mirror of
https://github.com/reactos/reactos.git
synced 2025-02-24 01:15:09 +00:00
CABMAN: add support for optional files (they are listed in the reactos.dff, but may not exist in the output-??? directory).
svn path=/trunk/; revision=17396
This commit is contained in:
parent
54bd458644
commit
a0fb1d3891
3 changed files with 46 additions and 20 deletions
|
@ -8,7 +8,7 @@ case insensitive.
|
||||||
Syntax Description
|
Syntax Description
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
; Anything on a line after this is a comment
|
; Anything on a line after this is a comment
|
||||||
<filename> [destination] File copy command
|
<filename> [destination] [options] File copy command (options: o=optional)
|
||||||
.Define variable=[value] Define variable to be equal to value (*)
|
.Define variable=[value] Define variable to be equal to value (*)
|
||||||
.Delete variable Delete a variable definition (*)
|
.Delete variable Delete a variable definition (*)
|
||||||
.New Disk|Cabinet|Folder Start a new disk, cabinet or folder (* -- new disk will work)
|
.New Disk|Cabinet|Folder Start a new disk, cabinet or folder (* -- new disk will work)
|
||||||
|
|
|
@ -1016,11 +1016,13 @@ unsigned long CDFParser::PerformFileCopy()
|
||||||
char SrcName[MAX_PATH];
|
char SrcName[MAX_PATH];
|
||||||
char DstName[MAX_PATH];
|
char DstName[MAX_PATH];
|
||||||
char InfLine[MAX_PATH];
|
char InfLine[MAX_PATH];
|
||||||
|
char Options[8];
|
||||||
char BaseFilename[MAX_PATH];
|
char BaseFilename[MAX_PATH];
|
||||||
|
|
||||||
strcpy(SrcName, "");
|
*SrcName = '\0';
|
||||||
strcpy(DstName, "");
|
*DstName = '\0';
|
||||||
|
|
||||||
|
// source file
|
||||||
i = CurrentChar;
|
i = CurrentChar;
|
||||||
while ((i < LineLength) &&
|
while ((i < LineLength) &&
|
||||||
((ch = Line[i]) != ' ') &&
|
((ch = Line[i]) != ' ') &&
|
||||||
|
@ -1035,6 +1037,7 @@ unsigned long CDFParser::PerformFileCopy()
|
||||||
strcpy(BaseFilename, CurrentString);
|
strcpy(BaseFilename, CurrentString);
|
||||||
strcat(SrcName, BaseFilename);
|
strcat(SrcName, BaseFilename);
|
||||||
|
|
||||||
|
// destination
|
||||||
SkipSpaces();
|
SkipSpaces();
|
||||||
|
|
||||||
if (CurrentToken != TokenEnd) {
|
if (CurrentToken != TokenEnd) {
|
||||||
|
@ -1052,6 +1055,24 @@ unsigned long CDFParser::PerformFileCopy()
|
||||||
strcpy(DstName, CurrentString);
|
strcpy(DstName, CurrentString);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// options (it may be empty)
|
||||||
|
SkipSpaces ();
|
||||||
|
|
||||||
|
if (CurrentToken != TokenEnd) {
|
||||||
|
j = strlen(CurrentString); i = 0;
|
||||||
|
while ((CurrentChar + i < LineLength) &&
|
||||||
|
((ch = Line[CurrentChar + i]) != ' ') &&
|
||||||
|
(ch != 0x09) &&
|
||||||
|
(ch != ';')) {
|
||||||
|
CurrentString[j + i] = ch;
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
CurrentString[j + i] = '\0';
|
||||||
|
CurrentToken = TokenString;
|
||||||
|
CurrentChar += i + 1;
|
||||||
|
strcpy(Options, CurrentString);
|
||||||
|
}
|
||||||
|
|
||||||
if (!CabinetCreated) {
|
if (!CabinetCreated) {
|
||||||
|
|
||||||
DPRINT(MID_TRACE, ("Creating cabinet.\n"));
|
DPRINT(MID_TRACE, ("Creating cabinet.\n"));
|
||||||
|
@ -1078,25 +1099,34 @@ unsigned long CDFParser::PerformFileCopy()
|
||||||
|
|
||||||
DPRINT(MID_TRACE, ("Adding file: '%s' destination: '%s'.\n", SrcName, DstName));
|
DPRINT(MID_TRACE, ("Adding file: '%s' destination: '%s'.\n", SrcName, DstName));
|
||||||
|
|
||||||
sprintf(InfLine, "%s=%s", GetFileName(SrcName), DstName);
|
|
||||||
WriteInfLine(InfLine);
|
|
||||||
|
|
||||||
Status = AddFile(SrcName);
|
Status = AddFile(SrcName);
|
||||||
if (Status == CAB_STATUS_CANNOT_OPEN) {
|
if (Status == CAB_STATUS_CANNOT_OPEN) {
|
||||||
strcpy(SrcName, FileRelativePath);
|
strcpy(SrcName, FileRelativePath);
|
||||||
strcat(SrcName, BaseFilename);
|
strcat(SrcName, BaseFilename);
|
||||||
Status = AddFile(SrcName);
|
Status = AddFile(SrcName);
|
||||||
}
|
}
|
||||||
if (Status != CAB_STATUS_SUCCESS) {
|
switch (Status)
|
||||||
if (Status == CAB_STATUS_CANNOT_OPEN)
|
{
|
||||||
|
case CAB_STATUS_SUCCESS:
|
||||||
|
sprintf(InfLine, "%s=%s", GetFileName(SrcName), DstName);
|
||||||
|
WriteInfLine(InfLine);
|
||||||
|
break;
|
||||||
|
case CAB_STATUS_CANNOT_OPEN:
|
||||||
|
if (strchr(Options,'o'))
|
||||||
|
{
|
||||||
|
Status = CAB_STATUS_SUCCESS;
|
||||||
|
printf("Optional file does not exist: %s.\n", SrcName);
|
||||||
|
} else {
|
||||||
printf("File does not exist: %s.\n", SrcName);
|
printf("File does not exist: %s.\n", SrcName);
|
||||||
else if (Status == CAB_STATUS_NOMEMORY)
|
|
||||||
printf("Insufficient memory to add file: %s.\n", SrcName);
|
|
||||||
else
|
|
||||||
printf("Cannot add file: %s (%lu).\n", SrcName, Status);
|
|
||||||
return Status;
|
|
||||||
}
|
}
|
||||||
|
break;
|
||||||
|
case CAB_STATUS_NOMEMORY:
|
||||||
|
printf("Insufficient memory to add file: %s.\n", SrcName);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
printf("Cannot add file: %s (%lu).\n", SrcName, Status);
|
||||||
|
break;
|
||||||
|
}
|
||||||
return CAB_STATUS_SUCCESS;
|
return CAB_STATUS_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -553,11 +553,7 @@ int main(int argc, char * argv[])
|
||||||
status = CABMgr.Run();
|
status = CABMgr.Run();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (status) {
|
return (status ? 0 : 1);
|
||||||
return 0;
|
|
||||||
} else {
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* EOF */
|
/* EOF */
|
||||||
|
|
Loading…
Reference in a new issue