file.cpp (unrarsrc-6.1.3) | : | file.cpp (unrarsrc-6.1.4) | ||
---|---|---|---|---|
#include "rar.hpp" | #include "rar.hpp" | |||
File::File() | File::File() | |||
{ | { | |||
hFile=FILE_BAD_HANDLE; | hFile=FILE_BAD_HANDLE; | |||
*FileName=0; | *FileName=0; | |||
NewFile=false; | NewFile=false; | |||
LastWrite=false; | LastWrite=false; | |||
HandleType=FILE_HANDLENORMAL; | HandleType=FILE_HANDLENORMAL; | |||
LineInput=false; | ||||
SkipClose=false; | SkipClose=false; | |||
ErrorType=FILE_SUCCESS; | ErrorType=FILE_SUCCESS; | |||
OpenShared=false; | OpenShared=false; | |||
AllowDelete=true; | AllowDelete=true; | |||
AllowExceptions=true; | AllowExceptions=true; | |||
PreserveAtime=false; | PreserveAtime=false; | |||
#ifdef _WIN_ALL | #ifdef _WIN_ALL | |||
CreateMode=FMF_UNDEFINED; | CreateMode=FMF_UNDEFINED; | |||
#endif | #endif | |||
ReadErrorMode=FREM_ASK; | ReadErrorMode=FREM_ASK; | |||
skipping to change at line 410 | skipping to change at line 411 | |||
if (Ignore || ReadErrorMode==FREM_TRUNCATE) | if (Ignore || ReadErrorMode==FREM_TRUNCATE) | |||
{ | { | |||
TruncatedAfterReadError=true; | TruncatedAfterReadError=true; | |||
return 0; | return 0; | |||
} | } | |||
ErrHandler.ReadError(FileName); | ErrHandler.ReadError(FileName); | |||
} | } | |||
} | } | |||
TotalRead+=ReadSize; // If ReadSize is -1, TotalRead is also set to -1 here. | TotalRead+=ReadSize; // If ReadSize is -1, TotalRead is also set to -1 here. | |||
if (HandleType==FILE_HANDLESTD && ReadSize>0 && (uint)ReadSize<Size) | if (HandleType==FILE_HANDLESTD && !LineInput && ReadSize>0 && (uint)ReadSize <Size) | |||
{ | { | |||
// Unlike regular files, for pipe we can read only as much as was | // Unlike regular files, for pipe we can read only as much as was | |||
// written at the other end of pipe. We had seen data coming in small | // written at the other end of pipe. We had seen data coming in small | |||
// ~80 byte chunks when piping from 'type arc.rar'. Extraction code | // ~80 byte chunks when piping from 'type arc.rar'. Extraction code | |||
// would fail if we read an incomplete archive header from stdin. | // would fail if we read an incomplete archive header from stdin. | |||
// So here we ensure that requested size is completely read. | // So here we ensure that requested size is completely read. | |||
// But we return the available data immediately in "line input" mode, | ||||
// when processing user's input in console prompts. Otherwise apps | ||||
// piping user responses to multiple Ask() prompts can hang if no more | ||||
// data is available yet and pipe isn't closed. | ||||
Data=(byte*)Data+ReadSize; | Data=(byte*)Data+ReadSize; | |||
Size-=ReadSize; | Size-=ReadSize; | |||
continue; | continue; | |||
} | } | |||
break; | break; | |||
} | } | |||
if (TotalRead>0) // Can be -1 for error and AllowExceptions disabled. | if (TotalRead>0) // Can be -1 for error and AllowExceptions disabled. | |||
CurFilePos+=TotalRead; | CurFilePos+=TotalRead; | |||
return TotalRead; // It can return -1 only if AllowExceptions is disabled. | return TotalRead; // It can return -1 only if AllowExceptions is disabled. | |||
} | } | |||
End of changes. 3 change blocks. | ||||
1 lines changed or deleted | 6 lines changed or added |