Update.cpp (p7zip_15.14.1_src_all) | : | Update.cpp (p7zip_16.02_src_all) | ||
---|---|---|---|---|
skipping to change at line 759 | skipping to change at line 759 | |||
RINOK(SetProperties(outArchive, options.MethodMode.Properties)); | RINOK(SetProperties(outArchive, options.MethodMode.Properties)); | |||
if (options.SfxMode) | if (options.SfxMode) | |||
{ | { | |||
CInFileStream *sfxStreamSpec = new CInFileStream; | CInFileStream *sfxStreamSpec = new CInFileStream; | |||
CMyComPtr<IInStream> sfxStream(sfxStreamSpec); | CMyComPtr<IInStream> sfxStream(sfxStreamSpec); | |||
if (!sfxStreamSpec->Open(options.SfxModule)) | if (!sfxStreamSpec->Open(options.SfxModule)) | |||
return errorInfo.SetFromLastError("cannot open SFX module", options.SfxMod ule); | return errorInfo.SetFromLastError("cannot open SFX module", options.SfxMod ule); | |||
CMyComPtr<ISequentialOutStream> sfxOutStream; | CMyComPtr<ISequentialOutStream> sfxOutStream; | |||
COutFileStream *outStreamSpec = NULL; | COutFileStream *outStreamSpec2 = NULL; | |||
if (options.VolumesSizes.Size() == 0) | if (options.VolumesSizes.Size() == 0) | |||
sfxOutStream = outStream; | sfxOutStream = outStream; | |||
else | else | |||
{ | { | |||
outStreamSpec = new COutFileStream; | outStreamSpec2 = new COutFileStream; | |||
sfxOutStream = outStreamSpec; | sfxOutStream = outStreamSpec2; | |||
FString realPath = us2fs(archivePath.GetFinalPath()); | FString realPath = us2fs(archivePath.GetFinalPath()); | |||
if (!outStreamSpec->Create(realPath, false)) | if (!outStreamSpec2->Create(realPath, false)) | |||
return errorInfo.SetFromLastError("cannot open file", realPath); | return errorInfo.SetFromLastError("cannot open file", realPath); | |||
} | } | |||
{ | { | |||
UInt64 sfxSize; | UInt64 sfxSize; | |||
RINOK(sfxStreamSpec->GetSize(&sfxSize)); | RINOK(sfxStreamSpec->GetSize(&sfxSize)); | |||
RINOK(callback->WriteSfx(fs2us(options.SfxModule), sfxSize)); | RINOK(callback->WriteSfx(fs2us(options.SfxModule), sfxSize)); | |||
} | } | |||
RINOK(NCompress::CopyStream(sfxStream, sfxOutStream, NULL)); | RINOK(NCompress::CopyStream(sfxStream, sfxOutStream, NULL)); | |||
if (outStreamSpec) | if (outStreamSpec2) | |||
{ | { | |||
RINOK(outStreamSpec->Close()); | RINOK(outStreamSpec2->Close()); | |||
} | } | |||
} | } | |||
CMyComPtr<ISequentialOutStream> tailStream; | CMyComPtr<ISequentialOutStream> tailStream; | |||
if (options.SfxMode || !arc || arc->ArcStreamOffset == 0) | if (options.SfxMode || !arc || arc->ArcStreamOffset == 0) | |||
tailStream = outStream; | tailStream = outStream; | |||
else | else | |||
{ | { | |||
// Int64 globalOffset = arc->GetGlobalOffset(); | // Int64 globalOffset = arc->GetGlobalOffset(); | |||
skipping to change at line 1058 | skipping to change at line 1058 | |||
} | } | |||
CArchiveLink arcLink; | CArchiveLink arcLink; | |||
if (needSetPath) | if (needSetPath) | |||
{ | { | |||
if (!options.InitFormatIndex(codecs, types, cmdArcPath2) || | if (!options.InitFormatIndex(codecs, types, cmdArcPath2) || | |||
!options.SetArcPath(codecs, cmdArcPath2)) | !options.SetArcPath(codecs, cmdArcPath2)) | |||
return E_NOTIMPL; | return E_NOTIMPL; | |||
} | } | |||
UString arcPath = options.ArchivePath.GetFinalPath(); | const UString arcPath = options.ArchivePath.GetFinalPath(); | |||
if (cmdArcPath2.IsEmpty()) | if (cmdArcPath2.IsEmpty()) | |||
{ | { | |||
if (options.MethodMode.Type.FormatIndex < 0) | if (options.MethodMode.Type.FormatIndex < 0) | |||
throw "type of archive is not specified"; | throw "type of archive is not specified"; | |||
} | } | |||
else | else | |||
{ | { | |||
NFind::CFileInfo fi; | NFind::CFileInfo fi; | |||
if (!fi.Find(us2fs(arcPath))) | if (!fi.Find(us2fs(arcPath))) | |||
skipping to change at line 1086 | skipping to change at line 1086 | |||
} | } | |||
} | } | |||
else | else | |||
{ | { | |||
if (fi.IsDir()) | if (fi.IsDir()) | |||
throw "there is no such archive"; | throw "there is no such archive"; | |||
if (fi.IsDevice) | if (fi.IsDevice) | |||
return E_NOTIMPL; | return E_NOTIMPL; | |||
if (options.VolumesSizes.Size() > 0) | if (options.VolumesSizes.Size() > 0) | |||
return E_NOTIMPL; | return E_NOTIMPL; | |||
CObjectVector<COpenType> types; | CObjectVector<COpenType> types2; | |||
// change it. | // change it. | |||
if (options.MethodMode.Type_Defined) | if (options.MethodMode.Type_Defined) | |||
types.Add(options.MethodMode.Type); | types2.Add(options.MethodMode.Type); | |||
// We need to set Properties to open archive only in some cases (WIM archi ves). | // We need to set Properties to open archive only in some cases (WIM archi ves). | |||
CIntVector excl; | CIntVector excl; | |||
COpenOptions op; | COpenOptions op; | |||
#ifndef _SFX | #ifndef _SFX | |||
op.props = &options.MethodMode.Properties; | op.props = &options.MethodMode.Properties; | |||
#endif | #endif | |||
op.codecs = codecs; | op.codecs = codecs; | |||
op.types = &types; | op.types = &types2; | |||
op.excludedFormats = ! | op.excludedFormats = ! | |||
op.stdInMode = false; | op.stdInMode = false; | |||
op.stream = NULL; | op.stream = NULL; | |||
op.filePath = arcPath; | op.filePath = arcPath; | |||
RINOK(callback->StartOpenArchive(arcPath)); | RINOK(callback->StartOpenArchive(arcPath)); | |||
HRESULT result = arcLink.Open3(op, openCallback); | HRESULT result = arcLink.Open3(op, openCallback); | |||
if (result == E_ABORT) | if (result == E_ABORT) | |||
skipping to change at line 1287 | skipping to change at line 1287 | |||
createTempFile = true; | createTempFile = true; | |||
ap.Temp = true; | ap.Temp = true; | |||
if (!options.WorkingDir.IsEmpty()) | if (!options.WorkingDir.IsEmpty()) | |||
ap.TempPrefix = options.WorkingDir; | ap.TempPrefix = options.WorkingDir; | |||
else | else | |||
ap.TempPrefix = us2fs(ap.Prefix); | ap.TempPrefix = us2fs(ap.Prefix); | |||
NormalizeDirPathPrefix(ap.TempPrefix); | NormalizeDirPathPrefix(ap.TempPrefix); | |||
} | } | |||
} | } | |||
unsigned i; | unsigned ci; | |||
for (i = 0; i < options.Commands.Size(); i++) | ||||
for (ci = 0; ci < options.Commands.Size(); ci++) | ||||
{ | { | |||
CArchivePath &ap = options.Commands[i].ArchivePath; | CArchivePath &ap = options.Commands[ci].ArchivePath; | |||
if (usesTempDir) | if (usesTempDir) | |||
{ | { | |||
// Check it | // Check it | |||
ap.Prefix = fs2us(tempDirPrefix); | ap.Prefix = fs2us(tempDirPrefix); | |||
// ap.Temp = true; | // ap.Temp = true; | |||
// ap.TempPrefix = tempDirPrefix; | // ap.TempPrefix = tempDirPrefix; | |||
} | } | |||
if (!options.StdOutMode && | if (!options.StdOutMode && | |||
(i > 0 || !createTempFile)) | (ci > 0 || !createTempFile)) | |||
{ | { | |||
const FString path = us2fs(ap.GetFinalPath()); | const FString path = us2fs(ap.GetFinalPath()); | |||
if (NFind::DoesFileOrDirExist(path)) | if (NFind::DoesFileOrDirExist(path)) | |||
{ | { | |||
errorInfo.SystemError = ERROR_FILE_EXISTS; | errorInfo.SystemError = ERROR_FILE_EXISTS; | |||
errorInfo.Message = "The file already exists"; | errorInfo.Message = "The file already exists"; | |||
errorInfo.FileNames.Add(path); | errorInfo.FileNames.Add(path); | |||
return errorInfo.Get_HRESULT_Error(); | return errorInfo.Get_HRESULT_Error(); | |||
} | } | |||
} | } | |||
skipping to change at line 1332 | skipping to change at line 1333 | |||
FStringVector *processedFilePaths_Ptr = NULL; | FStringVector *processedFilePaths_Ptr = NULL; | |||
if (options.DeleteAfterCompressing) | if (options.DeleteAfterCompressing) | |||
processedFilePaths_Ptr = &processedFilePaths; | processedFilePaths_Ptr = &processedFilePaths; | |||
*/ | */ | |||
CByteBuffer processedItems; | CByteBuffer processedItems; | |||
if (options.DeleteAfterCompressing) | if (options.DeleteAfterCompressing) | |||
{ | { | |||
unsigned num = dirItems.Items.Size(); | unsigned num = dirItems.Items.Size(); | |||
processedItems.Alloc(num); | processedItems.Alloc(num); | |||
for (i = 0; i < num; i++) | for (unsigned i = 0; i < num; i++) | |||
processedItems[i] = 0; | processedItems[i] = 0; | |||
} | } | |||
/* | /* | |||
#ifndef _NO_CRYPTO | #ifndef _NO_CRYPTO | |||
if (arcLink.PasswordWasAsked) | if (arcLink.PasswordWasAsked) | |||
{ | { | |||
// We set password, if open have requested password | // We set password, if open have requested password | |||
RINOK(callback->SetPassword(arcLink.Password)); | RINOK(callback->SetPassword(arcLink.Password)); | |||
} | } | |||
#endif | #endif | |||
*/ | */ | |||
for (i = 0; i < options.Commands.Size(); i++) | for (ci = 0; ci < options.Commands.Size(); ci++) | |||
{ | { | |||
const CArc *arc = thereIsInArchive ? arcLink.GetArc() : NULL; | const CArc *arc = thereIsInArchive ? arcLink.GetArc() : NULL; | |||
CUpdateArchiveCommand &command = options.Commands[i]; | CUpdateArchiveCommand &command = options.Commands[ci]; | |||
UString name; | UString name; | |||
bool isUpdating; | bool isUpdating; | |||
if (options.StdOutMode) | if (options.StdOutMode) | |||
{ | { | |||
name.SetFromAscii("stdout"); | name.SetFromAscii("stdout"); | |||
isUpdating = thereIsInArchive; | isUpdating = thereIsInArchive; | |||
} | } | |||
else | else | |||
{ | { | |||
name = command.ArchivePath.GetFinalPath(); | name = command.ArchivePath.GetFinalPath(); | |||
isUpdating = (i == 0 && options.UpdateArchiveItself && thereIsInArchive); | isUpdating = (ci == 0 && options.UpdateArchiveItself && thereIsInArchive); | |||
} | } | |||
RINOK(callback->StartArchive(name, isUpdating)) | RINOK(callback->StartArchive(name, isUpdating)) | |||
CFinishArchiveStat st; | CFinishArchiveStat st; | |||
RINOK(Compress(options, | RINOK(Compress(options, | |||
isUpdating, | isUpdating, | |||
codecs, | codecs, | |||
command.ActionSet, | command.ActionSet, | |||
skipping to change at line 1451 | skipping to change at line 1452 | |||
return errorInfo.Get_HRESULT_Error();; | return errorInfo.Get_HRESULT_Error();; | |||
} | } | |||
FStringVector fullPaths; | FStringVector fullPaths; | |||
unsigned i; | unsigned i; | |||
for (i = 0; i < options.Commands.Size(); i++) | for (i = 0; i < options.Commands.Size(); i++) | |||
{ | { | |||
CArchivePath &ap = options.Commands[i].ArchivePath; | CArchivePath &ap = options.Commands[i].ArchivePath; | |||
FString finalPath = us2fs(ap.GetFinalPath()); | FString finalPath = us2fs(ap.GetFinalPath()); | |||
FString arcPath; | FString arcPath2; | |||
if (!MyGetFullPathName(finalPath, arcPath)) | if (!MyGetFullPathName(finalPath, arcPath2)) | |||
return errorInfo.SetFromLastError("GetFullPathName error", finalPath); | return errorInfo.SetFromLastError("GetFullPathName error", finalPath); | |||
fullPaths.Add(arcPath); | fullPaths.Add(arcPath2); | |||
} | } | |||
CCurrentDirRestorer curDirRestorer; | CCurrentDirRestorer curDirRestorer; | |||
for (i = 0; i < fullPaths.Size(); i++) | for (i = 0; i < fullPaths.Size(); i++) | |||
{ | { | |||
UString arcPath = fs2us(fullPaths[i]); | UString arcPath2 = fs2us(fullPaths[i]); | |||
UString fileName = ExtractFileNameFromPath(arcPath); | UString fileName = ExtractFileNameFromPath(arcPath2); | |||
AString path = GetAnsiString(arcPath); | AString path = GetAnsiString(arcPath2); | |||
AString name = GetAnsiString(fileName); | AString name = GetAnsiString(fileName); | |||
// Warning!!! MAPISendDocuments function changes Current directory | // Warning!!! MAPISendDocuments function changes Current directory | |||
// fnSend(0, ";", (LPSTR)(LPCSTR)path, (LPSTR)(LPCSTR)name, 0); | // fnSend(0, ";", (LPSTR)(LPCSTR)path, (LPSTR)(LPCSTR)name, 0); | |||
MapiFileDesc f; | MapiFileDesc f; | |||
memset(&f, 0, sizeof(f)); | memset(&f, 0, sizeof(f)); | |||
f.nPosition = 0xFFFFFFFF; | f.nPosition = 0xFFFFFFFF; | |||
f.lpszPathName = (char *)(const char *)path; | f.lpszPathName = (char *)(const char *)path; | |||
f.lpszFileName = (char *)(const char *)name; | f.lpszFileName = (char *)(const char *)name; | |||
skipping to change at line 1501 | skipping to change at line 1502 | |||
} | } | |||
} | } | |||
#endif | #endif | |||
if (options.DeleteAfterCompressing) | if (options.DeleteAfterCompressing) | |||
{ | { | |||
CRecordVector<CRefSortPair> pairs; | CRecordVector<CRefSortPair> pairs; | |||
FStringVector foldersNames; | FStringVector foldersNames; | |||
unsigned i; | ||||
for (i = 0; i < dirItems.Items.Size(); i++) | for (i = 0; i < dirItems.Items.Size(); i++) | |||
{ | { | |||
const CDirItem &dirItem = dirItems.Items[i]; | const CDirItem &dirItem = dirItems.Items[i]; | |||
FString phyPath = dirItems.GetPhyPath(i); | FString phyPath = dirItems.GetPhyPath(i); | |||
if (dirItem.IsDir()) | if (dirItem.IsDir()) | |||
{ | { | |||
CRefSortPair pair; | CRefSortPair pair; | |||
pair.Index = i; | pair.Index = i; | |||
pair.Len = GetNumSlashes(phyPath); | pair.Len = GetNumSlashes(phyPath); | |||
pairs.Add(pair); | pairs.Add(pair); | |||
End of changes. 20 change blocks. | ||||
24 lines changed or deleted | 27 lines changed or added |