Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mpc-hc/mpc-hc.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'src/thirdparty/unrar/file.cpp')
-rw-r--r--src/thirdparty/unrar/file.cpp9
1 files changed, 8 insertions, 1 deletions
diff --git a/src/thirdparty/unrar/file.cpp b/src/thirdparty/unrar/file.cpp
index c67692c99..2c4de580c 100644
--- a/src/thirdparty/unrar/file.cpp
+++ b/src/thirdparty/unrar/file.cpp
@@ -57,14 +57,21 @@ bool File::Open(const wchar *Name,uint Mode)
uint Flags=NoSequentialRead ? 0:FILE_FLAG_SEQUENTIAL_SCAN;
hNewFile=CreateFile(Name,Access,ShareMode,NULL,OPEN_EXISTING,Flags,NULL);
+ DWORD LastError;
if (hNewFile==BAD_HANDLE)
{
+ // Following CreateFile("\\?\path") call can change the last error code
+ // from "not found" to "access denied" for relative paths like "..\path".
+ // But we need the correct "not found" code to create a new archive
+ // if existing one is not found. So we preserve the code here.
+ LastError=GetLastError();
+
wchar LongName[NM];
if (GetWinLongPath(Name,LongName,ASIZE(LongName)))
hNewFile=CreateFile(LongName,Access,ShareMode,NULL,OPEN_EXISTING,Flags,NULL);
}
- if (hNewFile==BAD_HANDLE && GetLastError()==ERROR_FILE_NOT_FOUND)
+ if (hNewFile==BAD_HANDLE && LastError==ERROR_FILE_NOT_FOUND)
ErrorType=FILE_NOTFOUND;
#else
int flags=UpdateMode ? O_RDWR:(WriteMode ? O_WRONLY:O_RDONLY);