[core] avoid the use of FILE_SHARE_WRITE

* Not having FILE_SHARE_WRITE on a disk or volume handle helps
  prevent spurious accesses from the OS or other apps while we
  are repartitioning/refomatting.
This commit is contained in:
Pete Batard 2017-02-16 14:13:30 +00:00
parent c877284d2a
commit 2f81e4f177
11 changed files with 50 additions and 31 deletions

View file

@ -248,7 +248,7 @@ static BOOL ExtractFAT(int entry, const char* path)
}
/* Create a file, using the same attributes as found in the FAT */
hFile = CreateFileA(filename, GENERIC_READ|GENERIC_WRITE, FILE_SHARE_READ|FILE_SHARE_WRITE,
hFile = CreateFileA(filename, GENERIC_READ|GENERIC_WRITE, FILE_SHARE_READ,
NULL, CREATE_ALWAYS, dir_entry->Attributes, NULL);
if (hFile == INVALID_HANDLE_VALUE) {
uprintf("Unable to create file '%s': %s.\n", filename, WindowsErrorString());
@ -385,7 +385,7 @@ BOOL ExtractFreeDOS(const char* path)
safe_strcpy(filename, sizeof(filename), ((i<2)?path:locale_path));
safe_strcat(filename, sizeof(filename), res_name[i]);
hFile = CreateFileA(filename, GENERIC_READ|GENERIC_WRITE, FILE_SHARE_READ|FILE_SHARE_WRITE, NULL,
hFile = CreateFileA(filename, GENERIC_READ|GENERIC_WRITE, FILE_SHARE_READ, NULL,
CREATE_ALWAYS, (i<2)?(FILE_ATTRIBUTE_HIDDEN|FILE_ATTRIBUTE_SYSTEM):FILE_ATTRIBUTE_NORMAL, NULL);
if ((hFile == NULL) || (hFile == INVALID_HANDLE_VALUE)) {
uprintf("Unable to create file '%s': %s.\n", filename, WindowsErrorString());