--- branches/xmlbuildsystem/reactos/tools/cabman/cabinet.cxx 2005-03-05 00:21:38 UTC (rev 13822)
+++ branches/xmlbuildsystem/reactos/tools/cabman/cabinet.cxx 2005-03-05 05:13:38 UTC (rev 13823)
@@ -34,7 +34,7 @@
#define ReadFileData(handle, buffer, size, bytesread) _ReadFileData(handle, buffer, size, bytesread)
static bool _ReadFileData(FILEHANDLE handle, void* buffer, unsigned long size, unsigned long* bytesread)
{
- return ReadFile(handle, buffer, size, bytesread, NULL);
+ return ReadFile(handle, buffer, size, bytesread, NULL) != 0;
}
#else
#define GetSizeOfFile(handle) _GetSizeOfFile(handle)
@@ -70,7 +70,7 @@
0, // No sharing
NULL, // No security
CREATE_ALWAYS, // Create or overwrite
- FILE_ATTRIBUTE_NORMAL, // Normal file
+ FILE_ATTRIBUTE_NORMAL, // Normal file
NULL); // No attribute template
if (FileHandle == INVALID_HANDLE_VALUE) {
DPRINT(MID_TRACE, ("ERROR OPENING '%d'.\n", (unsigned int)GetLastError()));
@@ -143,7 +143,7 @@
if ((FileHandle = tmpfile()) == NULL)
return CAB_STATUS_CANNOT_CREATE;
/*
- FileHandle = fopen(FullName, "w+b");
+ FileHandle = fopen(FullName, "w+b");
if (FileHandle == NULL) {
DPRINT(MID_TRACE, ("ERROR '%d'.\n", (unsigned int)errno));
return CAB_STATUS_CANNOT_CREATE;
@@ -297,9 +297,15 @@
* FUNCTION: Default constructor
*/
{
+ *CabinetName = '\0';
+ *CabinetPrev = '\0';
+ *DiskPrev = '\0';
+ *CabinetNext = '\0';
+ *DiskNext = '\0';
+ *DestPath = '\0';
+ *CabinetReservedFile = '\0';
+
FileOpen = false;
- strcpy(DestPath, "");
- strcpy(CabinetReservedFile, "");
CabinetReservedFileBuffer = NULL;
CabinetReservedFileSize = 0;
@@ -521,19 +527,19 @@
#if defined(WIN32)
FileHandle = CreateFile(ConvertPath(FileName, true), // Open this file
- GENERIC_READ, // Open for reading
- FILE_SHARE_READ, // Share for reading
- NULL, // No security
- OPEN_EXISTING, // Existing file only
- FILE_ATTRIBUTE_NORMAL, // Normal file
- NULL); // No attribute template
+ GENERIC_READ, // Open for reading
+ FILE_SHARE_READ, // Share for reading
+ NULL, // No security
+ OPEN_EXISTING, // Existing file only
+ FILE_ATTRIBUTE_NORMAL, // Normal file
+ NULL); // No attribute template
if (FileHandle == INVALID_HANDLE_VALUE) {
DPRINT(MID_TRACE, ("Cannot open cabinet reserved file.\n"));
return false;
}
#else /* !WIN32 */
-
- FileHandle = fopen(ConvertPath(FileName, true), "rb");
+
+ FileHandle = fopen(ConvertPath(FileName, true), "rb");
if (FileHandle == NULL) {
DPRINT(MID_TRACE, ("Cannot open cabinet reserved file.\n"));
return false;
@@ -614,19 +620,19 @@
#if defined(WIN32)
FileHandle = CreateFile(CabinetName, // Open this file
- GENERIC_READ, // Open for reading
- FILE_SHARE_READ, // Share for reading
- NULL, // No security
- OPEN_EXISTING, // Existing file only
- FILE_ATTRIBUTE_NORMAL, // Normal file
- NULL); // No attribute template
-
+ GENERIC_READ, // Open for reading
+ FILE_SHARE_READ, // Share for reading
+ NULL, // No security
+ OPEN_EXISTING, // Existing file only
+ FILE_ATTRIBUTE_NORMAL, // Normal file
+ NULL); // No attribute template
+
if (FileHandle == INVALID_HANDLE_VALUE) {
DPRINT(MID_TRACE, ("Cannot open file.\n"));
return CAB_STATUS_CANNOT_OPEN;
}
#else /* !WIN32 */
- FileHandle = fopen(CabinetName, "rb");
+ FileHandle = fopen(CabinetName, "rb");
if (FileHandle == NULL) {
DPRINT(MID_TRACE, ("Cannot open file.\n"));
return CAB_STATUS_CANNOT_OPEN;
@@ -694,7 +700,7 @@
strcpy(CabinetPrev, "");
strcpy(DiskPrev, "");
}
-
+
if ((CABHeader.Flags & CAB_FLAG_HASNEXT) > 0) {
/* Read name of next cabinet */
Status = ReadString(CabinetNext, 256);
@@ -818,7 +824,7 @@
OnDiskChange(CabinetNext, DiskNext);
Status = Open();
- if (Status != CAB_STATUS_SUCCESS)
+ if (Status != CAB_STATUS_SUCCESS)
return Status;
Search->Next = FileListHead;
@@ -925,7 +931,7 @@
}
}
#else /* !WIN32 */
- DestFile = fopen(DestName, "rb");
+ DestFile = fopen(DestName, "rb");
if (DestFile != NULL) {
fclose(DestFile);
/* If file exists, ask to overwrite file */
@@ -961,7 +967,7 @@
if (!Buffer) {
CloseFile(DestFile);
DPRINT(MIN_TRACE, ("Insufficient memory.\n"));
- return CAB_STATUS_NOMEMORY;
+ return CAB_STATUS_NOMEMORY;
}
/* Call OnExtract event handler */
@@ -1007,7 +1013,7 @@
do {
DPRINT(MAX_TRACE, ("Size (%lu bytes).\n", Size));
- if (((Status = ReadBlock(&CFData, sizeof(CFDATA), &BytesRead)) !=
+ if (((Status = ReadBlock(&CFData, sizeof(CFDATA), &BytesRead)) !=
CAB_STATUS_SUCCESS) || (BytesRead != sizeof(CFDATA))) {
CloseFile(DestFile);
FreeMemory(Buffer);
@@ -1027,7 +1033,7 @@
DPRINT(MAX_TRACE, ("Read: (0x%lX,0x%lX).\n",
(long unsigned int)CurrentBuffer, (long unsigned int)Buffer));
- if (((Status = ReadBlock(CurrentBuffer, BytesToRead, &BytesRead)) !=
+ if (((Status = ReadBlock(CurrentBuffer, BytesToRead, &BytesRead)) !=
CAB_STATUS_SUCCESS) || (BytesToRead != BytesRead)) {
CloseFile(DestFile);
FreeMemory(Buffer);
@@ -1068,7 +1074,7 @@
OnDiskChange(CabinetNext, DiskNext);
Status = Open();
- if (Status != CAB_STATUS_SUCCESS)
+ if (Status != CAB_STATUS_SUCCESS)
return Status;
/* The first data block of the file will not be
@@ -1140,7 +1146,7 @@
CurrentDataNode->AbsoluteOffset + sizeof(CFDATA) +
CurrentDataNode->Data.CompSize));
- if (((Status = ReadBlock(&CFData, sizeof(CFDATA), &BytesRead)) !=
+ if (((Status = ReadBlock(&CFData, sizeof(CFDATA), &BytesRead)) !=
CAB_STATUS_SUCCESS) || (BytesRead != sizeof(CFDATA))) {
CloseFile(DestFile);
FreeMemory(Buffer);
@@ -1274,7 +1280,7 @@
InputBuffer = AllocateMemory(CAB_BLOCKSIZE + 12); // This should be enough
if ((!OutputBuffer) || (!InputBuffer)) {
DPRINT(MIN_TRACE, ("Insufficient memory.\n"));
- return CAB_STATUS_NOMEMORY;
+ return CAB_STATUS_NOMEMORY;
}
CurrentIBuffer = InputBuffer;
CurrentIBufferSize = 0;
@@ -1417,14 +1423,14 @@
FILE_SHARE_READ, // Share for reading
NULL, // No security
OPEN_EXISTING, // File must exist
- FILE_ATTRIBUTE_NORMAL, // Normal file
+ FILE_ATTRIBUTE_NORMAL, // Normal file
NULL); // No attribute template
if (SourceFile == INVALID_HANDLE_VALUE) {
DPRINT(MID_TRACE, ("File not found (%s).\n", FileNode->FileName));
return CAB_STATUS_NOFILE;
}
#else /* !WIN32 */
- SourceFile = fopen(FileNode->FileName, "rb");
+ SourceFile = fopen(FileNode->FileName, "rb");
if (SourceFile == NULL) {
DPRINT(MID_TRACE, ("Cannot open cabinet reserved file.\n"));
return CAB_STATUS_NOFILE;
@@ -1447,7 +1453,7 @@
FileNode->File.FileOffset = CurrentFolderNode->UncompOffset;
CurrentFolderNode->UncompOffset += TotalBytesLeft;
- FileNode->File.FileControlID = NextFolderNumber - 1;
+ FileNode->File.FileControlID = (unsigned short)(NextFolderNumber - 1);
CurrentFolderNode->Commit = true;
PrevCabinetNumber = CurrentDiskNumber;
@@ -1543,7 +1549,7 @@
ContinueFile = true;
CreateNewDisk = false;
- DPRINT(MAX_TRACE, ("First on new disk. CurrentIBufferSize (%lu) CurrentOBufferSize (%lu).\n",
+ DPRINT(MAX_TRACE, ("First on new disk. CurrentIBufferSize (%lu) CurrentOBufferSize (%lu).\n",
CurrentIBufferSize, CurrentOBufferSize));
if ((CurrentIBufferSize > 0) || (CurrentOBufferSize > 0)) {
@@ -1635,7 +1641,7 @@
}
}
#else /* !WIN32 */
- FileHandle = fopen(CabinetName, "rb");
+ FileHandle = fopen(CabinetName, "rb");
if (FileHandle != NULL) {
fclose(FileHandle);
/* If file exists, ask to overwrite file */
@@ -1655,7 +1661,7 @@
}
#endif
- WriteCabinetHeader(MoreDisks);
+ WriteCabinetHeader(MoreDisks != 0);
Status = WriteFolderEntries();
if (Status != CAB_STATUS_SUCCESS)
@@ -1770,14 +1776,14 @@
FILE_SHARE_READ, // Share for reading
NULL, // No security
OPEN_EXISTING, // File must exist
- FILE_ATTRIBUTE_NORMAL, // Normal file
+ FILE_ATTRIBUTE_NORMAL, // Normal file
NULL); // No attribute template
if (SrcFile == INVALID_HANDLE_VALUE) {
DPRINT(MID_TRACE, ("File not found (%s).\n", FileNode->FileName));
return CAB_STATUS_CANNOT_OPEN;
}
#else /* !WIN32 */
- SrcFile = fopen(FileNode->FileName, "rb");
+ SrcFile = fopen(FileNode->FileName, "rb");
if (SrcFile == NULL) {
DPRINT(MID_TRACE, ("File not found (%s).\n", FileNode->FileName));
return CAB_STATUS_CANNOT_OPEN;
@@ -2545,8 +2551,8 @@
CABHeader.FileCount = 0; // Not known yet
CABHeader.Flags = 0; // Not known yet
- CABHeader.CabinetNumber = CurrentDiskNumber;
-
+ CABHeader.CabinetNumber = (unsigned short)CurrentDiskNumber;
+
if ((CurrentDiskNumber > 0) && (OnCabinetName(PrevCabinetNumber, CabinetPrev))) {
CABHeader.Flags |= CAB_FLAG_HASPREV;
if (!OnDiskLabel(PrevCabinetNumber, DiskPrev))
@@ -2672,7 +2678,7 @@
/* Write per-cabinet reserved area if present */
if (CABHeader.Flags & CAB_FLAG_RESERVE) {
unsigned long ReservedSize;
-
+
ReservedSize = CabinetReservedFileSize & 0xffff;
ReservedSize |= (0 << 16); /* Folder reserved area size */
ReservedSize |= (0 << 24); /* Folder reserved area size */
@@ -2846,7 +2852,7 @@
/* The file could end in the last (split) block and should therefore
appear in the next disk too */
-
+
if ((File->File.FileOffset + File->File.FileSize >= LastBlockStart) &&
(File->File.FileControlID <= CAB_FILE_MAX_FOLDER) && (BlockIsSplit)) {
File->File.FileControlID = CAB_FILE_SPLIT;
@@ -2914,7 +2920,7 @@
DataNode = FolderNode->DataListHead;
if (DataNode != NULL)
Status = ScratchFile->Seek(DataNode->ScratchFilePosition);
-
+
while (DataNode != NULL) {
DPRINT(MAX_TRACE, ("Reading block at (0x%lX) CompSize (%d) UncompSize (%d).\n",
DataNode->ScratchFilePosition,
--- branches/xmlbuildsystem/reactos/tools/cabman/main.cxx 2005-03-05 00:21:38 UTC (rev 13822)
+++ branches/xmlbuildsystem/reactos/tools/cabman/main.cxx 2005-03-05 05:13:38 UTC (rev 13823)
@@ -189,9 +189,9 @@
*/
{
printf("ReactOS Cabinet Manager - Version %s\n\n", CM_VERSION);
- printf("CABMAN [/D | /E] [/A] [/L dir] cabinet [filename ...]\n");
- printf("CABMAN /C dirfile [/I] [/RC file]\n");
- printf("CABMAN /S cabinet filename\n");
+ printf("CABMAN [-D | -E] [-A] [-L dir] cabinet [filename ...]\n");
+ printf("CABMAN -C dirfile [-I] [-RC file]\n");
+ printf("CABMAN -S cabinet filename\n");
printf(" cabinet Cabinet file.\n");
printf(" filename Name of the file to extract from the cabinet.\n");
printf(" Wild cards and multiple filenames\n");
@@ -199,18 +199,18 @@
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(" /C Create cabinet.\n");
- printf(" /D Display cabinet directory.\n");
- printf(" /E Extract files from cabinet.\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(" -C Create cabinet.\n");
+ printf(" -D Display cabinet directory.\n");
+ printf(" -E Extract files from cabinet.\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(" (default is current directory).\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(" -N Don't create the .inf file, only the cabinet.\n");
+ printf(" -RC Specify file to put in cabinet reserved area\n");
printf(" (size must be less than 64KB).\n");
- printf(" /S Create simple cabinet.\n");
+ printf(" -S Create simple cabinet.\n");
}
bool CCABManager::ParseCmdline(int argc, char* argv[])
@@ -230,7 +230,7 @@
ShowUsage = (argc < 2);
for (i = 1; i < argc; i++) {
- if (argv[i][0] == '/') {
+ if (argv[i][0] == '-') {
switch (argv[i][1]) {
case 'a':
case 'A': ProcessAll = true; break;
@@ -404,7 +404,7 @@
}
return true;
} else
- printf("Cannot not open file: %s\n", GetCabinetName());
+ printf("Cannot open file: %s\n", GetCabinetName());
return false;
}
@@ -443,7 +443,7 @@
}
return true;
} else
- printf("Cannot not open file: %s.\n", GetCabinetName());
+ printf("Cannot open file: %s.\n", GetCabinetName());
return false;
}