mirror of
https://github.com/reactos/reactos.git
synced 2024-07-08 05:35:06 +00:00
[FORMATTING] TABs -> 4 spaces
svn path=/trunk/; revision=32086
This commit is contained in:
parent
d91afce7df
commit
8dc242259f
File diff suppressed because it is too large
Load diff
|
@ -65,18 +65,18 @@
|
||||||
extern ULONG DebugTraceLevel;
|
extern ULONG DebugTraceLevel;
|
||||||
|
|
||||||
#define DPRINT(_t_, _x_) \
|
#define DPRINT(_t_, _x_) \
|
||||||
if (((DebugTraceLevel & NORMAL_MASK) >= _t_) || \
|
if (((DebugTraceLevel & NORMAL_MASK) >= _t_) || \
|
||||||
((DebugTraceLevel & _t_) > NORMAL_MASK)) { \
|
((DebugTraceLevel & _t_) > NORMAL_MASK)) { \
|
||||||
printf("(%s:%d)(%s) ", __FILE__, __LINE__, __FUNCTION__); \
|
printf("(%s:%d)(%s) ", __FILE__, __LINE__, __FUNCTION__); \
|
||||||
printf _x_ ; \
|
printf _x_ ; \
|
||||||
}
|
}
|
||||||
|
|
||||||
#define ASSERT(_b_) { \
|
#define ASSERT(_b_) { \
|
||||||
if (!(_b_)) { \
|
if (!(_b_)) { \
|
||||||
printf("(%s:%d)(%s) ASSERTION: ", __FILE__, __LINE__, __FUNCTION__); \
|
printf("(%s:%d)(%s) ASSERTION: ", __FILE__, __LINE__, __FUNCTION__); \
|
||||||
printf(#_b_); \
|
printf(#_b_); \
|
||||||
exit(0); \
|
exit(0); \
|
||||||
} \
|
} \
|
||||||
}
|
}
|
||||||
|
|
||||||
#else /* DBG */
|
#else /* DBG */
|
||||||
|
@ -123,108 +123,108 @@ extern ULONG DebugTraceLevel;
|
||||||
|
|
||||||
typedef struct _CFHEADER
|
typedef struct _CFHEADER
|
||||||
{
|
{
|
||||||
ULONG Signature; // File signature 'MSCF' (CAB_SIGNATURE)
|
ULONG Signature; // File signature 'MSCF' (CAB_SIGNATURE)
|
||||||
ULONG Reserved1; // Reserved field
|
ULONG Reserved1; // Reserved field
|
||||||
ULONG CabinetSize; // Cabinet file size
|
ULONG CabinetSize; // Cabinet file size
|
||||||
ULONG Reserved2; // Reserved field
|
ULONG Reserved2; // Reserved field
|
||||||
ULONG FileTableOffset; // Offset of first CFFILE
|
ULONG FileTableOffset; // Offset of first CFFILE
|
||||||
ULONG Reserved3; // Reserved field
|
ULONG Reserved3; // Reserved field
|
||||||
USHORT Version; // Cabinet version (CAB_VERSION)
|
USHORT Version; // Cabinet version (CAB_VERSION)
|
||||||
USHORT FolderCount; // Number of folders
|
USHORT FolderCount; // Number of folders
|
||||||
USHORT FileCount; // Number of files
|
USHORT FileCount; // Number of files
|
||||||
USHORT Flags; // Cabinet flags (CAB_FLAG_*)
|
USHORT Flags; // Cabinet flags (CAB_FLAG_*)
|
||||||
USHORT SetID; // Cabinet set id
|
USHORT SetID; // Cabinet set id
|
||||||
USHORT CabinetNumber; // Zero-based cabinet number
|
USHORT CabinetNumber; // Zero-based cabinet number
|
||||||
/* Optional fields (depends on Flags)
|
/* Optional fields (depends on Flags)
|
||||||
USHORT CabinetResSize // Per-cabinet reserved area size
|
USHORT CabinetResSize // Per-cabinet reserved area size
|
||||||
char FolderResSize // Per-folder reserved area size
|
char FolderResSize // Per-folder reserved area size
|
||||||
char FileResSize // Per-file reserved area size
|
char FileResSize // Per-file reserved area size
|
||||||
char CabinetReserved[] // Per-cabinet reserved area
|
char CabinetReserved[] // Per-cabinet reserved area
|
||||||
char CabinetPrev[] // Name of previous cabinet file
|
char CabinetPrev[] // Name of previous cabinet file
|
||||||
char DiskPrev[] // Name of previous disk
|
char DiskPrev[] // Name of previous disk
|
||||||
char CabinetNext[] // Name of next cabinet file
|
char CabinetNext[] // Name of next cabinet file
|
||||||
char DiskNext[] // Name of next disk
|
char DiskNext[] // Name of next disk
|
||||||
*/
|
*/
|
||||||
} CFHEADER, *PCFHEADER;
|
} CFHEADER, *PCFHEADER;
|
||||||
|
|
||||||
|
|
||||||
typedef struct _CFFOLDER
|
typedef struct _CFFOLDER
|
||||||
{
|
{
|
||||||
ULONG DataOffset; // Absolute offset of first CFDATA block in this folder
|
ULONG DataOffset; // Absolute offset of first CFDATA block in this folder
|
||||||
USHORT DataBlockCount; // Number of CFDATA blocks in this folder in this cabinet
|
USHORT DataBlockCount; // Number of CFDATA blocks in this folder in this cabinet
|
||||||
USHORT CompressionType; // Type of compression used for all CFDATA blocks in this folder
|
USHORT CompressionType; // Type of compression used for all CFDATA blocks in this folder
|
||||||
/* Optional fields (depends on Flags)
|
/* Optional fields (depends on Flags)
|
||||||
char FolderReserved[] // Per-folder reserved area
|
char FolderReserved[] // Per-folder reserved area
|
||||||
*/
|
*/
|
||||||
} CFFOLDER, *PCFFOLDER;
|
} CFFOLDER, *PCFFOLDER;
|
||||||
|
|
||||||
|
|
||||||
typedef struct _CFFILE
|
typedef struct _CFFILE
|
||||||
{
|
{
|
||||||
ULONG FileSize; // Uncompressed file size in bytes
|
ULONG FileSize; // Uncompressed file size in bytes
|
||||||
ULONG FileOffset; // Uncompressed offset of file in the folder
|
ULONG FileOffset; // Uncompressed offset of file in the folder
|
||||||
USHORT FileControlID; // File control ID (CAB_FILE_*)
|
USHORT FileControlID; // File control ID (CAB_FILE_*)
|
||||||
USHORT FileDate; // File date stamp, as used by DOS
|
USHORT FileDate; // File date stamp, as used by DOS
|
||||||
USHORT FileTime; // File time stamp, as used by DOS
|
USHORT FileTime; // File time stamp, as used by DOS
|
||||||
USHORT Attributes; // File attributes (CAB_ATTRIB_*)
|
USHORT Attributes; // File attributes (CAB_ATTRIB_*)
|
||||||
/* After this is the NULL terminated filename */
|
/* After this is the NULL terminated filename */
|
||||||
} CFFILE, *PCFFILE;
|
} CFFILE, *PCFFILE;
|
||||||
|
|
||||||
|
|
||||||
typedef struct _CFDATA
|
typedef struct _CFDATA
|
||||||
{
|
{
|
||||||
ULONG Checksum; // Checksum of CFDATA entry
|
ULONG Checksum; // Checksum of CFDATA entry
|
||||||
USHORT CompSize; // Number of compressed bytes in this block
|
USHORT CompSize; // Number of compressed bytes in this block
|
||||||
USHORT UncompSize; // Number of uncompressed bytes in this block
|
USHORT UncompSize; // Number of uncompressed bytes in this block
|
||||||
/* Optional fields (depends on Flags)
|
/* Optional fields (depends on Flags)
|
||||||
char DataReserved[] // Per-datablock reserved area
|
char DataReserved[] // Per-datablock reserved area
|
||||||
*/
|
*/
|
||||||
} CFDATA, *PCFDATA;
|
} CFDATA, *PCFDATA;
|
||||||
|
|
||||||
typedef struct _CFDATA_NODE
|
typedef struct _CFDATA_NODE
|
||||||
{
|
{
|
||||||
struct _CFDATA_NODE *Next;
|
struct _CFDATA_NODE *Next;
|
||||||
struct _CFDATA_NODE *Prev;
|
struct _CFDATA_NODE *Prev;
|
||||||
ULONG ScratchFilePosition; // Absolute offset in scratch file
|
ULONG ScratchFilePosition; // Absolute offset in scratch file
|
||||||
ULONG AbsoluteOffset; // Absolute offset in cabinet
|
ULONG AbsoluteOffset; // Absolute offset in cabinet
|
||||||
ULONG UncompOffset; // Uncompressed offset in folder
|
ULONG UncompOffset; // Uncompressed offset in folder
|
||||||
CFDATA Data;
|
CFDATA Data;
|
||||||
} CFDATA_NODE, *PCFDATA_NODE;
|
} CFDATA_NODE, *PCFDATA_NODE;
|
||||||
|
|
||||||
typedef struct _CFFOLDER_NODE
|
typedef struct _CFFOLDER_NODE
|
||||||
{
|
{
|
||||||
struct _CFFOLDER_NODE *Next;
|
struct _CFFOLDER_NODE *Next;
|
||||||
struct _CFFOLDER_NODE *Prev;
|
struct _CFFOLDER_NODE *Prev;
|
||||||
ULONG UncompOffset; // File size accumulator
|
ULONG UncompOffset; // File size accumulator
|
||||||
ULONG AbsoluteOffset;
|
ULONG AbsoluteOffset;
|
||||||
ULONG TotalFolderSize; // Total size of folder in current disk
|
ULONG TotalFolderSize; // Total size of folder in current disk
|
||||||
PCFDATA_NODE DataListHead;
|
PCFDATA_NODE DataListHead;
|
||||||
PCFDATA_NODE DataListTail;
|
PCFDATA_NODE DataListTail;
|
||||||
ULONG Index;
|
ULONG Index;
|
||||||
bool Commit; // true if the folder should be committed
|
bool Commit; // true if the folder should be committed
|
||||||
bool Delete; // true if marked for deletion
|
bool Delete; // true if marked for deletion
|
||||||
CFFOLDER Folder;
|
CFFOLDER Folder;
|
||||||
} CFFOLDER_NODE, *PCFFOLDER_NODE;
|
} CFFOLDER_NODE, *PCFFOLDER_NODE;
|
||||||
|
|
||||||
typedef struct _CFFILE_NODE
|
typedef struct _CFFILE_NODE
|
||||||
{
|
{
|
||||||
struct _CFFILE_NODE *Next;
|
struct _CFFILE_NODE *Next;
|
||||||
struct _CFFILE_NODE *Prev;
|
struct _CFFILE_NODE *Prev;
|
||||||
CFFILE File;
|
CFFILE File;
|
||||||
char* FileName;
|
char* FileName;
|
||||||
PCFDATA_NODE DataBlock; // First data block of file. NULL if not known
|
PCFDATA_NODE DataBlock; // First data block of file. NULL if not known
|
||||||
bool Commit; // true if the file data should be committed
|
bool Commit; // true if the file data should be committed
|
||||||
bool Delete; // true if marked for deletion
|
bool Delete; // true if marked for deletion
|
||||||
PCFFOLDER_NODE FolderNode; // Folder this file belong to
|
PCFFOLDER_NODE FolderNode; // Folder this file belong to
|
||||||
} CFFILE_NODE, *PCFFILE_NODE;
|
} CFFILE_NODE, *PCFFILE_NODE;
|
||||||
|
|
||||||
|
|
||||||
typedef struct _CAB_SEARCH
|
typedef struct _CAB_SEARCH
|
||||||
{
|
{
|
||||||
char Search[MAX_PATH]; // Search criteria
|
char Search[MAX_PATH]; // Search criteria
|
||||||
PCFFILE_NODE Next; // Pointer to next node
|
PCFFILE_NODE Next; // Pointer to next node
|
||||||
PCFFILE File; // Pointer to current CFFILE
|
PCFFILE File; // Pointer to current CFFILE
|
||||||
char* FileName; // Current filename
|
char* FileName; // Current filename
|
||||||
} CAB_SEARCH, *PCAB_SEARCH;
|
} CAB_SEARCH, *PCAB_SEARCH;
|
||||||
|
|
||||||
|
|
||||||
|
@ -249,20 +249,20 @@ typedef struct _CAB_SEARCH
|
||||||
|
|
||||||
class CCABCodec {
|
class CCABCodec {
|
||||||
public:
|
public:
|
||||||
/* Default constructor */
|
/* Default constructor */
|
||||||
CCABCodec() {};
|
CCABCodec() {};
|
||||||
/* Default destructor */
|
/* Default destructor */
|
||||||
virtual ~CCABCodec() {};
|
virtual ~CCABCodec() {};
|
||||||
/* Compresses a data block */
|
/* Compresses a data block */
|
||||||
virtual ULONG Compress(void* OutputBuffer,
|
virtual ULONG Compress(void* OutputBuffer,
|
||||||
void* InputBuffer,
|
void* InputBuffer,
|
||||||
ULONG InputLength,
|
ULONG InputLength,
|
||||||
PULONG OutputLength) = 0;
|
PULONG OutputLength) = 0;
|
||||||
/* Uncompresses a data block */
|
/* Uncompresses a data block */
|
||||||
virtual ULONG Uncompress(void* OutputBuffer,
|
virtual ULONG Uncompress(void* OutputBuffer,
|
||||||
void* InputBuffer,
|
void* InputBuffer,
|
||||||
ULONG InputLength,
|
ULONG InputLength,
|
||||||
PULONG OutputLength) = 0;
|
PULONG OutputLength) = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
@ -285,193 +285,193 @@ public:
|
||||||
|
|
||||||
class CCFDATAStorage {
|
class CCFDATAStorage {
|
||||||
public:
|
public:
|
||||||
/* Default constructor */
|
/* Default constructor */
|
||||||
CCFDATAStorage();
|
CCFDATAStorage();
|
||||||
/* Default destructor */
|
/* Default destructor */
|
||||||
virtual ~CCFDATAStorage();
|
virtual ~CCFDATAStorage();
|
||||||
ULONG Create(char* FileName);
|
ULONG Create(char* FileName);
|
||||||
ULONG Destroy();
|
ULONG Destroy();
|
||||||
ULONG Truncate();
|
ULONG Truncate();
|
||||||
ULONG Position();
|
ULONG Position();
|
||||||
ULONG Seek(LONG Position);
|
ULONG Seek(LONG Position);
|
||||||
ULONG ReadBlock(PCFDATA Data, void* Buffer, PULONG BytesRead);
|
ULONG ReadBlock(PCFDATA Data, void* Buffer, PULONG BytesRead);
|
||||||
ULONG WriteBlock(PCFDATA Data, void* Buffer, PULONG BytesWritten);
|
ULONG WriteBlock(PCFDATA Data, void* Buffer, PULONG BytesWritten);
|
||||||
private:
|
private:
|
||||||
char FullName[MAX_PATH];
|
char FullName[MAX_PATH];
|
||||||
bool FileCreated;
|
bool FileCreated;
|
||||||
FILEHANDLE FileHandle;
|
FILEHANDLE FileHandle;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif /* CAB_READ_ONLY */
|
#endif /* CAB_READ_ONLY */
|
||||||
|
|
||||||
class CCabinet {
|
class CCabinet {
|
||||||
public:
|
public:
|
||||||
/* Default constructor */
|
/* Default constructor */
|
||||||
CCabinet();
|
CCabinet();
|
||||||
/* Default destructor */
|
/* Default destructor */
|
||||||
virtual ~CCabinet();
|
virtual ~CCabinet();
|
||||||
/* Determines if a character is a separator */
|
/* Determines if a character is a separator */
|
||||||
bool IsSeparator(char Char);
|
bool IsSeparator(char Char);
|
||||||
/* Replaces \ or / with the one used be the host environment */
|
/* Replaces \ or / with the one used be the host environment */
|
||||||
char* ConvertPath(char* Path, bool Allocate);
|
char* ConvertPath(char* Path, bool Allocate);
|
||||||
/* Returns a pointer to the filename part of a fully qualified filename */
|
/* Returns a pointer to the filename part of a fully qualified filename */
|
||||||
char* GetFileName(char* Path);
|
char* GetFileName(char* Path);
|
||||||
/* Removes a filename from a fully qualified filename */
|
/* Removes a filename from a fully qualified filename */
|
||||||
void RemoveFileName(char* Path);
|
void RemoveFileName(char* Path);
|
||||||
/* Normalizes a path */
|
/* Normalizes a path */
|
||||||
bool NormalizePath(char* Path, ULONG Length);
|
bool NormalizePath(char* Path, ULONG Length);
|
||||||
/* Returns name of cabinet file */
|
/* Returns name of cabinet file */
|
||||||
char* GetCabinetName();
|
char* GetCabinetName();
|
||||||
/* Sets the name of the cabinet file */
|
/* Sets the name of the cabinet file */
|
||||||
void SetCabinetName(char* FileName);
|
void SetCabinetName(char* FileName);
|
||||||
/* Sets destination path for extracted files */
|
/* Sets destination path for extracted files */
|
||||||
void SetDestinationPath(char* DestinationPath);
|
void SetDestinationPath(char* DestinationPath);
|
||||||
/* Sets cabinet reserved file */
|
/* Sets cabinet reserved file */
|
||||||
bool SetCabinetReservedFile(char* FileName);
|
bool SetCabinetReservedFile(char* FileName);
|
||||||
/* Returns cabinet reserved file */
|
/* Returns cabinet reserved file */
|
||||||
char* GetCabinetReservedFile();
|
char* GetCabinetReservedFile();
|
||||||
/* Returns destination path */
|
/* Returns destination path */
|
||||||
char* GetDestinationPath();
|
char* GetDestinationPath();
|
||||||
/* Returns zero-based current disk number */
|
/* Returns zero-based current disk number */
|
||||||
ULONG GetCurrentDiskNumber();
|
ULONG GetCurrentDiskNumber();
|
||||||
/* Opens the current cabinet file */
|
/* Opens the current cabinet file */
|
||||||
ULONG Open();
|
ULONG Open();
|
||||||
/* Closes the current open cabinet file */
|
/* Closes the current open cabinet file */
|
||||||
void Close();
|
void Close();
|
||||||
/* Locates the first file in the current cabinet file that matches a search criteria */
|
/* Locates the first file in the current cabinet file that matches a search criteria */
|
||||||
ULONG FindFirst(char* FileName, PCAB_SEARCH Search);
|
ULONG FindFirst(char* FileName, PCAB_SEARCH Search);
|
||||||
/* Locates the next file in the current cabinet file */
|
/* Locates the next file in the current cabinet file */
|
||||||
ULONG FindNext(PCAB_SEARCH Search);
|
ULONG FindNext(PCAB_SEARCH Search);
|
||||||
/* Extracts a file from the current cabinet file */
|
/* Extracts a file from the current cabinet file */
|
||||||
ULONG ExtractFile(char* FileName);
|
ULONG ExtractFile(char* FileName);
|
||||||
/* Select codec engine to use */
|
/* Select codec engine to use */
|
||||||
void SelectCodec(ULONG Id);
|
void SelectCodec(ULONG Id);
|
||||||
#ifndef CAB_READ_ONLY
|
#ifndef CAB_READ_ONLY
|
||||||
/* Creates a new cabinet file */
|
/* Creates a new cabinet file */
|
||||||
ULONG NewCabinet();
|
ULONG NewCabinet();
|
||||||
/* Forces a new disk to be created */
|
/* Forces a new disk to be created */
|
||||||
ULONG NewDisk();
|
ULONG NewDisk();
|
||||||
/* Forces a new folder to be created */
|
/* Forces a new folder to be created */
|
||||||
ULONG NewFolder();
|
ULONG NewFolder();
|
||||||
/* Writes a file to scratch storage */
|
/* Writes a file to scratch storage */
|
||||||
ULONG WriteFileToScratchStorage(PCFFILE_NODE FileNode);
|
ULONG WriteFileToScratchStorage(PCFFILE_NODE FileNode);
|
||||||
/* Forces the current disk to be written */
|
/* Forces the current disk to be written */
|
||||||
ULONG WriteDisk(ULONG MoreDisks);
|
ULONG WriteDisk(ULONG MoreDisks);
|
||||||
/* Commits the current disk */
|
/* Commits the current disk */
|
||||||
ULONG CommitDisk(ULONG MoreDisks);
|
ULONG CommitDisk(ULONG MoreDisks);
|
||||||
/* Closes the current disk */
|
/* Closes the current disk */
|
||||||
ULONG CloseDisk();
|
ULONG CloseDisk();
|
||||||
/* Closes the current cabinet */
|
/* Closes the current cabinet */
|
||||||
ULONG CloseCabinet();
|
ULONG CloseCabinet();
|
||||||
/* Adds a file to the current disk */
|
/* Adds a file to the current disk */
|
||||||
ULONG AddFile(char* FileName);
|
ULONG AddFile(char* FileName);
|
||||||
/* Sets the maximum size of the current disk */
|
/* Sets the maximum size of the current disk */
|
||||||
void SetMaxDiskSize(ULONG Size);
|
void SetMaxDiskSize(ULONG Size);
|
||||||
#endif /* CAB_READ_ONLY */
|
#endif /* CAB_READ_ONLY */
|
||||||
|
|
||||||
/* Default event handlers */
|
/* Default event handlers */
|
||||||
|
|
||||||
/* Handler called when a file is about to be overridden */
|
/* Handler called when a file is about to be overridden */
|
||||||
virtual bool OnOverwrite(PCFFILE Entry, char* FileName);
|
virtual bool OnOverwrite(PCFFILE Entry, char* FileName);
|
||||||
/* Handler called when a file is about to be extracted */
|
/* Handler called when a file is about to be extracted */
|
||||||
virtual void OnExtract(PCFFILE Entry, char* FileName);
|
virtual void OnExtract(PCFFILE Entry, char* FileName);
|
||||||
/* Handler called when a new disk is to be processed */
|
/* Handler called when a new disk is to be processed */
|
||||||
virtual void OnDiskChange(char* CabinetName, char* DiskLabel);
|
virtual void OnDiskChange(char* CabinetName, char* DiskLabel);
|
||||||
#ifndef CAB_READ_ONLY
|
#ifndef CAB_READ_ONLY
|
||||||
/* Handler called when a file is about to be added */
|
/* Handler called when a file is about to be added */
|
||||||
virtual void OnAdd(PCFFILE Entry, char* FileName);
|
virtual void OnAdd(PCFFILE Entry, char* FileName);
|
||||||
/* Handler called when a cabinet need a name */
|
/* Handler called when a cabinet need a name */
|
||||||
virtual bool OnCabinetName(ULONG Number, char* Name);
|
virtual bool OnCabinetName(ULONG Number, char* Name);
|
||||||
/* Handler called when a disk needs a label */
|
/* Handler called when a disk needs a label */
|
||||||
virtual bool OnDiskLabel(ULONG Number, char* Label);
|
virtual bool OnDiskLabel(ULONG Number, char* Label);
|
||||||
#endif /* CAB_READ_ONLY */
|
#endif /* CAB_READ_ONLY */
|
||||||
private:
|
private:
|
||||||
PCFFOLDER_NODE LocateFolderNode(ULONG Index);
|
PCFFOLDER_NODE LocateFolderNode(ULONG Index);
|
||||||
ULONG GetAbsoluteOffset(PCFFILE_NODE File);
|
ULONG GetAbsoluteOffset(PCFFILE_NODE File);
|
||||||
ULONG LocateFile(char* FileName, PCFFILE_NODE *File);
|
ULONG LocateFile(char* FileName, PCFFILE_NODE *File);
|
||||||
ULONG ReadString(char* String, ULONG MaxLength);
|
ULONG ReadString(char* String, ULONG MaxLength);
|
||||||
ULONG ReadFileTable();
|
ULONG ReadFileTable();
|
||||||
ULONG ReadDataBlocks(PCFFOLDER_NODE FolderNode);
|
ULONG ReadDataBlocks(PCFFOLDER_NODE FolderNode);
|
||||||
PCFFOLDER_NODE NewFolderNode();
|
PCFFOLDER_NODE NewFolderNode();
|
||||||
PCFFILE_NODE NewFileNode();
|
PCFFILE_NODE NewFileNode();
|
||||||
PCFDATA_NODE NewDataNode(PCFFOLDER_NODE FolderNode);
|
PCFDATA_NODE NewDataNode(PCFFOLDER_NODE FolderNode);
|
||||||
void DestroyDataNodes(PCFFOLDER_NODE FolderNode);
|
void DestroyDataNodes(PCFFOLDER_NODE FolderNode);
|
||||||
void DestroyFileNodes();
|
void DestroyFileNodes();
|
||||||
void DestroyDeletedFileNodes();
|
void DestroyDeletedFileNodes();
|
||||||
void DestroyFolderNodes();
|
void DestroyFolderNodes();
|
||||||
void DestroyDeletedFolderNodes();
|
void DestroyDeletedFolderNodes();
|
||||||
ULONG ComputeChecksum(void* Buffer, ULONG Size, ULONG Seed);
|
ULONG ComputeChecksum(void* Buffer, ULONG Size, ULONG Seed);
|
||||||
ULONG ReadBlock(void* Buffer, ULONG Size, PULONG BytesRead);
|
ULONG ReadBlock(void* Buffer, ULONG Size, PULONG BytesRead);
|
||||||
#ifndef CAB_READ_ONLY
|
#ifndef CAB_READ_ONLY
|
||||||
ULONG InitCabinetHeader();
|
ULONG InitCabinetHeader();
|
||||||
ULONG WriteCabinetHeader(bool MoreDisks);
|
ULONG WriteCabinetHeader(bool MoreDisks);
|
||||||
ULONG WriteFolderEntries();
|
ULONG WriteFolderEntries();
|
||||||
ULONG WriteFileEntries();
|
ULONG WriteFileEntries();
|
||||||
ULONG CommitDataBlocks(PCFFOLDER_NODE FolderNode);
|
ULONG CommitDataBlocks(PCFFOLDER_NODE FolderNode);
|
||||||
ULONG WriteDataBlock();
|
ULONG WriteDataBlock();
|
||||||
ULONG GetAttributesOnFile(PCFFILE_NODE File);
|
ULONG GetAttributesOnFile(PCFFILE_NODE File);
|
||||||
ULONG SetAttributesOnFile(PCFFILE_NODE File);
|
ULONG SetAttributesOnFile(PCFFILE_NODE File);
|
||||||
ULONG GetFileTimes(FILEHANDLE FileHandle, PCFFILE_NODE File);
|
ULONG GetFileTimes(FILEHANDLE FileHandle, PCFFILE_NODE File);
|
||||||
#if !defined(WIN32)
|
#if !defined(WIN32)
|
||||||
void ConvertDateAndTime(time_t* Time, PUSHORT DosDate, PUSHORT DosTime);
|
void ConvertDateAndTime(time_t* Time, PUSHORT DosDate, PUSHORT DosTime);
|
||||||
#endif
|
#endif
|
||||||
#endif /* CAB_READ_ONLY */
|
#endif /* CAB_READ_ONLY */
|
||||||
ULONG CurrentDiskNumber; // Zero based disk number
|
ULONG CurrentDiskNumber; // Zero based disk number
|
||||||
char CabinetName[256]; // Filename of current cabinet
|
char CabinetName[256]; // Filename of current cabinet
|
||||||
char CabinetPrev[256]; // Filename of previous cabinet
|
char CabinetPrev[256]; // Filename of previous cabinet
|
||||||
char DiskPrev[256]; // Label of cabinet in file CabinetPrev
|
char DiskPrev[256]; // Label of cabinet in file CabinetPrev
|
||||||
char CabinetNext[256]; // Filename of next cabinet
|
char CabinetNext[256]; // Filename of next cabinet
|
||||||
char DiskNext[256]; // Label of cabinet in file CabinetNext
|
char DiskNext[256]; // Label of cabinet in file CabinetNext
|
||||||
ULONG TotalHeaderSize; // Size of header and optional fields
|
ULONG TotalHeaderSize; // Size of header and optional fields
|
||||||
ULONG NextFieldsSize; // Size of next cabinet name and next disk label
|
ULONG NextFieldsSize; // Size of next cabinet name and next disk label
|
||||||
ULONG TotalFolderSize; // Size of all folder entries
|
ULONG TotalFolderSize; // Size of all folder entries
|
||||||
ULONG TotalFileSize; // Size of all file entries
|
ULONG TotalFileSize; // Size of all file entries
|
||||||
ULONG FolderUncompSize; // Uncompressed size of folder
|
ULONG FolderUncompSize; // Uncompressed size of folder
|
||||||
ULONG BytesLeftInBlock; // Number of bytes left in current block
|
ULONG BytesLeftInBlock; // Number of bytes left in current block
|
||||||
bool ReuseBlock;
|
bool ReuseBlock;
|
||||||
char DestPath[MAX_PATH];
|
char DestPath[MAX_PATH];
|
||||||
char CabinetReservedFile[MAX_PATH];
|
char CabinetReservedFile[MAX_PATH];
|
||||||
void* CabinetReservedFileBuffer;
|
void* CabinetReservedFileBuffer;
|
||||||
ULONG CabinetReservedFileSize;
|
ULONG CabinetReservedFileSize;
|
||||||
FILEHANDLE FileHandle;
|
FILEHANDLE FileHandle;
|
||||||
bool FileOpen;
|
bool FileOpen;
|
||||||
CFHEADER CABHeader;
|
CFHEADER CABHeader;
|
||||||
ULONG CabinetReserved;
|
ULONG CabinetReserved;
|
||||||
ULONG FolderReserved;
|
ULONG FolderReserved;
|
||||||
ULONG DataReserved;
|
ULONG DataReserved;
|
||||||
PCFFOLDER_NODE FolderListHead;
|
PCFFOLDER_NODE FolderListHead;
|
||||||
PCFFOLDER_NODE FolderListTail;
|
PCFFOLDER_NODE FolderListTail;
|
||||||
PCFFOLDER_NODE CurrentFolderNode;
|
PCFFOLDER_NODE CurrentFolderNode;
|
||||||
PCFDATA_NODE CurrentDataNode;
|
PCFDATA_NODE CurrentDataNode;
|
||||||
PCFFILE_NODE FileListHead;
|
PCFFILE_NODE FileListHead;
|
||||||
PCFFILE_NODE FileListTail;
|
PCFFILE_NODE FileListTail;
|
||||||
CCABCodec *Codec;
|
CCABCodec *Codec;
|
||||||
ULONG CodecId;
|
ULONG CodecId;
|
||||||
bool CodecSelected;
|
bool CodecSelected;
|
||||||
void* InputBuffer;
|
void* InputBuffer;
|
||||||
void* CurrentIBuffer; // Current offset in input buffer
|
void* CurrentIBuffer; // Current offset in input buffer
|
||||||
ULONG CurrentIBufferSize; // Bytes left in input buffer
|
ULONG CurrentIBufferSize; // Bytes left in input buffer
|
||||||
void* OutputBuffer;
|
void* OutputBuffer;
|
||||||
ULONG TotalCompSize; // Total size of current CFDATA block
|
ULONG TotalCompSize; // Total size of current CFDATA block
|
||||||
void* CurrentOBuffer; // Current offset in output buffer
|
void* CurrentOBuffer; // Current offset in output buffer
|
||||||
ULONG CurrentOBufferSize; // Bytes left in output buffer
|
ULONG CurrentOBufferSize; // Bytes left in output buffer
|
||||||
ULONG BytesLeftInCabinet;
|
ULONG BytesLeftInCabinet;
|
||||||
bool RestartSearch;
|
bool RestartSearch;
|
||||||
ULONG LastFileOffset; // Uncompressed offset of last extracted file
|
ULONG LastFileOffset; // Uncompressed offset of last extracted file
|
||||||
#ifndef CAB_READ_ONLY
|
#ifndef CAB_READ_ONLY
|
||||||
ULONG LastBlockStart; // Uncompressed offset of last block in folder
|
ULONG LastBlockStart; // Uncompressed offset of last block in folder
|
||||||
ULONG MaxDiskSize;
|
ULONG MaxDiskSize;
|
||||||
ULONG DiskSize;
|
ULONG DiskSize;
|
||||||
ULONG PrevCabinetNumber; // Previous cabinet number (where split file starts)
|
ULONG PrevCabinetNumber; // Previous cabinet number (where split file starts)
|
||||||
bool CreateNewDisk;
|
bool CreateNewDisk;
|
||||||
bool CreateNewFolder;
|
bool CreateNewFolder;
|
||||||
|
|
||||||
CCFDATAStorage *ScratchFile;
|
CCFDATAStorage *ScratchFile;
|
||||||
FILEHANDLE SourceFile;
|
FILEHANDLE SourceFile;
|
||||||
bool ContinueFile;
|
bool ContinueFile;
|
||||||
ULONG TotalBytesLeft;
|
ULONG TotalBytesLeft;
|
||||||
bool BlockIsSplit; // true if current data block is split
|
bool BlockIsSplit; // true if current data block is split
|
||||||
ULONG NextFolderNumber; // Zero based folder number
|
ULONG NextFolderNumber; // Zero based folder number
|
||||||
#endif /* CAB_READ_ONLY */
|
#endif /* CAB_READ_ONLY */
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -20,27 +20,27 @@
|
||||||
|
|
||||||
class CCABManager : public CDFParser {
|
class CCABManager : public CDFParser {
|
||||||
public:
|
public:
|
||||||
CCABManager();
|
CCABManager();
|
||||||
virtual ~CCABManager();
|
virtual ~CCABManager();
|
||||||
bool ParseCmdline(int argc, char* argv[]);
|
bool ParseCmdline(int argc, char* argv[]);
|
||||||
bool Run();
|
bool Run();
|
||||||
private:
|
private:
|
||||||
void Usage();
|
void Usage();
|
||||||
bool CreateCabinet();
|
bool CreateCabinet();
|
||||||
bool CreateSimpleCabinet();
|
bool CreateSimpleCabinet();
|
||||||
bool DisplayCabinet();
|
bool DisplayCabinet();
|
||||||
bool ExtractFromCabinet();
|
bool ExtractFromCabinet();
|
||||||
/* Event handlers */
|
/* Event handlers */
|
||||||
virtual bool OnOverwrite(PCFFILE File, char* FileName);
|
virtual bool OnOverwrite(PCFFILE File, char* FileName);
|
||||||
virtual void OnExtract(PCFFILE File, char* FileName);
|
virtual void OnExtract(PCFFILE File, char* FileName);
|
||||||
virtual void OnDiskChange(char* CabinetName, char* DiskLabel);
|
virtual void OnDiskChange(char* CabinetName, char* DiskLabel);
|
||||||
virtual void OnAdd(PCFFILE Entry, char* FileName);
|
virtual void OnAdd(PCFFILE Entry, char* FileName);
|
||||||
/* Configuration */
|
/* Configuration */
|
||||||
bool ProcessAll;
|
bool ProcessAll;
|
||||||
ULONG Mode;
|
ULONG Mode;
|
||||||
bool PromptOnOverwrite;
|
bool PromptOnOverwrite;
|
||||||
char Location[MAX_PATH];
|
char Location[MAX_PATH];
|
||||||
char FileName[MAX_PATH];
|
char FileName[MAX_PATH];
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif /* __CABMAN_H */
|
#endif /* __CABMAN_H */
|
||||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -10,45 +10,45 @@
|
||||||
#include "cabinet.h"
|
#include "cabinet.h"
|
||||||
|
|
||||||
typedef struct _CABINET_NAME {
|
typedef struct _CABINET_NAME {
|
||||||
struct _CABINET_NAME *Next;
|
struct _CABINET_NAME *Next;
|
||||||
ULONG DiskNumber;
|
ULONG DiskNumber;
|
||||||
char Name[128];
|
char Name[128];
|
||||||
} CABINET_NAME, *PCABINET_NAME;
|
} CABINET_NAME, *PCABINET_NAME;
|
||||||
|
|
||||||
typedef struct _DISK_NUMBER {
|
typedef struct _DISK_NUMBER {
|
||||||
struct _DISK_NUMBER *Next;
|
struct _DISK_NUMBER *Next;
|
||||||
ULONG DiskNumber;
|
ULONG DiskNumber;
|
||||||
ULONG Number;
|
ULONG Number;
|
||||||
} DISK_NUMBER, *PDISK_NUMBER;
|
} DISK_NUMBER, *PDISK_NUMBER;
|
||||||
|
|
||||||
typedef enum {
|
typedef enum {
|
||||||
TokenUnknown,
|
TokenUnknown,
|
||||||
TokenInteger,
|
TokenInteger,
|
||||||
TokenIdentifier,
|
TokenIdentifier,
|
||||||
TokenString,
|
TokenString,
|
||||||
TokenSpace,
|
TokenSpace,
|
||||||
TokenSemi,
|
TokenSemi,
|
||||||
TokenEqual,
|
TokenEqual,
|
||||||
TokenPeriod,
|
TokenPeriod,
|
||||||
TokenBackslash,
|
TokenBackslash,
|
||||||
TokenEnd,
|
TokenEnd,
|
||||||
} DFP_TOKEN;
|
} DFP_TOKEN;
|
||||||
|
|
||||||
|
|
||||||
typedef enum {
|
typedef enum {
|
||||||
stCabinetName,
|
stCabinetName,
|
||||||
stCabinetNameTemplate,
|
stCabinetNameTemplate,
|
||||||
stDiskLabel,
|
stDiskLabel,
|
||||||
stDiskLabelTemplate,
|
stDiskLabelTemplate,
|
||||||
stMaxDiskSize,
|
stMaxDiskSize,
|
||||||
stInfFileName
|
stInfFileName
|
||||||
} SETTYPE;
|
} SETTYPE;
|
||||||
|
|
||||||
|
|
||||||
typedef enum {
|
typedef enum {
|
||||||
ntDisk,
|
ntDisk,
|
||||||
ntCabinet,
|
ntCabinet,
|
||||||
ntFolder,
|
ntFolder,
|
||||||
} NEWTYPE;
|
} NEWTYPE;
|
||||||
|
|
||||||
|
|
||||||
|
@ -56,86 +56,86 @@ typedef enum {
|
||||||
|
|
||||||
class CDFParser : public CCabinet {
|
class CDFParser : public CCabinet {
|
||||||
public:
|
public:
|
||||||
CDFParser();
|
CDFParser();
|
||||||
virtual ~CDFParser();
|
virtual ~CDFParser();
|
||||||
ULONG Load(char* FileName);
|
ULONG Load(char* FileName);
|
||||||
ULONG Parse();
|
ULONG Parse();
|
||||||
void SetFileRelativePath(char* Path);
|
void SetFileRelativePath(char* Path);
|
||||||
bool InfFileOnly;
|
bool InfFileOnly;
|
||||||
bool DontGenerateInf;
|
bool DontGenerateInf;
|
||||||
char FileRelativePath[300];
|
char FileRelativePath[300];
|
||||||
private:
|
private:
|
||||||
/* Event handlers */
|
/* Event handlers */
|
||||||
virtual bool OnDiskLabel(ULONG Number, char* Label);
|
virtual bool OnDiskLabel(ULONG Number, char* Label);
|
||||||
virtual bool OnCabinetName(ULONG Number, char* Name);
|
virtual bool OnCabinetName(ULONG Number, char* Name);
|
||||||
|
|
||||||
void WriteInfLine(char* InfLine);
|
void WriteInfLine(char* InfLine);
|
||||||
bool SetDiskName(PCABINET_NAME *List, ULONG Number, char* String);
|
bool SetDiskName(PCABINET_NAME *List, ULONG Number, char* String);
|
||||||
bool GetDiskName(PCABINET_NAME *List, ULONG Number, char* String);
|
bool GetDiskName(PCABINET_NAME *List, ULONG Number, char* String);
|
||||||
bool SetDiskNumber(PDISK_NUMBER *List, ULONG Number, ULONG Value);
|
bool SetDiskNumber(PDISK_NUMBER *List, ULONG Number, ULONG Value);
|
||||||
bool GetDiskNumber(PDISK_NUMBER *List, ULONG Number, PULONG Value);
|
bool GetDiskNumber(PDISK_NUMBER *List, ULONG Number, PULONG Value);
|
||||||
bool DoDiskLabel(ULONG Number, char* Label);
|
bool DoDiskLabel(ULONG Number, char* Label);
|
||||||
void DoDiskLabelTemplate(char* Template);
|
void DoDiskLabelTemplate(char* Template);
|
||||||
bool DoCabinetName(ULONG Number, char* Name);
|
bool DoCabinetName(ULONG Number, char* Name);
|
||||||
void DoCabinetNameTemplate(char* Template);
|
void DoCabinetNameTemplate(char* Template);
|
||||||
void DoInfFileName(char* InfFileName);
|
void DoInfFileName(char* InfFileName);
|
||||||
ULONG DoMaxDiskSize(bool NumberValid, ULONG Number);
|
ULONG DoMaxDiskSize(bool NumberValid, ULONG Number);
|
||||||
ULONG SetupNewDisk();
|
ULONG SetupNewDisk();
|
||||||
ULONG PerformSetCommand();
|
ULONG PerformSetCommand();
|
||||||
ULONG PerformNewCommand();
|
ULONG PerformNewCommand();
|
||||||
ULONG PerformInfBeginCommand();
|
ULONG PerformInfBeginCommand();
|
||||||
ULONG PerformInfEndCommand();
|
ULONG PerformInfEndCommand();
|
||||||
ULONG PerformCommand();
|
ULONG PerformCommand();
|
||||||
ULONG PerformFileCopy();
|
ULONG PerformFileCopy();
|
||||||
void SkipSpaces();
|
void SkipSpaces();
|
||||||
bool IsNextToken(DFP_TOKEN Token, bool NoSpaces);
|
bool IsNextToken(DFP_TOKEN Token, bool NoSpaces);
|
||||||
bool ReadLine();
|
bool ReadLine();
|
||||||
void NextToken();
|
void NextToken();
|
||||||
/* Parsing */
|
/* Parsing */
|
||||||
bool FileLoaded;
|
bool FileLoaded;
|
||||||
FILEHANDLE FileHandle;
|
FILEHANDLE FileHandle;
|
||||||
char* FileBuffer;
|
char* FileBuffer;
|
||||||
ULONG FileBufferSize;
|
ULONG FileBufferSize;
|
||||||
ULONG CurrentOffset;
|
ULONG CurrentOffset;
|
||||||
char Line[128];
|
char Line[128];
|
||||||
ULONG LineLength;
|
ULONG LineLength;
|
||||||
ULONG CurrentLine;
|
ULONG CurrentLine;
|
||||||
ULONG CurrentChar;
|
ULONG CurrentChar;
|
||||||
/* Token */
|
/* Token */
|
||||||
DFP_TOKEN CurrentToken;
|
DFP_TOKEN CurrentToken;
|
||||||
ULONG CurrentInteger;
|
ULONG CurrentInteger;
|
||||||
char CurrentString[256];
|
char CurrentString[256];
|
||||||
|
|
||||||
/* State */
|
/* State */
|
||||||
bool CabinetCreated;
|
bool CabinetCreated;
|
||||||
bool DiskCreated;
|
bool DiskCreated;
|
||||||
bool FolderCreated;
|
bool FolderCreated;
|
||||||
/* Standard directive variable */
|
/* Standard directive variable */
|
||||||
bool Cabinet;
|
bool Cabinet;
|
||||||
ULONG CabinetFileCountThreshold;
|
ULONG CabinetFileCountThreshold;
|
||||||
PCABINET_NAME CabinetName;
|
PCABINET_NAME CabinetName;
|
||||||
bool CabinetNameTemplateSet;
|
bool CabinetNameTemplateSet;
|
||||||
char CabinetNameTemplate[128];
|
char CabinetNameTemplate[128];
|
||||||
bool InfFileNameSet;
|
bool InfFileNameSet;
|
||||||
char InfFileName[256];
|
char InfFileName[256];
|
||||||
bool Compress;
|
bool Compress;
|
||||||
ULONG CompressionType;
|
ULONG CompressionType;
|
||||||
PCABINET_NAME DiskLabel;
|
PCABINET_NAME DiskLabel;
|
||||||
bool DiskLabelTemplateSet;
|
bool DiskLabelTemplateSet;
|
||||||
char DiskLabelTemplate[128];
|
char DiskLabelTemplate[128];
|
||||||
ULONG FolderFileCountThreshold;
|
ULONG FolderFileCountThreshold;
|
||||||
ULONG FolderSizeThreshold;
|
ULONG FolderSizeThreshold;
|
||||||
ULONG MaxCabinetSize;
|
ULONG MaxCabinetSize;
|
||||||
ULONG MaxDiskFileCount;
|
ULONG MaxDiskFileCount;
|
||||||
PDISK_NUMBER MaxDiskSize;
|
PDISK_NUMBER MaxDiskSize;
|
||||||
bool MaxDiskSizeAllSet;
|
bool MaxDiskSizeAllSet;
|
||||||
ULONG MaxDiskSizeAll;
|
ULONG MaxDiskSizeAll;
|
||||||
ULONG ReservePerCabinetSize;
|
ULONG ReservePerCabinetSize;
|
||||||
ULONG ReservePerDataBlockSize;
|
ULONG ReservePerDataBlockSize;
|
||||||
ULONG ReservePerFolderSize;
|
ULONG ReservePerFolderSize;
|
||||||
char SourceDir[256];
|
char SourceDir[256];
|
||||||
FILEHANDLE InfFileHandle;
|
FILEHANDLE InfFileHandle;
|
||||||
bool InfModeEnabled;
|
bool InfModeEnabled;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif /* __DFP_H */
|
#endif /* __DFP_H */
|
||||||
|
|
|
@ -8,9 +8,7 @@
|
||||||
* REVISIONS:
|
* REVISIONS:
|
||||||
* CSH 21/03-2001 Created
|
* CSH 21/03-2001 Created
|
||||||
* CSH 15/08-2003 Made it portable
|
* CSH 15/08-2003 Made it portable
|
||||||
* CF 04/05-2007 Reformatted the code to be more consistent and use TABs instead of spaces
|
|
||||||
* CF 04/05-2007 Made it compatible with 64-bit operating systems
|
* CF 04/05-2007 Made it compatible with 64-bit operating systems
|
||||||
* CF 18/08-2007 Use typedefs64.h and the Windows types for compatibility with 64-bit operating systems
|
|
||||||
*/
|
*/
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <stdarg.h>
|
#include <stdarg.h>
|
||||||
|
@ -44,16 +42,16 @@ char* Pad(char* Str, char PadChar, ULONG Length)
|
||||||
* Str must be at least Length + 1 bytes
|
* Str must be at least Length + 1 bytes
|
||||||
*/
|
*/
|
||||||
{
|
{
|
||||||
ULONG Len;
|
ULONG Len;
|
||||||
|
|
||||||
Len = (ULONG)strlen(Str);
|
Len = (ULONG)strlen(Str);
|
||||||
|
|
||||||
if (Len < Length)
|
if (Len < Length)
|
||||||
{
|
{
|
||||||
memcpy(&Str[Length - Len], Str, Len + 1);
|
memcpy(&Str[Length - Len], Str, Len + 1);
|
||||||
memset(Str, PadChar, Length - Len);
|
memset(Str, PadChar, Length - Len);
|
||||||
}
|
}
|
||||||
return Str;
|
return Str;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -67,24 +65,24 @@ char* Date2Str(char* Str, USHORT Date)
|
||||||
* Pointer to string
|
* Pointer to string
|
||||||
*/
|
*/
|
||||||
{
|
{
|
||||||
ULONG dw;
|
ULONG dw;
|
||||||
|
|
||||||
/* Month */
|
/* Month */
|
||||||
Str[0] = (char)('0' + ((Date & 0x01E0) >> 5) / 10);
|
Str[0] = (char)('0' + ((Date & 0x01E0) >> 5) / 10);
|
||||||
Str[1] = (char)('0' + ((Date & 0x01E0) >> 5) % 10);
|
Str[1] = (char)('0' + ((Date & 0x01E0) >> 5) % 10);
|
||||||
Str[2] = '-';
|
Str[2] = '-';
|
||||||
/* Day */
|
/* Day */
|
||||||
Str[3] = (char)('0' + (Date & 0x001F) / 10);
|
Str[3] = (char)('0' + (Date & 0x001F) / 10);
|
||||||
Str[4] = (char)('0' + (Date & 0x001F) % 10);
|
Str[4] = (char)('0' + (Date & 0x001F) % 10);
|
||||||
Str[5] = '-';
|
Str[5] = '-';
|
||||||
/* Year */
|
/* Year */
|
||||||
dw = 1980 + ((Date & 0xFE00) >> 9);
|
dw = 1980 + ((Date & 0xFE00) >> 9);
|
||||||
Str[6] = (char)('0' + dw / 1000); dw %= 1000;
|
Str[6] = (char)('0' + dw / 1000); dw %= 1000;
|
||||||
Str[7] = (char)('0' + dw / 100); dw %= 100;
|
Str[7] = (char)('0' + dw / 100); dw %= 100;
|
||||||
Str[8] = (char)('0' + dw / 10); dw %= 10;
|
Str[8] = (char)('0' + dw / 10); dw %= 10;
|
||||||
Str[9] = (char)('0' + dw % 10);
|
Str[9] = (char)('0' + dw % 10);
|
||||||
Str[10] = '\0';
|
Str[10] = '\0';
|
||||||
return Str;
|
return Str;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -98,33 +96,33 @@ char* Time2Str(char* Str, USHORT Time)
|
||||||
* Pointer to string
|
* Pointer to string
|
||||||
*/
|
*/
|
||||||
{
|
{
|
||||||
bool PM;
|
bool PM;
|
||||||
ULONG Hour;
|
ULONG Hour;
|
||||||
ULONG dw;
|
ULONG dw;
|
||||||
|
|
||||||
Hour = ((Time & 0xF800) >> 11);
|
Hour = ((Time & 0xF800) >> 11);
|
||||||
PM = (Hour >= 12);
|
PM = (Hour >= 12);
|
||||||
Hour %= 12;
|
Hour %= 12;
|
||||||
if (Hour == 0)
|
if (Hour == 0)
|
||||||
Hour = 12;
|
Hour = 12;
|
||||||
|
|
||||||
if (Hour >= 10)
|
if (Hour >= 10)
|
||||||
Str[0] = (char)('0' + Hour / 10);
|
Str[0] = (char)('0' + Hour / 10);
|
||||||
else Str[0] = ' ';
|
else Str[0] = ' ';
|
||||||
Str[1] = (char)('0' + Hour % 10);
|
Str[1] = (char)('0' + Hour % 10);
|
||||||
Str[2] = ':';
|
Str[2] = ':';
|
||||||
/* Minute */
|
/* Minute */
|
||||||
Str[3] = (char)('0' + ((Time & 0x07E0) >> 5) / 10);
|
Str[3] = (char)('0' + ((Time & 0x07E0) >> 5) / 10);
|
||||||
Str[4] = (char)('0' + ((Time & 0x07E0) >> 5) % 10);
|
Str[4] = (char)('0' + ((Time & 0x07E0) >> 5) % 10);
|
||||||
Str[5] = ':';
|
Str[5] = ':';
|
||||||
/* Second */
|
/* Second */
|
||||||
dw = 2 * (Time & 0x001F);
|
dw = 2 * (Time & 0x001F);
|
||||||
Str[6] = (char)('0' + dw / 10);
|
Str[6] = (char)('0' + dw / 10);
|
||||||
Str[7] = (char)('0' + dw % 10);
|
Str[7] = (char)('0' + dw % 10);
|
||||||
|
|
||||||
Str[8] = PM? 'p' : 'a';
|
Str[8] = PM? 'p' : 'a';
|
||||||
Str[9] = '\0';
|
Str[9] = '\0';
|
||||||
return Str;
|
return Str;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -138,32 +136,32 @@ char* Attr2Str(char* Str, USHORT Attr)
|
||||||
* Pointer to string
|
* Pointer to string
|
||||||
*/
|
*/
|
||||||
{
|
{
|
||||||
/* Archive */
|
/* Archive */
|
||||||
if (Attr & CAB_ATTRIB_ARCHIVE)
|
if (Attr & CAB_ATTRIB_ARCHIVE)
|
||||||
Str[0] = 'A';
|
Str[0] = 'A';
|
||||||
else
|
else
|
||||||
Str[0] = '-';
|
Str[0] = '-';
|
||||||
|
|
||||||
/* Hidden */
|
/* Hidden */
|
||||||
if (Attr & CAB_ATTRIB_HIDDEN)
|
if (Attr & CAB_ATTRIB_HIDDEN)
|
||||||
Str[1] = 'H';
|
Str[1] = 'H';
|
||||||
else
|
else
|
||||||
Str[1] = '-';
|
Str[1] = '-';
|
||||||
|
|
||||||
/* Read only */
|
/* Read only */
|
||||||
if (Attr & CAB_ATTRIB_READONLY)
|
if (Attr & CAB_ATTRIB_READONLY)
|
||||||
Str[2] = 'R';
|
Str[2] = 'R';
|
||||||
else
|
else
|
||||||
Str[2] = '-';
|
Str[2] = '-';
|
||||||
|
|
||||||
/* System */
|
/* System */
|
||||||
if (Attr & CAB_ATTRIB_SYSTEM)
|
if (Attr & CAB_ATTRIB_SYSTEM)
|
||||||
Str[3] = 'S';
|
Str[3] = 'S';
|
||||||
else
|
else
|
||||||
Str[3] = '-';
|
Str[3] = '-';
|
||||||
|
|
||||||
Str[4] = '\0';
|
Str[4] = '\0';
|
||||||
return Str;
|
return Str;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -174,9 +172,9 @@ CCABManager::CCABManager()
|
||||||
* FUNCTION: Default constructor
|
* FUNCTION: Default constructor
|
||||||
*/
|
*/
|
||||||
{
|
{
|
||||||
ProcessAll = false;
|
ProcessAll = false;
|
||||||
InfFileOnly = false;
|
InfFileOnly = false;
|
||||||
Mode = CM_MODE_DISPLAY;
|
Mode = CM_MODE_DISPLAY;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -193,30 +191,30 @@ void CCABManager::Usage()
|
||||||
* FUNCTION: Display usage information on screen
|
* FUNCTION: Display usage information on screen
|
||||||
*/
|
*/
|
||||||
{
|
{
|
||||||
printf("ReactOS Cabinet Manager - Version %s\n\n", CM_VERSION);
|
printf("ReactOS Cabinet Manager - Version %s\n\n", CM_VERSION);
|
||||||
printf("CABMAN [-D | -E] [-A] [-L dir] cabinet [filename ...]\n");
|
printf("CABMAN [-D | -E] [-A] [-L dir] cabinet [filename ...]\n");
|
||||||
printf("CABMAN -C dirfile [-I] [-RC file] [-P dir]\n");
|
printf("CABMAN -C dirfile [-I] [-RC file] [-P dir]\n");
|
||||||
printf("CABMAN -S cabinet filename\n");
|
printf("CABMAN -S cabinet filename\n");
|
||||||
printf(" cabinet Cabinet file.\n");
|
printf(" cabinet Cabinet file.\n");
|
||||||
printf(" filename Name of the file to extract from the cabinet.\n");
|
printf(" filename Name of the file to extract from the cabinet.\n");
|
||||||
printf(" Wild cards and multiple filenames\n");
|
printf(" Wild cards and multiple filenames\n");
|
||||||
printf(" (separated by blanks) may be used.\n\n");
|
printf(" (separated by blanks) may be used.\n\n");
|
||||||
|
|
||||||
printf(" dirfile Name of the directive file to use.\n");
|
printf(" dirfile Name of the directive file to use.\n");
|
||||||
|
|
||||||
printf(" -A Process ALL cabinets. Follows cabinet chain\n");
|
printf(" -A Process ALL cabinets. Follows cabinet chain\n");
|
||||||
printf(" starting in first cabinet mentioned.\n");
|
printf(" starting in first cabinet mentioned.\n");
|
||||||
printf(" -C Create cabinet.\n");
|
printf(" -C Create cabinet.\n");
|
||||||
printf(" -D Display cabinet directory.\n");
|
printf(" -D Display cabinet directory.\n");
|
||||||
printf(" -E Extract files from cabinet.\n");
|
printf(" -E Extract files from cabinet.\n");
|
||||||
printf(" -I Don't create the cabinet, only the .inf file.\n");
|
printf(" -I Don't create the cabinet, only the .inf file.\n");
|
||||||
printf(" -L dir Location to place extracted or generated files\n");
|
printf(" -L dir Location to place extracted or generated files\n");
|
||||||
printf(" (default is current directory).\n");
|
printf(" (default is current directory).\n");
|
||||||
printf(" -N Don't create the .inf file, only the cabinet.\n");
|
printf(" -N Don't create the .inf file, only the cabinet.\n");
|
||||||
printf(" -RC Specify file to put in cabinet reserved area\n");
|
printf(" -RC Specify file to put in cabinet reserved area\n");
|
||||||
printf(" (size must be less than 64KB).\n");
|
printf(" (size must be less than 64KB).\n");
|
||||||
printf(" -S Create simple cabinet.\n");
|
printf(" -S Create simple cabinet.\n");
|
||||||
printf(" -P dir Files in the .dff are relative to this directory\n");
|
printf(" -P dir Files in the .dff are relative to this directory\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CCABManager::ParseCmdline(int argc, char* argv[])
|
bool CCABManager::ParseCmdline(int argc, char* argv[])
|
||||||
|
@ -229,135 +227,135 @@ bool CCABManager::ParseCmdline(int argc, char* argv[])
|
||||||
* true if command line arguments was successfully parsed, false if not
|
* true if command line arguments was successfully parsed, false if not
|
||||||
*/
|
*/
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
bool ShowUsage;
|
bool ShowUsage;
|
||||||
bool FoundCabinet = false;
|
bool FoundCabinet = false;
|
||||||
|
|
||||||
ShowUsage = (argc < 2);
|
ShowUsage = (argc < 2);
|
||||||
|
|
||||||
for (i = 1; i < argc; i++)
|
for (i = 1; i < argc; i++)
|
||||||
{
|
{
|
||||||
if (argv[i][0] == '-')
|
if (argv[i][0] == '-')
|
||||||
{
|
{
|
||||||
switch (argv[i][1])
|
switch (argv[i][1])
|
||||||
{
|
{
|
||||||
case 'a':
|
case 'a':
|
||||||
case 'A':
|
case 'A':
|
||||||
ProcessAll = true;
|
ProcessAll = true;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'c':
|
case 'c':
|
||||||
case 'C':
|
case 'C':
|
||||||
Mode = CM_MODE_CREATE;
|
Mode = CM_MODE_CREATE;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'd':
|
case 'd':
|
||||||
case 'D':
|
case 'D':
|
||||||
Mode = CM_MODE_DISPLAY;
|
Mode = CM_MODE_DISPLAY;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'e':
|
case 'e':
|
||||||
case 'E':
|
case 'E':
|
||||||
Mode = CM_MODE_EXTRACT;
|
Mode = CM_MODE_EXTRACT;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'i':
|
case 'i':
|
||||||
case 'I':
|
case 'I':
|
||||||
InfFileOnly = true;
|
InfFileOnly = true;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'l':
|
case 'l':
|
||||||
case 'L':
|
case 'L':
|
||||||
if (argv[i][2] == 0)
|
if (argv[i][2] == 0)
|
||||||
{
|
{
|
||||||
i++;
|
i++;
|
||||||
SetDestinationPath((char*)&argv[i][0]);
|
SetDestinationPath((char*)&argv[i][0]);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
SetDestinationPath((char*)&argv[i][1]);
|
SetDestinationPath((char*)&argv[i][1]);
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'n':
|
case 'n':
|
||||||
case 'N':
|
case 'N':
|
||||||
DontGenerateInf = true;
|
DontGenerateInf = true;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'R':
|
case 'R':
|
||||||
switch (argv[i][2])
|
switch (argv[i][2])
|
||||||
{
|
{
|
||||||
case 'C': /* File to put in cabinet reserved area */
|
case 'C': /* File to put in cabinet reserved area */
|
||||||
if (argv[i][3] == 0)
|
if (argv[i][3] == 0)
|
||||||
{
|
{
|
||||||
i++;
|
i++;
|
||||||
if (!SetCabinetReservedFile((char*)&argv[i][0]))
|
if (!SetCabinetReservedFile((char*)&argv[i][0]))
|
||||||
{
|
{
|
||||||
printf("Cannot open cabinet reserved area file.\n");
|
printf("Cannot open cabinet reserved area file.\n");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (!SetCabinetReservedFile((char*)&argv[i][3]))
|
if (!SetCabinetReservedFile((char*)&argv[i][3]))
|
||||||
{
|
{
|
||||||
printf("Cannot open cabinet reserved area file.\n");
|
printf("Cannot open cabinet reserved area file.\n");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
printf("Bad parameter %s.\n", argv[i]);
|
printf("Bad parameter %s.\n", argv[i]);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 's':
|
case 's':
|
||||||
case 'S':
|
case 'S':
|
||||||
Mode = CM_MODE_CREATE_SIMPLE;
|
Mode = CM_MODE_CREATE_SIMPLE;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'P':
|
case 'P':
|
||||||
if (argv[i][2] == 0)
|
if (argv[i][2] == 0)
|
||||||
{
|
{
|
||||||
i++;
|
i++;
|
||||||
SetFileRelativePath((char*)&argv[i][0]);
|
SetFileRelativePath((char*)&argv[i][0]);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
SetFileRelativePath((char*)&argv[i][1]);
|
SetFileRelativePath((char*)&argv[i][1]);
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
printf("Bad parameter %s.\n", argv[i]);
|
printf("Bad parameter %s.\n", argv[i]);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if ((FoundCabinet) || (Mode == CM_MODE_CREATE))
|
if ((FoundCabinet) || (Mode == CM_MODE_CREATE))
|
||||||
{
|
{
|
||||||
/* FIXME: There may be many of these if Mode != CM_MODE_CREATE */
|
/* FIXME: There may be many of these if Mode != CM_MODE_CREATE */
|
||||||
strcpy((char*)FileName, argv[i]);
|
strcpy((char*)FileName, argv[i]);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
SetCabinetName(argv[i]);
|
SetCabinetName(argv[i]);
|
||||||
FoundCabinet = true;
|
FoundCabinet = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ShowUsage)
|
if (ShowUsage)
|
||||||
{
|
{
|
||||||
Usage();
|
Usage();
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* FIXME */
|
/* FIXME */
|
||||||
SelectCodec(CAB_CODEC_MSZIP);
|
SelectCodec(CAB_CODEC_MSZIP);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -366,18 +364,18 @@ bool CCABManager::CreateCabinet()
|
||||||
* FUNCTION: Create cabinet
|
* FUNCTION: Create cabinet
|
||||||
*/
|
*/
|
||||||
{
|
{
|
||||||
ULONG Status;
|
ULONG Status;
|
||||||
|
|
||||||
Status = Load((char*)&FileName);
|
Status = Load((char*)&FileName);
|
||||||
if (Status != CAB_STATUS_SUCCESS)
|
if (Status != CAB_STATUS_SUCCESS)
|
||||||
{
|
{
|
||||||
printf("Specified directive file could not be found: %s.\n", (char*)&FileName);
|
printf("Specified directive file could not be found: %s.\n", (char*)&FileName);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
Status = Parse();
|
Status = Parse();
|
||||||
|
|
||||||
return (Status == CAB_STATUS_SUCCESS ? true : false);
|
return (Status == CAB_STATUS_SUCCESS ? true : false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -386,34 +384,34 @@ bool CCABManager::CreateSimpleCabinet()
|
||||||
* FUNCTION: Create cabinet
|
* FUNCTION: Create cabinet
|
||||||
*/
|
*/
|
||||||
{
|
{
|
||||||
ULONG Status;
|
ULONG Status;
|
||||||
|
|
||||||
Status = NewCabinet();
|
Status = NewCabinet();
|
||||||
if (Status != CAB_STATUS_SUCCESS)
|
if (Status != CAB_STATUS_SUCCESS)
|
||||||
{
|
{
|
||||||
DPRINT(MIN_TRACE, ("Cannot create cabinet (%lu).\n", (ULONG)Status));
|
DPRINT(MIN_TRACE, ("Cannot create cabinet (%lu).\n", (ULONG)Status));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
Status = AddFile(FileName);
|
Status = AddFile(FileName);
|
||||||
if (Status != CAB_STATUS_SUCCESS)
|
if (Status != CAB_STATUS_SUCCESS)
|
||||||
{
|
{
|
||||||
DPRINT(MIN_TRACE, ("Cannot add file to cabinet (%lu).\n", (ULONG)Status));
|
DPRINT(MIN_TRACE, ("Cannot add file to cabinet (%lu).\n", (ULONG)Status));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
Status = WriteDisk(false);
|
Status = WriteDisk(false);
|
||||||
if (Status == CAB_STATUS_SUCCESS)
|
if (Status == CAB_STATUS_SUCCESS)
|
||||||
Status = CloseDisk();
|
Status = CloseDisk();
|
||||||
if (Status != CAB_STATUS_SUCCESS)
|
if (Status != CAB_STATUS_SUCCESS)
|
||||||
{
|
{
|
||||||
DPRINT(MIN_TRACE, ("Cannot write disk (%lu).\n", (ULONG)Status));
|
DPRINT(MIN_TRACE, ("Cannot write disk (%lu).\n", (ULONG)Status));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
CloseCabinet();
|
CloseCabinet();
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -422,62 +420,62 @@ bool CCABManager::DisplayCabinet()
|
||||||
* FUNCTION: Display cabinet contents
|
* FUNCTION: Display cabinet contents
|
||||||
*/
|
*/
|
||||||
{
|
{
|
||||||
CAB_SEARCH Search;
|
CAB_SEARCH Search;
|
||||||
char Str[20];
|
char Str[20];
|
||||||
ULONG FileCount = 0;
|
ULONG FileCount = 0;
|
||||||
ULONG ByteCount = 0;
|
ULONG ByteCount = 0;
|
||||||
|
|
||||||
if (Open() == CAB_STATUS_SUCCESS)
|
if (Open() == CAB_STATUS_SUCCESS)
|
||||||
{
|
{
|
||||||
printf("Cabinet %s\n\n", GetCabinetName());
|
printf("Cabinet %s\n\n", GetCabinetName());
|
||||||
|
|
||||||
if (FindFirst("", &Search) == CAB_STATUS_SUCCESS)
|
if (FindFirst("", &Search) == CAB_STATUS_SUCCESS)
|
||||||
{
|
{
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
if (Search.File->FileControlID != CAB_FILE_CONTINUED)
|
if (Search.File->FileControlID != CAB_FILE_CONTINUED)
|
||||||
{
|
{
|
||||||
printf("%s ", Date2Str((char*)&Str, Search.File->FileDate));
|
printf("%s ", Date2Str((char*)&Str, Search.File->FileDate));
|
||||||
printf("%s ", Time2Str((char*)&Str, Search.File->FileTime));
|
printf("%s ", Time2Str((char*)&Str, Search.File->FileTime));
|
||||||
printf("%s ", Attr2Str((char*)&Str, Search.File->Attributes));
|
printf("%s ", Attr2Str((char*)&Str, Search.File->Attributes));
|
||||||
sprintf(Str, "%lu", Search.File->FileSize);
|
sprintf(Str, "%lu", Search.File->FileSize);
|
||||||
printf("%s ", Pad(Str, ' ', 13));
|
printf("%s ", Pad(Str, ' ', 13));
|
||||||
printf("%s\n", Search.FileName);
|
printf("%s\n", Search.FileName);
|
||||||
|
|
||||||
FileCount++;
|
FileCount++;
|
||||||
ByteCount += Search.File->FileSize;
|
ByteCount += Search.File->FileSize;
|
||||||
}
|
}
|
||||||
} while (FindNext(&Search) == CAB_STATUS_SUCCESS);
|
} while (FindNext(&Search) == CAB_STATUS_SUCCESS);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (FileCount > 0) {
|
if (FileCount > 0) {
|
||||||
if (FileCount == 1)
|
if (FileCount == 1)
|
||||||
printf(" 1 file ");
|
printf(" 1 file ");
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
sprintf(Str, "%lu", FileCount);
|
sprintf(Str, "%lu", FileCount);
|
||||||
printf(" %s files ", Pad(Str, ' ', 12));
|
printf(" %s files ", Pad(Str, ' ', 12));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ByteCount == 1)
|
if (ByteCount == 1)
|
||||||
printf(" 1 byte\n");
|
printf(" 1 byte\n");
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
sprintf(Str, "%lu", ByteCount);
|
sprintf(Str, "%lu", ByteCount);
|
||||||
printf("%s bytes\n", Pad(Str, ' ', 12));
|
printf("%s bytes\n", Pad(Str, ' ', 12));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
/* There should be at least one file in a cabinet */
|
/* There should be at least one file in a cabinet */
|
||||||
printf("No files in cabinet.");
|
printf("No files in cabinet.");
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
printf("Cannot open file: %s\n", GetCabinetName());
|
printf("Cannot open file: %s\n", GetCabinetName());
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -486,44 +484,44 @@ bool CCABManager::ExtractFromCabinet()
|
||||||
* FUNCTION: Extract file(s) from cabinet
|
* FUNCTION: Extract file(s) from cabinet
|
||||||
*/
|
*/
|
||||||
{
|
{
|
||||||
CAB_SEARCH Search;
|
CAB_SEARCH Search;
|
||||||
ULONG Status;
|
ULONG Status;
|
||||||
|
|
||||||
if (Open() == CAB_STATUS_SUCCESS)
|
if (Open() == CAB_STATUS_SUCCESS)
|
||||||
{
|
{
|
||||||
printf("Cabinet %s\n\n", GetCabinetName());
|
printf("Cabinet %s\n\n", GetCabinetName());
|
||||||
|
|
||||||
if (FindFirst("", &Search) == CAB_STATUS_SUCCESS)
|
if (FindFirst("", &Search) == CAB_STATUS_SUCCESS)
|
||||||
{
|
{
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
switch (Status = ExtractFile(Search.FileName)) {
|
switch (Status = ExtractFile(Search.FileName)) {
|
||||||
case CAB_STATUS_SUCCESS:
|
case CAB_STATUS_SUCCESS:
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case CAB_STATUS_INVALID_CAB:
|
case CAB_STATUS_INVALID_CAB:
|
||||||
printf("Cabinet contains errors.\n");
|
printf("Cabinet contains errors.\n");
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
case CAB_STATUS_UNSUPPCOMP:
|
case CAB_STATUS_UNSUPPCOMP:
|
||||||
printf("Cabinet uses unsupported compression type.\n");
|
printf("Cabinet uses unsupported compression type.\n");
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
case CAB_STATUS_CANNOT_WRITE:
|
case CAB_STATUS_CANNOT_WRITE:
|
||||||
printf("You've run out of free space on the destination volume or the volume is damaged.\n");
|
printf("You've run out of free space on the destination volume or the volume is damaged.\n");
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
printf("Unspecified error code (%lu).\n", (ULONG)Status);
|
printf("Unspecified error code (%lu).\n", (ULONG)Status);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
} while (FindNext(&Search) == CAB_STATUS_SUCCESS);
|
} while (FindNext(&Search) == CAB_STATUS_SUCCESS);
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
} else
|
} else
|
||||||
printf("Cannot open file: %s.\n", GetCabinetName());
|
printf("Cannot open file: %s.\n", GetCabinetName());
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -532,30 +530,30 @@ bool CCABManager::Run()
|
||||||
* FUNCTION: Process cabinet
|
* FUNCTION: Process cabinet
|
||||||
*/
|
*/
|
||||||
{
|
{
|
||||||
printf("ReactOS Cabinet Manager - Version %s\n\n", CM_VERSION);
|
printf("ReactOS Cabinet Manager - Version %s\n\n", CM_VERSION);
|
||||||
|
|
||||||
switch (Mode)
|
switch (Mode)
|
||||||
{
|
{
|
||||||
case CM_MODE_CREATE:
|
case CM_MODE_CREATE:
|
||||||
return CreateCabinet();
|
return CreateCabinet();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case CM_MODE_DISPLAY:
|
case CM_MODE_DISPLAY:
|
||||||
return DisplayCabinet();
|
return DisplayCabinet();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case CM_MODE_EXTRACT:
|
case CM_MODE_EXTRACT:
|
||||||
return ExtractFromCabinet();
|
return ExtractFromCabinet();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case CM_MODE_CREATE_SIMPLE:
|
case CM_MODE_CREATE_SIMPLE:
|
||||||
return CreateSimpleCabinet();
|
return CreateSimpleCabinet();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -572,11 +570,11 @@ bool CCABManager::OnOverwrite(PCFFILE File,
|
||||||
* true if the file should be overwritten, false if not
|
* true if the file should be overwritten, false if not
|
||||||
*/
|
*/
|
||||||
{
|
{
|
||||||
if (Mode == CM_MODE_CREATE)
|
if (Mode == CM_MODE_CREATE)
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
/* Always overwrite */
|
/* Always overwrite */
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -589,7 +587,7 @@ void CCABManager::OnExtract(PCFFILE File,
|
||||||
* FileName = Pointer to buffer with name of file (full path)
|
* FileName = Pointer to buffer with name of file (full path)
|
||||||
*/
|
*/
|
||||||
{
|
{
|
||||||
printf("Extracting %s\n", GetFileName(FileName));
|
printf("Extracting %s\n", GetFileName(FileName));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -603,7 +601,7 @@ void CCABManager::OnDiskChange(char* CabinetName,
|
||||||
* DiskLabel = Pointer to buffer with label of disk
|
* DiskLabel = Pointer to buffer with label of disk
|
||||||
*/
|
*/
|
||||||
{
|
{
|
||||||
printf("\nChanging to cabinet %s - %s\n\n", CabinetName, DiskLabel);
|
printf("\nChanging to cabinet %s - %s\n\n", CabinetName, DiskLabel);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -616,7 +614,7 @@ void CCABManager::OnAdd(PCFFILE File,
|
||||||
* FileName = Pointer to buffer with name of file (full path)
|
* FileName = Pointer to buffer with name of file (full path)
|
||||||
*/
|
*/
|
||||||
{
|
{
|
||||||
printf("Adding %s\n", GetFileName(FileName));
|
printf("Adding %s\n", GetFileName(FileName));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -628,13 +626,13 @@ int main(int argc, char * argv[])
|
||||||
* argv = Pointer to list of command line arguments
|
* argv = Pointer to list of command line arguments
|
||||||
*/
|
*/
|
||||||
{
|
{
|
||||||
CCABManager CABMgr;
|
CCABManager CABMgr;
|
||||||
bool status = false;
|
bool status = false;
|
||||||
|
|
||||||
if (CABMgr.ParseCmdline(argc, argv))
|
if (CABMgr.ParseCmdline(argc, argv))
|
||||||
status = CABMgr.Run();
|
status = CABMgr.Run();
|
||||||
|
|
||||||
return (status ? 0 : 1);
|
return (status ? 0 : 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* EOF */
|
/* EOF */
|
||||||
|
|
|
@ -10,9 +10,7 @@
|
||||||
* REVISIONS:
|
* REVISIONS:
|
||||||
* CSH 21/03-2001 Created
|
* CSH 21/03-2001 Created
|
||||||
* CSH 15/08-2003 Made it portable
|
* CSH 15/08-2003 Made it portable
|
||||||
* CF 04/05-2007 Reformatted the code to be more consistent and use TABs instead of spaces
|
|
||||||
* CF 04/05-2007 Made it compatible with 64-bit operating systems
|
* CF 04/05-2007 Made it compatible with 64-bit operating systems
|
||||||
* CF 18/08-2007 Use typedefs64.h and the Windows types for compatibility with 64-bit operating systems
|
|
||||||
*/
|
*/
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include "mszip.h"
|
#include "mszip.h"
|
||||||
|
@ -22,14 +20,14 @@
|
||||||
|
|
||||||
voidpf MSZipAlloc(voidpf opaque, uInt items, uInt size)
|
voidpf MSZipAlloc(voidpf opaque, uInt items, uInt size)
|
||||||
{
|
{
|
||||||
DPRINT(DEBUG_MEMORY, ("items = (%d) size = (%d)\n", items, size));
|
DPRINT(DEBUG_MEMORY, ("items = (%d) size = (%d)\n", items, size));
|
||||||
return AllocateMemory(items * size);
|
return AllocateMemory(items * size);
|
||||||
}
|
}
|
||||||
|
|
||||||
void MSZipFree (voidpf opaque, voidpf address)
|
void MSZipFree (voidpf opaque, voidpf address)
|
||||||
{
|
{
|
||||||
DPRINT(DEBUG_MEMORY, ("\n"));
|
DPRINT(DEBUG_MEMORY, ("\n"));
|
||||||
FreeMemory(address);
|
FreeMemory(address);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -40,9 +38,9 @@ CMSZipCodec::CMSZipCodec()
|
||||||
* FUNCTION: Default constructor
|
* FUNCTION: Default constructor
|
||||||
*/
|
*/
|
||||||
{
|
{
|
||||||
ZStream.zalloc = MSZipAlloc;
|
ZStream.zalloc = MSZipAlloc;
|
||||||
ZStream.zfree = MSZipFree;
|
ZStream.zfree = MSZipFree;
|
||||||
ZStream.opaque = (voidpf)0;
|
ZStream.opaque = (voidpf)0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -67,50 +65,50 @@ ULONG CMSZipCodec::Compress(void* OutputBuffer,
|
||||||
* OutputLength = Address of buffer to place size of compressed data
|
* OutputLength = Address of buffer to place size of compressed data
|
||||||
*/
|
*/
|
||||||
{
|
{
|
||||||
PUSHORT Magic;
|
PUSHORT Magic;
|
||||||
|
|
||||||
DPRINT(MAX_TRACE, ("InputLength (%lu).\n", InputLength));
|
DPRINT(MAX_TRACE, ("InputLength (%lu).\n", InputLength));
|
||||||
|
|
||||||
Magic = (PUSHORT)OutputBuffer;
|
Magic = (PUSHORT)OutputBuffer;
|
||||||
*Magic = MSZIP_MAGIC;
|
*Magic = MSZIP_MAGIC;
|
||||||
|
|
||||||
ZStream.next_in = (unsigned char*)InputBuffer;
|
ZStream.next_in = (unsigned char*)InputBuffer;
|
||||||
ZStream.avail_in = InputLength;
|
ZStream.avail_in = InputLength;
|
||||||
ZStream.next_out = (unsigned char*)((_W64 unsigned long)OutputBuffer + 2);
|
ZStream.next_out = (unsigned char*)((_W64 unsigned long)OutputBuffer + 2);
|
||||||
ZStream.avail_out = CAB_BLOCKSIZE + 12;
|
ZStream.avail_out = CAB_BLOCKSIZE + 12;
|
||||||
|
|
||||||
/* WindowBits is passed < 0 to tell that there is no zlib header */
|
/* WindowBits is passed < 0 to tell that there is no zlib header */
|
||||||
Status = deflateInit2(&ZStream,
|
Status = deflateInit2(&ZStream,
|
||||||
Z_BEST_COMPRESSION,
|
Z_BEST_COMPRESSION,
|
||||||
Z_DEFLATED,
|
Z_DEFLATED,
|
||||||
-MAX_WBITS,
|
-MAX_WBITS,
|
||||||
8, /* memLevel */
|
8, /* memLevel */
|
||||||
Z_DEFAULT_STRATEGY);
|
Z_DEFAULT_STRATEGY);
|
||||||
if (Status != Z_OK)
|
if (Status != Z_OK)
|
||||||
{
|
{
|
||||||
DPRINT(MIN_TRACE, ("deflateInit() returned (%d).\n", Status));
|
DPRINT(MIN_TRACE, ("deflateInit() returned (%d).\n", Status));
|
||||||
return CS_NOMEMORY;
|
return CS_NOMEMORY;
|
||||||
}
|
}
|
||||||
|
|
||||||
Status = deflate(&ZStream, Z_FINISH);
|
Status = deflate(&ZStream, Z_FINISH);
|
||||||
if ((Status != Z_OK) && (Status != Z_STREAM_END))
|
if ((Status != Z_OK) && (Status != Z_STREAM_END))
|
||||||
{
|
{
|
||||||
DPRINT(MIN_TRACE, ("deflate() returned (%d) (%s).\n", Status, ZStream.msg));
|
DPRINT(MIN_TRACE, ("deflate() returned (%d) (%s).\n", Status, ZStream.msg));
|
||||||
if (Status == Z_MEM_ERROR)
|
if (Status == Z_MEM_ERROR)
|
||||||
return CS_NOMEMORY;
|
return CS_NOMEMORY;
|
||||||
return CS_BADSTREAM;
|
return CS_BADSTREAM;
|
||||||
}
|
}
|
||||||
|
|
||||||
*OutputLength = ZStream.total_out + 2;
|
*OutputLength = ZStream.total_out + 2;
|
||||||
|
|
||||||
Status = deflateEnd(&ZStream);
|
Status = deflateEnd(&ZStream);
|
||||||
if (Status != Z_OK)
|
if (Status != Z_OK)
|
||||||
{
|
{
|
||||||
DPRINT(MIN_TRACE, ("deflateEnd() returned (%d).\n", Status));
|
DPRINT(MIN_TRACE, ("deflateEnd() returned (%d).\n", Status));
|
||||||
return CS_BADSTREAM;
|
return CS_BADSTREAM;
|
||||||
}
|
}
|
||||||
|
|
||||||
return CS_SUCCESS;
|
return CS_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -127,58 +125,58 @@ ULONG CMSZipCodec::Uncompress(void* OutputBuffer,
|
||||||
* OutputLength = Address of buffer to place size of uncompressed data
|
* OutputLength = Address of buffer to place size of uncompressed data
|
||||||
*/
|
*/
|
||||||
{
|
{
|
||||||
USHORT Magic;
|
USHORT Magic;
|
||||||
|
|
||||||
DPRINT(MAX_TRACE, ("InputLength (%lu).\n", InputLength));
|
DPRINT(MAX_TRACE, ("InputLength (%lu).\n", InputLength));
|
||||||
|
|
||||||
Magic = *((PUSHORT)InputBuffer);
|
Magic = *((PUSHORT)InputBuffer);
|
||||||
|
|
||||||
if (Magic != MSZIP_MAGIC)
|
if (Magic != MSZIP_MAGIC)
|
||||||
{
|
{
|
||||||
DPRINT(MID_TRACE, ("Bad MSZIP block header magic (0x%X)\n", Magic));
|
DPRINT(MID_TRACE, ("Bad MSZIP block header magic (0x%X)\n", Magic));
|
||||||
return CS_BADSTREAM;
|
return CS_BADSTREAM;
|
||||||
}
|
}
|
||||||
|
|
||||||
ZStream.next_in = (unsigned char*)((_W64 unsigned long)InputBuffer + 2);
|
ZStream.next_in = (unsigned char*)((_W64 unsigned long)InputBuffer + 2);
|
||||||
ZStream.avail_in = InputLength - 2;
|
ZStream.avail_in = InputLength - 2;
|
||||||
ZStream.next_out = (unsigned char*)OutputBuffer;
|
ZStream.next_out = (unsigned char*)OutputBuffer;
|
||||||
ZStream.avail_out = CAB_BLOCKSIZE + 12;
|
ZStream.avail_out = CAB_BLOCKSIZE + 12;
|
||||||
|
|
||||||
/* WindowBits is passed < 0 to tell that there is no zlib header.
|
/* WindowBits is passed < 0 to tell that there is no zlib header.
|
||||||
* Note that in this case inflate *requires* an extra "dummy" byte
|
* Note that in this case inflate *requires* an extra "dummy" byte
|
||||||
* after the compressed stream in order to complete decompression and
|
* after the compressed stream in order to complete decompression and
|
||||||
* return Z_STREAM_END.
|
* return Z_STREAM_END.
|
||||||
*/
|
*/
|
||||||
Status = inflateInit2(&ZStream, -MAX_WBITS);
|
Status = inflateInit2(&ZStream, -MAX_WBITS);
|
||||||
if (Status != Z_OK)
|
if (Status != Z_OK)
|
||||||
{
|
{
|
||||||
DPRINT(MIN_TRACE, ("inflateInit2() returned (%d).\n", Status));
|
DPRINT(MIN_TRACE, ("inflateInit2() returned (%d).\n", Status));
|
||||||
return CS_BADSTREAM;
|
return CS_BADSTREAM;
|
||||||
}
|
}
|
||||||
|
|
||||||
while ((ZStream.total_out < CAB_BLOCKSIZE + 12) &&
|
while ((ZStream.total_out < CAB_BLOCKSIZE + 12) &&
|
||||||
(ZStream.total_in < InputLength - 2))
|
(ZStream.total_in < InputLength - 2))
|
||||||
{
|
{
|
||||||
Status = inflate(&ZStream, Z_NO_FLUSH);
|
Status = inflate(&ZStream, Z_NO_FLUSH);
|
||||||
if (Status == Z_STREAM_END) break;
|
if (Status == Z_STREAM_END) break;
|
||||||
if (Status != Z_OK)
|
if (Status != Z_OK)
|
||||||
{
|
{
|
||||||
DPRINT(MIN_TRACE, ("inflate() returned (%d) (%s).\n", Status, ZStream.msg));
|
DPRINT(MIN_TRACE, ("inflate() returned (%d) (%s).\n", Status, ZStream.msg));
|
||||||
if (Status == Z_MEM_ERROR)
|
if (Status == Z_MEM_ERROR)
|
||||||
return CS_NOMEMORY;
|
return CS_NOMEMORY;
|
||||||
return CS_BADSTREAM;
|
return CS_BADSTREAM;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
*OutputLength = ZStream.total_out;
|
*OutputLength = ZStream.total_out;
|
||||||
|
|
||||||
Status = inflateEnd(&ZStream);
|
Status = inflateEnd(&ZStream);
|
||||||
if (Status != Z_OK)
|
if (Status != Z_OK)
|
||||||
{
|
{
|
||||||
DPRINT(MIN_TRACE, ("inflateEnd() returned (%d).\n", Status));
|
DPRINT(MIN_TRACE, ("inflateEnd() returned (%d).\n", Status));
|
||||||
return CS_BADSTREAM;
|
return CS_BADSTREAM;
|
||||||
}
|
}
|
||||||
return CS_SUCCESS;
|
return CS_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* EOF */
|
/* EOF */
|
||||||
|
|
|
@ -17,23 +17,23 @@
|
||||||
|
|
||||||
class CMSZipCodec : public CCABCodec {
|
class CMSZipCodec : public CCABCodec {
|
||||||
public:
|
public:
|
||||||
/* Default constructor */
|
/* Default constructor */
|
||||||
CMSZipCodec();
|
CMSZipCodec();
|
||||||
/* Default destructor */
|
/* Default destructor */
|
||||||
virtual ~CMSZipCodec();
|
virtual ~CMSZipCodec();
|
||||||
/* Compresses a data block */
|
/* Compresses a data block */
|
||||||
virtual ULONG Compress(void* OutputBuffer,
|
virtual ULONG Compress(void* OutputBuffer,
|
||||||
void* InputBuffer,
|
void* InputBuffer,
|
||||||
ULONG InputLength,
|
ULONG InputLength,
|
||||||
PULONG OutputLength);
|
PULONG OutputLength);
|
||||||
/* Uncompresses a data block */
|
/* Uncompresses a data block */
|
||||||
virtual ULONG Uncompress(void* OutputBuffer,
|
virtual ULONG Uncompress(void* OutputBuffer,
|
||||||
void* InputBuffer,
|
void* InputBuffer,
|
||||||
ULONG InputLength,
|
ULONG InputLength,
|
||||||
PULONG OutputLength);
|
PULONG OutputLength);
|
||||||
private:
|
private:
|
||||||
int Status;
|
int Status;
|
||||||
z_stream ZStream; /* Zlib stream */
|
z_stream ZStream; /* Zlib stream */
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif /* __MSZIP_H */
|
#endif /* __MSZIP_H */
|
||||||
|
|
|
@ -8,9 +8,7 @@
|
||||||
* REVISIONS:
|
* REVISIONS:
|
||||||
* CSH 21/03-2001 Created
|
* CSH 21/03-2001 Created
|
||||||
* CSH 15/08-2003 Made it portable
|
* CSH 15/08-2003 Made it portable
|
||||||
* CF 04/05-2007 Reformatted the code to be more consistent and use TABs instead of spaces
|
|
||||||
* CF 04/05-2007 Made it compatible with 64-bit operating systems
|
* CF 04/05-2007 Made it compatible with 64-bit operating systems
|
||||||
* CF 18/08-2007 Use typedefs64.h and the Windows types for compatibility with 64-bit operating systems
|
|
||||||
*/
|
*/
|
||||||
#include "raw.h"
|
#include "raw.h"
|
||||||
|
|
||||||
|
@ -46,9 +44,9 @@ ULONG CRawCodec::Compress(void* OutputBuffer,
|
||||||
* OutputLength = Address of buffer to place size of compressed data
|
* OutputLength = Address of buffer to place size of compressed data
|
||||||
*/
|
*/
|
||||||
{
|
{
|
||||||
memcpy(OutputBuffer, InputBuffer, InputLength);
|
memcpy(OutputBuffer, InputBuffer, InputLength);
|
||||||
*OutputLength = InputLength;
|
*OutputLength = InputLength;
|
||||||
return CS_SUCCESS;
|
return CS_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
ULONG CRawCodec::Uncompress(void* OutputBuffer,
|
ULONG CRawCodec::Uncompress(void* OutputBuffer,
|
||||||
|
@ -64,9 +62,9 @@ ULONG CRawCodec::Uncompress(void* OutputBuffer,
|
||||||
* OutputLength = Address of buffer to place size of uncompressed data
|
* OutputLength = Address of buffer to place size of uncompressed data
|
||||||
*/
|
*/
|
||||||
{
|
{
|
||||||
memcpy(OutputBuffer, InputBuffer, InputLength);
|
memcpy(OutputBuffer, InputBuffer, InputLength);
|
||||||
*OutputLength = InputLength;
|
*OutputLength = InputLength;
|
||||||
return CS_SUCCESS;
|
return CS_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* EOF */
|
/* EOF */
|
||||||
|
|
|
@ -14,20 +14,20 @@
|
||||||
|
|
||||||
class CRawCodec : public CCABCodec {
|
class CRawCodec : public CCABCodec {
|
||||||
public:
|
public:
|
||||||
/* Default constructor */
|
/* Default constructor */
|
||||||
CRawCodec();
|
CRawCodec();
|
||||||
/* Default destructor */
|
/* Default destructor */
|
||||||
virtual ~CRawCodec();
|
virtual ~CRawCodec();
|
||||||
/* Compresses a data block */
|
/* Compresses a data block */
|
||||||
virtual ULONG Compress(void* OutputBuffer,
|
virtual ULONG Compress(void* OutputBuffer,
|
||||||
void* InputBuffer,
|
void* InputBuffer,
|
||||||
ULONG InputLength,
|
ULONG InputLength,
|
||||||
PULONG OutputLength);
|
PULONG OutputLength);
|
||||||
/* Uncompresses a data block */
|
/* Uncompresses a data block */
|
||||||
virtual ULONG Uncompress(void* OutputBuffer,
|
virtual ULONG Uncompress(void* OutputBuffer,
|
||||||
void* InputBuffer,
|
void* InputBuffer,
|
||||||
ULONG InputLength,
|
ULONG InputLength,
|
||||||
PULONG OutputLength);
|
PULONG OutputLength);
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif /* __RAW_H */
|
#endif /* __RAW_H */
|
||||||
|
|
Loading…
Reference in a new issue