Updated unrar source from 5.9.4 to 6.0.5

This commit is contained in:
Jens Steube
2021-05-15 11:31:42 +02:00
parent ce90f83b65
commit f4ca10b116
32 changed files with 400 additions and 94 deletions
+22 -6
View File
@@ -8,7 +8,6 @@ File::File()
LastWrite=false;
HandleType=FILE_HANDLENORMAL;
SkipClose=false;
IgnoreReadErrors=false;
ErrorType=FILE_SUCCESS;
OpenShared=false;
AllowDelete=true;
@@ -18,6 +17,8 @@ File::File()
NoSequentialRead=false;
CreateMode=FMF_UNDEFINED;
#endif
ReadErrorMode=FREM_ASK;
TruncatedAfterReadError=false;
}
@@ -37,6 +38,7 @@ void File::operator = (File &SrcFile)
NewFile=SrcFile.NewFile;
LastWrite=SrcFile.LastWrite;
HandleType=SrcFile.HandleType;
TruncatedAfterReadError=SrcFile.TruncatedAfterReadError;
wcsncpyz(FileName,SrcFile.FileName,ASIZE(FileName));
SrcFile.SkipClose=true;
}
@@ -118,12 +120,12 @@ bool File::Open(const wchar *Name,uint Mode)
#ifdef _OSF_SOURCE
extern "C" int flock(int, int);
#endif
if (!OpenShared && UpdateMode && handle>=0 && flock(handle,LOCK_EX|LOCK_NB)==-1)
{
close(handle);
return false;
}
#endif
if (handle==-1)
hNewFile=FILE_BAD_HANDLE;
@@ -146,6 +148,7 @@ bool File::Open(const wchar *Name,uint Mode)
{
hFile=hNewFile;
wcsncpyz(FileName,Name,ASIZE(FileName));
TruncatedAfterReadError=false;
}
return Success;
}
@@ -369,9 +372,12 @@ bool File::Write(const void *Data,size_t Size)
int File::Read(void *Data,size_t Size)
{
if (TruncatedAfterReadError)
return 0;
int64 FilePos=0; // Initialized only to suppress some compilers warning.
if (IgnoreReadErrors)
if (ReadErrorMode==FREM_IGNORE)
FilePos=Tell();
int ReadSize;
while (true)
@@ -381,7 +387,7 @@ int File::Read(void *Data,size_t Size)
{
ErrorType=FILE_READERROR;
if (AllowExceptions)
if (IgnoreReadErrors)
if (ReadErrorMode==FREM_IGNORE)
{
ReadSize=0;
for (size_t I=0;I<Size;I+=512)
@@ -394,8 +400,18 @@ int File::Read(void *Data,size_t Size)
}
else
{
if (HandleType==FILE_HANDLENORMAL && ErrHandler.AskRepeatRead(FileName))
continue;
bool Ignore=false,Retry=false,Quit=false;
if (ReadErrorMode==FREM_ASK && HandleType==FILE_HANDLENORMAL)
{
ErrHandler.AskRepeatRead(FileName,Ignore,Retry,Quit);
if (Retry)
continue;
}
if (Ignore || ReadErrorMode==FREM_TRUNCATE)
{
TruncatedAfterReadError=true;
return 0;
}
ErrHandler.ReadError(FileName);
}
}