mirror of
https://github.com/reactos/reactos.git
synced 2025-02-23 17:05:46 +00:00
[CABMAN]
* Show the status messages only in -V mode. * Improve error messages by marking them as ERROR/WARNING. * Brought to you by David Quintana. CORE-7477 #resolve #comment Committed in r60449. Gracias. svn path=/trunk/; revision=60449
This commit is contained in:
parent
8f2aedbc45
commit
f657a0467c
4 changed files with 77 additions and 44 deletions
|
@ -607,7 +607,7 @@ bool CCabinet::SetCompressionCodec(char* CodecName)
|
|||
SelectCodec(CAB_CODEC_MSZIP);
|
||||
else
|
||||
{
|
||||
printf("Invalid codec specified!\n");
|
||||
printf("ERROR: Invalid codec specified!\n");
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
|
@ -24,6 +24,7 @@ public:
|
|||
virtual ~CCABManager();
|
||||
bool ParseCmdline(int argc, char* argv[]);
|
||||
bool Run();
|
||||
bool IsVerbose() { return Verbose; }
|
||||
private:
|
||||
void Usage();
|
||||
bool CreateCabinet();
|
||||
|
@ -39,6 +40,9 @@ private:
|
|||
ULONG Mode;
|
||||
bool PromptOnOverwrite;
|
||||
char FileName[PATH_MAX];
|
||||
bool Verbose;
|
||||
};
|
||||
|
||||
extern CCABManager CABMgr;
|
||||
|
||||
/* EOF */
|
||||
|
|
|
@ -14,7 +14,7 @@
|
|||
*/
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include "cabinet.h"
|
||||
#include "cabman.h"
|
||||
#include "dfp.h"
|
||||
|
||||
|
||||
|
@ -345,7 +345,7 @@ ULONG CDFParser::Parse()
|
|||
|
||||
if (Status == CAB_STATUS_FAILURE)
|
||||
{
|
||||
printf("Directive file contains errors at line %u.\n", (UINT)CurrentLine);
|
||||
printf("ERROR: Directive file contains errors at line %u.\n", (UINT)CurrentLine);
|
||||
DPRINT(MID_TRACE, ("Error while executing command.\n"));
|
||||
}
|
||||
|
||||
|
@ -359,7 +359,7 @@ ULONG CDFParser::Parse()
|
|||
|
||||
if (Status != CAB_STATUS_SUCCESS)
|
||||
{
|
||||
printf("Directive file contains errors at line %u.\n", (UINT)CurrentLine);
|
||||
printf("ERROR: Directive file contains errors at line %u.\n", (UINT)CurrentLine);
|
||||
DPRINT(MID_TRACE, ("Error while copying file.\n"));
|
||||
}
|
||||
|
||||
|
@ -380,7 +380,7 @@ ULONG CDFParser::Parse()
|
|||
break;
|
||||
|
||||
default:
|
||||
printf("Directive file contains errors at line %u.\n", (UINT)CurrentLine);
|
||||
printf("ERROR: Directive file contains errors at line %u.\n", (UINT)CurrentLine);
|
||||
DPRINT(MID_TRACE, ("Token is (%u).\n", (UINT)CurrentToken));
|
||||
return CAB_STATUS_SUCCESS;
|
||||
}
|
||||
|
@ -391,7 +391,10 @@ ULONG CDFParser::Parse()
|
|||
|
||||
if (!InfFileOnly)
|
||||
{
|
||||
printf("\nWriting cabinet. This may take a while...\n\n");
|
||||
if (CABMgr.IsVerbose())
|
||||
{
|
||||
printf("Writing cabinet. This may take a while...\n");
|
||||
}
|
||||
|
||||
if (DiskCreated)
|
||||
{
|
||||
|
@ -415,7 +418,10 @@ ULONG CDFParser::Parse()
|
|||
}
|
||||
}
|
||||
|
||||
printf("\nDone.\n");
|
||||
if (CABMgr.IsVerbose())
|
||||
{
|
||||
printf("Done.\n");
|
||||
}
|
||||
}
|
||||
|
||||
return CAB_STATUS_SUCCESS;
|
||||
|
@ -1181,7 +1187,7 @@ ULONG CDFParser::PerformFileCopy()
|
|||
if (Status != CAB_STATUS_SUCCESS)
|
||||
{
|
||||
DPRINT(MIN_TRACE, ("Cannot create cabinet (%u).\n", (UINT)Status));
|
||||
printf("Cannot create cabinet.\n");
|
||||
printf("ERROR: Cannot create cabinet.\n");
|
||||
return CAB_STATUS_FAILURE;
|
||||
}
|
||||
CabinetCreated = true;
|
||||
|
@ -1192,7 +1198,7 @@ ULONG CDFParser::PerformFileCopy()
|
|||
if (Status != CAB_STATUS_SUCCESS)
|
||||
{
|
||||
DPRINT(MIN_TRACE, ("Cannot create disk (%u).\n", (UINT)Status));
|
||||
printf("Cannot create disk.\n");
|
||||
printf("ERROR: Cannot create disk.\n");
|
||||
return CAB_STATUS_FAILURE;
|
||||
}
|
||||
DiskCreated = true;
|
||||
|
@ -1219,19 +1225,19 @@ ULONG CDFParser::PerformFileCopy()
|
|||
if (strstr(Options,"optional"))
|
||||
{
|
||||
Status = CAB_STATUS_SUCCESS;
|
||||
printf("Optional file does not exist: %s.\n", SrcName);
|
||||
printf("Optional file skipped (does not exist): %s.\n", SrcName);
|
||||
}
|
||||
else
|
||||
printf("File does not exist: %s.\n", SrcName);
|
||||
printf("ERROR: File not found: %s.\n", SrcName);
|
||||
|
||||
break;
|
||||
|
||||
case CAB_STATUS_NOMEMORY:
|
||||
printf("Insufficient memory to add file: %s.\n", SrcName);
|
||||
printf("ERROR: Insufficient memory to add file: %s.\n", SrcName);
|
||||
break;
|
||||
|
||||
default:
|
||||
printf("Cannot add file: %s (%u).\n", SrcName, (UINT)Status);
|
||||
printf("ERROR: Cannot add file: %s (%u).\n", SrcName, (UINT)Status);
|
||||
break;
|
||||
}
|
||||
return Status;
|
||||
|
|
|
@ -173,6 +173,7 @@ CCABManager::CCABManager()
|
|||
InfFileOnly = false;
|
||||
Mode = CM_MODE_DISPLAY;
|
||||
FileName[0] = 0;
|
||||
Verbose = false;
|
||||
}
|
||||
|
||||
|
||||
|
@ -215,7 +216,8 @@ void CCABManager::Usage()
|
|||
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(" -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");
|
||||
printf(" -V Verbose mode (prints more messages).\n");
|
||||
}
|
||||
|
||||
bool CCABManager::ParseCmdline(int argc, char* argv[])
|
||||
|
@ -309,7 +311,7 @@ bool CCABManager::ParseCmdline(int argc, char* argv[])
|
|||
i++;
|
||||
if (!SetCabinetReservedFile(&argv[i][0]))
|
||||
{
|
||||
printf("Cannot open cabinet reserved area file.\n");
|
||||
printf("ERROR: Cannot open cabinet reserved area file.\n");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
@ -317,14 +319,14 @@ bool CCABManager::ParseCmdline(int argc, char* argv[])
|
|||
{
|
||||
if (!SetCabinetReservedFile(&argv[i][3]))
|
||||
{
|
||||
printf("Cannot open cabinet reserved area file.\n");
|
||||
printf("ERROR: Cannot open cabinet reserved area file.\n");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
printf("Bad parameter %s.\n", argv[i]);
|
||||
printf("ERROR: Bad parameter %s.\n", argv[i]);
|
||||
return false;
|
||||
}
|
||||
break;
|
||||
|
@ -344,9 +346,13 @@ bool CCABManager::ParseCmdline(int argc, char* argv[])
|
|||
SetFileRelativePath(&argv[i][2]);
|
||||
|
||||
break;
|
||||
|
||||
case 'V':
|
||||
Verbose = true;
|
||||
break;
|
||||
|
||||
default:
|
||||
printf("Bad parameter %s.\n", argv[i]);
|
||||
printf("ERROR: Bad parameter %s.\n", argv[i]);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
@ -356,7 +362,7 @@ bool CCABManager::ParseCmdline(int argc, char* argv[])
|
|||
{
|
||||
if(FileName[0])
|
||||
{
|
||||
printf("You may only specify one directive file!\n");
|
||||
printf("ERROR: You may only specify one directive file!\n");
|
||||
return false;
|
||||
}
|
||||
else
|
||||
|
@ -391,7 +397,7 @@ bool CCABManager::ParseCmdline(int argc, char* argv[])
|
|||
// Search criteria (= the filename argument) is necessary for creating a simple cabinet
|
||||
if( Mode == CM_MODE_CREATE_SIMPLE && !HasSearchCriteria())
|
||||
{
|
||||
printf("You have to enter input file names!\n");
|
||||
printf("ERROR: You have to enter input file names!\n");
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -409,7 +415,7 @@ bool CCABManager::CreateCabinet()
|
|||
Status = Load(FileName);
|
||||
if (Status != CAB_STATUS_SUCCESS)
|
||||
{
|
||||
printf("Specified directive file could not be found: %s.\n", FileName);
|
||||
printf("ERROR: Specified directive file could not be found: %s.\n", FileName);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -430,7 +436,10 @@ bool CCABManager::DisplayCabinet()
|
|||
|
||||
if (Open() == CAB_STATUS_SUCCESS)
|
||||
{
|
||||
printf("Cabinet %s\n\n", GetCabinetName());
|
||||
if (Verbose)
|
||||
{
|
||||
printf("Cabinet %s\n\n", GetCabinetName());
|
||||
}
|
||||
|
||||
if (FindFirst(&Search) == CAB_STATUS_SUCCESS)
|
||||
{
|
||||
|
@ -473,12 +482,12 @@ bool CCABManager::DisplayCabinet()
|
|||
else
|
||||
{
|
||||
/* There should be at least one file in a cabinet */
|
||||
printf("No files in cabinet.");
|
||||
printf("WARNING: No files in cabinet.");
|
||||
}
|
||||
return true;
|
||||
}
|
||||
else
|
||||
printf("Cannot open file: %s\n", GetCabinetName());
|
||||
printf("ERROR: Cannot open file: %s\n", GetCabinetName());
|
||||
|
||||
return false;
|
||||
}
|
||||
|
@ -495,7 +504,10 @@ bool CCABManager::ExtractFromCabinet()
|
|||
|
||||
if (Open() == CAB_STATUS_SUCCESS)
|
||||
{
|
||||
printf("Cabinet %s\n\n", GetCabinetName());
|
||||
if (Verbose)
|
||||
{
|
||||
printf("Cabinet %s\n\n", GetCabinetName());
|
||||
}
|
||||
|
||||
if (FindFirst(&Search) == CAB_STATUS_SUCCESS)
|
||||
{
|
||||
|
@ -507,22 +519,22 @@ bool CCABManager::ExtractFromCabinet()
|
|||
break;
|
||||
|
||||
case CAB_STATUS_INVALID_CAB:
|
||||
printf("Cabinet contains errors.\n");
|
||||
printf("ERROR: Cabinet contains errors.\n");
|
||||
bRet = false;
|
||||
break;
|
||||
|
||||
case CAB_STATUS_UNSUPPCOMP:
|
||||
printf("Cabinet uses unsupported compression type.\n");
|
||||
printf("ERROR: Cabinet uses unsupported compression type.\n");
|
||||
bRet = false;
|
||||
break;
|
||||
|
||||
case CAB_STATUS_CANNOT_WRITE:
|
||||
printf("You've run out of free space on the destination volume or the volume is damaged.\n");
|
||||
printf("ERROR: You've run out of free space on the destination volume or the volume is damaged.\n");
|
||||
bRet = false;
|
||||
break;
|
||||
|
||||
default:
|
||||
printf("Unspecified error code (%u).\n", (UINT)Status);
|
||||
printf("ERROR: Unspecified error code (%u).\n", (UINT)Status);
|
||||
bRet = false;
|
||||
break;
|
||||
}
|
||||
|
@ -537,7 +549,7 @@ bool CCABManager::ExtractFromCabinet()
|
|||
return bRet;
|
||||
}
|
||||
else
|
||||
printf("Cannot open file: %s.\n", GetCabinetName());
|
||||
printf("ERROR: Cannot open file: %s.\n", GetCabinetName());
|
||||
|
||||
return false;
|
||||
}
|
||||
|
@ -548,7 +560,10 @@ bool CCABManager::Run()
|
|||
* FUNCTION: Process cabinet
|
||||
*/
|
||||
{
|
||||
printf("ReactOS Cabinet Manager\n\n");
|
||||
if (Verbose)
|
||||
{
|
||||
printf("ReactOS Cabinet Manager\n\n");
|
||||
}
|
||||
|
||||
switch (Mode)
|
||||
{
|
||||
|
@ -601,21 +616,27 @@ void CCABManager::OnExtract(PCFFILE File,
|
|||
* FileName = Pointer to buffer with name of file (full path)
|
||||
*/
|
||||
{
|
||||
printf("Extracting %s\n", GetFileName(FileName));
|
||||
if (Verbose)
|
||||
{
|
||||
printf("Extracting %s\n", GetFileName(FileName));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
void CCABManager::OnDiskChange(char* CabinetName,
|
||||
char* DiskLabel)
|
||||
/*
|
||||
* FUNCTION: Called when a new disk is to be processed
|
||||
* ARGUMENTS:
|
||||
* CabinetName = Pointer to buffer with name of cabinet
|
||||
* DiskLabel = Pointer to buffer with label of disk
|
||||
*/
|
||||
char* DiskLabel)
|
||||
/*
|
||||
* FUNCTION: Called when a new disk is to be processed
|
||||
* ARGUMENTS:
|
||||
* CabinetName = Pointer to buffer with name of cabinet
|
||||
* DiskLabel = Pointer to buffer with label of disk
|
||||
*/
|
||||
{
|
||||
printf("\nChanging to cabinet %s - %s\n\n", CabinetName, DiskLabel);
|
||||
if (Verbose)
|
||||
{
|
||||
printf("\nChanging to cabinet %s - %s\n\n", CabinetName, DiskLabel);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -628,9 +649,13 @@ void CCABManager::OnAdd(PCFFILE File,
|
|||
* FileName = Pointer to buffer with name of file (full path)
|
||||
*/
|
||||
{
|
||||
printf("Adding %s\n", GetFileName(FileName));
|
||||
if (Verbose)
|
||||
{
|
||||
printf("Adding %s\n", GetFileName(FileName));
|
||||
}
|
||||
}
|
||||
|
||||
CCABManager CABMgr;
|
||||
|
||||
int main(int argc, char * argv[])
|
||||
/*
|
||||
|
@ -640,11 +665,9 @@ int main(int argc, char * argv[])
|
|||
* argv = Pointer to list of command line arguments
|
||||
*/
|
||||
{
|
||||
CCABManager CABMgr;
|
||||
bool status = false;
|
||||
|
||||
if (CABMgr.ParseCmdline(argc, argv))
|
||||
status = CABMgr.Run();
|
||||
if (CABMgr.ParseCmdline(argc, argv)) status = CABMgr.Run();
|
||||
|
||||
return (status ? 0 : 1);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue