safely handle the case where an archive required for populating a directory cannot be opened (e.g. because it is open within 7-zip, which apparently wants exclusive access)
fixes #1021 This was SVN commit r10631.
This commit is contained in:
parent
b54ad51054
commit
24aa71b566
@ -568,7 +568,14 @@ private:
|
||||
|
||||
PIArchiveReader CreateArchiveReader_Zip(const OsPath& archivePathname)
|
||||
{
|
||||
return PIArchiveReader(new ArchiveReader_Zip(archivePathname));
|
||||
try
|
||||
{
|
||||
return PIArchiveReader(new ArchiveReader_Zip(archivePathname));
|
||||
}
|
||||
catch(Status)
|
||||
{
|
||||
return PIArchiveReader();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -737,5 +744,12 @@ private:
|
||||
|
||||
PIArchiveWriter CreateArchiveWriter_Zip(const OsPath& archivePathname, bool noDeflate)
|
||||
{
|
||||
return PIArchiveWriter(new ArchiveWriter_Zip(archivePathname, noDeflate));
|
||||
try
|
||||
{
|
||||
return PIArchiveWriter(new ArchiveWriter_Zip(archivePathname, noDeflate));
|
||||
}
|
||||
catch(Status)
|
||||
{
|
||||
return PIArchiveWriter();
|
||||
}
|
||||
}
|
||||
|
@ -29,7 +29,14 @@
|
||||
|
||||
#include "lib/file/archive/archive.h"
|
||||
|
||||
/**
|
||||
* @return 0 if opening the archive failed (e.g. because an external program is holding on to it)
|
||||
**/
|
||||
LIB_API PIArchiveReader CreateArchiveReader_Zip(const OsPath& archivePathname);
|
||||
|
||||
/**
|
||||
* @return 0 if opening the archive failed (e.g. because an external program is holding on to it)
|
||||
**/
|
||||
LIB_API PIArchiveWriter CreateArchiveWriter_Zip(const OsPath& archivePathname, bool noDeflate);
|
||||
|
||||
#endif // #ifndef INCLUDED_ARCHIVE_ZIP
|
||||
|
@ -141,7 +141,10 @@ private:
|
||||
if(pathname.Extension() == L".zip")
|
||||
{
|
||||
PIArchiveReader archiveReader = CreateArchiveReader_Zip(pathname);
|
||||
RETURN_STATUS_IF_ERR(archiveReader->ReadEntries(AddArchiveFile, (uintptr_t)this));
|
||||
// archiveReader == nullptr if file could not be opened (e.g. because
|
||||
// archive is currently open in another program)
|
||||
if(archiveReader)
|
||||
RETURN_STATUS_IF_ERR(archiveReader->ReadEntries(AddArchiveFile, (uintptr_t)this));
|
||||
}
|
||||
else // regular (non-archive) file
|
||||
AddFile(files[i]);
|
||||
|
Loading…
Reference in New Issue
Block a user