diff options
author | XhmikosR <xhmikosr@gmail.com> | 2014-11-03 20:58:35 +0300 |
---|---|---|
committer | XhmikosR <xhmikosr@gmail.com> | 2014-11-11 22:54:31 +0300 |
commit | 7c45b2cd031940bce1315f34a51424e9625b2080 (patch) | |
tree | 596ebb8dfd067e7f74229a0d2a29ceae4245e3f7 /src/thirdparty/unrar/filefn.cpp | |
parent | adf4331c84b71e130a0f7b260f7942b99ef2f3f7 (diff) |
Update Unrar to v5.2.2.
Diffstat (limited to 'src/thirdparty/unrar/filefn.cpp')
-rw-r--r-- | src/thirdparty/unrar/filefn.cpp | 23 |
1 files changed, 19 insertions, 4 deletions
diff --git a/src/thirdparty/unrar/filefn.cpp b/src/thirdparty/unrar/filefn.cpp index e1baca9ab..6526f4337 100644 --- a/src/thirdparty/unrar/filefn.cpp +++ b/src/thirdparty/unrar/filefn.cpp @@ -29,6 +29,10 @@ MKDIR_CODE MakeDir(const wchar *Name,bool SetAttr,uint Attr) WideToChar(Name,NameA,ASIZE(NameA)); mode_t uattr=SetAttr ? (mode_t)Attr:0777; int ErrCode=mkdir(NameA,uattr); +#ifdef _ANDROID + if (ErrCode==-1 && errno!=ENOENT) + ErrCode=JniMkdir(Name) ? 0 : -1; // If external card is read-only for usual file API. +#endif if (ErrCode==-1) return errno==ENOENT ? MKDIR_BADPATH:MKDIR_ERROR; return MKDIR_SUCCESS; @@ -58,8 +62,9 @@ bool CreatePath(const wchar *Path,bool SkipLastName) break; // Process all kinds of path separators, so user can enter Unix style - // path in Windows or Windows in Unix. - if (IsPathDiv(*s)) + // path in Windows or Windows in Unix. s>Path check avoids attempting + // creating an empty directory for paths starting from path separator. + if (IsPathDiv(*s) && s>Path) { #ifdef _WIN_ALL // We must not attempt to create "D:" directory, because first @@ -411,7 +416,12 @@ bool RenameFile(const wchar *SrcName,const wchar *DestName) char SrcNameA[NM],DestNameA[NM]; WideToChar(SrcName,SrcNameA,ASIZE(SrcNameA)); WideToChar(DestName,DestNameA,ASIZE(DestNameA)); - return rename(SrcNameA,DestNameA)==0; + bool Success=rename(SrcNameA,DestNameA)==0; +#ifdef _ANDROID + if (!Success) + Success=JniRename(SrcName,DestName); // If external card is read-only for usual file API. +#endif + return Success; #endif } @@ -430,7 +440,12 @@ bool DelFile(const wchar *Name) #else char NameA[NM]; WideToChar(Name,NameA,ASIZE(NameA)); - return remove(NameA)==0; + bool Success=remove(NameA)==0; +#ifdef _ANDROID + if (!Success) + Success=JniDelete(Name); +#endif + return Success; #endif } |