summaryrefslogtreecommitdiffstatshomepage
path: root/3rdparty/lzma/CPP/7zip/UI/Common/OpenArchive.h
diff options
context:
space:
mode:
Diffstat (limited to '3rdparty/lzma/CPP/7zip/UI/Common/OpenArchive.h')
-rw-r--r--3rdparty/lzma/CPP/7zip/UI/Common/OpenArchive.h136
1 files changed, 94 insertions, 42 deletions
diff --git a/3rdparty/lzma/CPP/7zip/UI/Common/OpenArchive.h b/3rdparty/lzma/CPP/7zip/UI/Common/OpenArchive.h
index d46d69e8a8d..5c3bfe5df95 100644
--- a/3rdparty/lzma/CPP/7zip/UI/Common/OpenArchive.h
+++ b/3rdparty/lzma/CPP/7zip/UI/Common/OpenArchive.h
@@ -1,15 +1,16 @@
// OpenArchive.h
-#ifndef __OPEN_ARCHIVE_H
-#define __OPEN_ARCHIVE_H
+#ifndef ZIP7_INC_OPEN_ARCHIVE_H
+#define ZIP7_INC_OPEN_ARCHIVE_H
#include "../../../Windows/PropVariant.h"
#include "ArchiveOpenCallback.h"
#include "LoadCodecs.h"
#include "Property.h"
+#include "DirItem.h"
-#ifndef _SFX
+#ifndef Z7_SFX
#define SUPPORT_ALT_STREAMS
@@ -33,7 +34,7 @@ struct COptionalOpenProperties
};
*/
-#ifdef _SFX
+#ifdef Z7_SFX
#define OPEN_PROPS_DECL
#else
#define OPEN_PROPS_DECL const CObjectVector<CProperty> *props;
@@ -70,6 +71,7 @@ struct COpenType
bool CanReturnArc;
bool CanReturnParser;
+ bool IsHashType;
bool EachPos;
// bool SkipSfxStub;
@@ -88,9 +90,10 @@ struct COpenType
COpenType():
FormatIndex(-1),
Recursive(true),
- EachPos(false),
CanReturnArc(true),
CanReturnParser(false),
+ IsHashType(false),
+ EachPos(false),
// SkipSfxStub(true),
// ExeAsUnknown(true),
ZerosTailIsAllowed(false),
@@ -121,7 +124,7 @@ struct COpenOptions
IInStream *stream;
ISequentialInStream *seqStream;
IArchiveOpenCallback *callback;
- COpenCallbackImp *callbackSpec;
+ COpenCallbackImp *callbackSpec; // it's used for SFX only
OPEN_PROPS_DECL
// bool openOnlySpecifiedByExtension,
@@ -240,7 +243,7 @@ struct CReadArcItem
bool MainIsDir;
UInt32 ParentIndex; // use it, if IsAltStream
- #ifndef _SFX
+ #ifndef Z7_SFX
bool _use_baseParentFolder_mode;
int _baseParentFolder;
#endif
@@ -251,22 +254,25 @@ struct CReadArcItem
WriteToAltStreamIfColon = false;
#endif
- #ifndef _SFX
+ #ifndef Z7_SFX
_use_baseParentFolder_mode = false;
_baseParentFolder = -1;
#endif
}
};
+
+
+
class CArc
{
HRESULT PrepareToOpen(const COpenOptions &op, unsigned formatIndex, CMyComPtr<IInArchive> &archive);
HRESULT CheckZerosTail(const COpenOptions &op, UInt64 offset);
HRESULT OpenStream2(const COpenOptions &options);
- #ifndef _SFX
+ #ifndef Z7_SFX
// parts.Back() can contain alt stream name "nams:AltName"
- HRESULT GetItemPathToParent(UInt32 index, UInt32 parent, UStringVector &parts) const;
+ HRESULT GetItem_PathToParent(UInt32 index, UInt32 parent, UStringVector &parts) const;
#endif
public:
@@ -279,49 +285,50 @@ public:
CMyComPtr<IArchiveGetRawProps> GetRawProps;
CMyComPtr<IArchiveGetRootProps> GetRootProps;
- CArcErrorInfo ErrorInfo; // for OK archives
- CArcErrorInfo NonOpen_ErrorInfo; // ErrorInfo for mainArchive (false OPEN)
+ bool IsParseArc;
+
+ bool IsTree;
+ bool IsReadOnly;
+
+ bool Ask_Deleted;
+ bool Ask_AltStream;
+ bool Ask_Aux;
+ bool Ask_INode;
+
+ bool IgnoreSplit; // don't try split handler
UString Path;
UString filePath;
UString DefaultName;
- int FormatIndex; // - 1 means Parser.
- int SubfileIndex;
- FILETIME MTime;
- bool MTimeDefined;
+ int FormatIndex; // -1 means Parser
+ UInt32 SubfileIndex; // (UInt32)(Int32)-1; means no subfile
+
+ // CFiTime MTime;
+ // bool MTime_Defined;
+ CArcTime MTime;
Int64 Offset; // it's offset of start of archive inside stream that is open by Archive Handler
UInt64 PhySize;
// UInt64 OkPhySize;
- bool PhySizeDefined;
+ bool PhySize_Defined;
// bool OkPhySize_Defined;
UInt64 FileSize;
UInt64 AvailPhySize; // PhySize, but it's reduced if exceed end of file
- // bool offsetDefined;
- UInt64 GetEstmatedPhySize() const { return PhySizeDefined ? PhySize : FileSize; }
+ CArcErrorInfo ErrorInfo; // for OK archives
+ CArcErrorInfo NonOpen_ErrorInfo; // ErrorInfo for mainArchive (false OPEN)
+
+ UInt64 GetEstmatedPhySize() const { return PhySize_Defined ? PhySize : FileSize; }
UInt64 ArcStreamOffset; // offset of stream that is open by Archive Handler
- Int64 GetGlobalOffset() const { return ArcStreamOffset + Offset; } // it's global offset of archive
+ Int64 GetGlobalOffset() const { return (Int64)ArcStreamOffset + Offset; } // it's global offset of archive
// AString ErrorFlagsText;
- bool IsParseArc;
-
- bool IsTree;
- bool IsReadOnly;
-
- bool Ask_Deleted;
- bool Ask_AltStream;
- bool Ask_Aux;
- bool Ask_INode;
-
- bool IgnoreSplit; // don't try split handler
-
// void Set_ErrorFlagsText();
CArc():
- MTimeDefined(false),
+ // MTime_Defined(false),
IsTree(false),
IsReadOnly(false),
Ask_Deleted(false),
@@ -333,34 +340,51 @@ public:
HRESULT ReadBasicProps(IInArchive *archive, UInt64 startPos, HRESULT openRes);
- // ~CArc();
-
HRESULT Close()
{
InStream.Release();
return Archive->Close();
}
- HRESULT GetItemPath(UInt32 index, UString &result) const;
- HRESULT GetDefaultItemPath(UInt32 index, UString &result) const;
+ HRESULT GetItem_Path(UInt32 index, UString &result) const;
+ HRESULT GetItem_DefaultPath(UInt32 index, UString &result) const;
// GetItemPath2 adds [DELETED] dir prefix for deleted items.
- HRESULT GetItemPath2(UInt32 index, UString &result) const;
+ HRESULT GetItem_Path2(UInt32 index, UString &result) const;
HRESULT GetItem(UInt32 index, CReadArcItem &item) const;
- HRESULT GetItemSize(UInt32 index, UInt64 &size, bool &defined) const;
- HRESULT GetItemMTime(UInt32 index, FILETIME &ft, bool &defined) const;
- HRESULT IsItemAnti(UInt32 index, bool &result) const
+ HRESULT GetItem_Size(UInt32 index, UInt64 &size, bool &defined) const;
+
+ /* if (GetProperty() returns vt==VT_EMPTY), this function sets
+ timestamp from archive file timestamp (MTime).
+ So (at) will be set in most cases (at.Def == true)
+ if (at.Prec == 0)
+ {
+ it means that (Prec == 0) was returned for (kpidMTime),
+ and no value was returned for (kpidTimeType).
+ it can mean Windows precision or unknown precision.
+ }
+ */
+ HRESULT GetItem_MTime(UInt32 index, CArcTime &at) const;
+
+ HRESULT IsItem_Anti(UInt32 index, bool &result) const
{ return Archive_GetItemBoolProp(Archive, index, kpidIsAnti, result); }
HRESULT OpenStream(const COpenOptions &options);
HRESULT OpenStreamOrFile(COpenOptions &options);
- HRESULT ReOpen(const COpenOptions &options);
+ HRESULT ReOpen(const COpenOptions &options, IArchiveOpenCallback *openCallback_Additional);
HRESULT CreateNewTailStream(CMyComPtr<IInStream> &stream);
+
+ bool IsHashHandler(const COpenOptions &options) const
+ {
+ if (FormatIndex < 0)
+ return false;
+ return options.codecs->Formats[(unsigned)FormatIndex].Flags_HashHandler();
+ }
};
struct CArchiveLink
@@ -397,6 +421,13 @@ struct CArchiveLink
IArchiveGetRawProps *GetArchiveGetRawProps() const { return Arcs.Back().GetRawProps; }
IArchiveGetRootProps *GetArchiveGetRootProps() const { return Arcs.Back().GetRootProps; }
+ /*
+ Open() opens archive and COpenOptions::callback
+ Open2() uses COpenCallbackImp that implements Volumes and password callback
+ Open3() calls Open2() and callbackUI->Open_Finished();
+ Open_Strict() returns S_FALSE also in case, if there is non-open expected nested archive.
+ */
+
HRESULT Open(COpenOptions &options);
HRESULT Open2(COpenOptions &options, IOpenCallbackUI *callbackUI);
HRESULT Open3(COpenOptions &options, IOpenCallbackUI *callbackUI);
@@ -414,4 +445,25 @@ struct CArchiveLink
bool ParseOpenTypes(CCodecs &codecs, const UString &s, CObjectVector<COpenType> &types);
+// bool IsHashType(const CObjectVector<COpenType> &types);
+
+
+struct CDirPathSortPair
+{
+ unsigned Len;
+ unsigned Index;
+
+ void SetNumSlashes(const FChar *s);
+
+ int Compare(const CDirPathSortPair &a) const
+ {
+ // We need sorting order where parent items will be after child items
+ if (Len < a.Len) return 1;
+ if (Len > a.Len) return -1;
+ if (Index < a.Index) return -1;
+ if (Index > a.Index) return 1;
+ return 0;
+ }
+};
+
#endif