Implemented creation of simple cabinet files (one file per cabinet).

svn path=/trunk/; revision=5957
This commit is contained in:
Eric Kohl 2003-09-01 15:43:25 +00:00
parent 3882add234
commit ed2e90a9e8
2 changed files with 56 additions and 17 deletions

View file

@ -14,7 +14,7 @@
#define CM_MODE_CREATE 0 #define CM_MODE_CREATE 0
#define CM_MODE_DISPLAY 1 #define CM_MODE_DISPLAY 1
#define CM_MODE_EXTRACT 2 #define CM_MODE_EXTRACT 2
#define CM_MODE_CREATE_SIMPLE 3
/* Classes */ /* Classes */
@ -27,6 +27,7 @@ public:
private: private:
void Usage(); void Usage();
bool CreateCabinet(); bool CreateCabinet();
bool CreateSimpleCabinet();
bool DisplayCabinet(); bool DisplayCabinet();
bool ExtractFromCabinet(); bool ExtractFromCabinet();
/* Event handlers */ /* Event handlers */

View file

@ -191,6 +191,7 @@ void CCABManager::Usage()
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]\n"); printf("CABMAN /C dirfile [/I] [/RC file]\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");
@ -209,6 +210,7 @@ void CCABManager::Usage()
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");
} }
bool CCABManager::ParseCmdline(int argc, char* argv[]) bool CCABManager::ParseCmdline(int argc, char* argv[])
@ -222,14 +224,14 @@ bool CCABManager::ParseCmdline(int argc, char* argv[])
*/ */
{ {
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': ProcessAll = true; break; case 'A': ProcessAll = true; break;
case 'c': case 'c':
@ -237,11 +239,11 @@ bool CCABManager::ParseCmdline(int argc, char* argv[])
case 'd': case 'd':
case 'D': Mode = CM_MODE_DISPLAY; break; case 'D': Mode = CM_MODE_DISPLAY; break;
case 'e': case 'e':
case 'E': Mode = CM_MODE_EXTRACT; break; case 'E': Mode = CM_MODE_EXTRACT; break;
case 'i': case 'i':
case 'I': InfFileOnly = true; break; case 'I': InfFileOnly = true; 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]);
@ -251,7 +253,7 @@ bool CCABManager::ParseCmdline(int argc, char* argv[])
break; break;
case 'n': case 'n':
case 'N': DontGenerateInf = true; break; case 'N': DontGenerateInf = true; 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) {
@ -272,30 +274,32 @@ bool CCABManager::ParseCmdline(int argc, char* argv[])
return false; return false;
} }
break; break;
default: case 's':
case 'S': Mode = CM_MODE_CREATE_SIMPLE; break;
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;
} }
@ -318,6 +322,39 @@ bool CCABManager::CreateCabinet()
} }
bool CCABManager::CreateSimpleCabinet()
/*
* FUNCTION: Create cabinet
*/
{
unsigned long Status;
Status = NewCabinet();
if (Status != CAB_STATUS_SUCCESS) {
DPRINT(MIN_TRACE, ("Cannot create cabinet (%d).\n", (unsigned int)Status));
return false;
}
Status = AddFile(FileName);
if (Status != CAB_STATUS_SUCCESS) {
DPRINT(MIN_TRACE, ("Cannot add file to cabinet (%d).\n", (unsigned int)Status));
return false;
}
Status = WriteDisk(false);
if (Status == CAB_STATUS_SUCCESS)
Status = CloseDisk();
if (Status != CAB_STATUS_SUCCESS) {
DPRINT(MIN_TRACE, ("Cannot write disk (%d).\n", (unsigned int)Status));
return false;
}
CloseCabinet();
return true;
}
bool CCABManager::DisplayCabinet() bool CCABManager::DisplayCabinet()
/* /*
* FUNCTION: Display cabinet contents * FUNCTION: Display cabinet contents
@ -423,6 +460,7 @@ bool CCABManager::Run()
case CM_MODE_CREATE: return CreateCabinet(); break; case CM_MODE_CREATE: return CreateCabinet(); break;
case CM_MODE_DISPLAY: return DisplayCabinet(); break; case CM_MODE_DISPLAY: return DisplayCabinet(); break;
case CM_MODE_EXTRACT: return ExtractFromCabinet(); break; case CM_MODE_EXTRACT: return ExtractFromCabinet(); break;
case CM_MODE_CREATE_SIMPLE: return CreateSimpleCabinet(); break;
default: default:
break; break;
} }