mirror of
https://github.com/hrydgard/ppsspp.git
synced 2025-01-27 08:12:33 +00:00
Merge pull request #8802 from unknownbrackets/file-minor
Fix extract file and sharing violation handling
This commit is contained in:
commit
cad7235c86
@ -220,6 +220,17 @@ bool DirectoryFileHandle::Open(std::string &basePath, std::string &fileName, Fil
|
||||
bool success = hFile != INVALID_HANDLE_VALUE;
|
||||
if (!success) {
|
||||
DWORD w32err = GetLastError();
|
||||
|
||||
if (w32err == ERROR_SHARING_VIOLATION) {
|
||||
// Sometimes, the file is locked for write, let's try again.
|
||||
sharemode |= FILE_SHARE_WRITE;
|
||||
hFile = CreateFile(ConvertUTF8ToWString(fullName).c_str(), desired, sharemode, 0, openmode, 0, 0);
|
||||
success = hFile != INVALID_HANDLE_VALUE;
|
||||
if (!success) {
|
||||
w32err = GetLastError();
|
||||
}
|
||||
}
|
||||
|
||||
if (w32err == ERROR_DISK_FULL || w32err == ERROR_NOT_ENOUGH_QUOTA) {
|
||||
// This is returned when the disk is full.
|
||||
I18NCategory *err = GetI18NCategory("Error");
|
||||
|
@ -842,9 +842,11 @@ namespace MainWindow {
|
||||
FILE *fp = File::OpenCFile(fn, "wb");
|
||||
u32 handle = pspFileSystem.OpenFile(filename, FILEACCESS_READ, "");
|
||||
u8 buffer[4096];
|
||||
while (pspFileSystem.ReadFile(handle, buffer, sizeof(buffer)) > 0) {
|
||||
fwrite(buffer, sizeof(buffer), 1, fp);
|
||||
}
|
||||
size_t bytes;
|
||||
do {
|
||||
bytes = pspFileSystem.ReadFile(handle, buffer, sizeof(buffer));
|
||||
fwrite(buffer, 1, bytes, fp);
|
||||
} while (bytes == sizeof(buffer));
|
||||
pspFileSystem.CloseFile(handle);
|
||||
fclose(fp);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user