Author: akhaldi
Date: Sun Sep 29 14:48:37 2013
New Revision: 60449
URL:
http://svn.reactos.org/svn/reactos?rev=60449&view=rev
Log:
[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.
Modified:
trunk/reactos/tools/cabman/cabinet.cxx
trunk/reactos/tools/cabman/cabman.h
trunk/reactos/tools/cabman/dfp.cxx
trunk/reactos/tools/cabman/main.cxx
Modified: trunk/reactos/tools/cabman/cabinet.cxx
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/tools/cabman/cabinet.cxx?r…
==============================================================================
--- trunk/reactos/tools/cabman/cabinet.cxx [iso-8859-1] (original)
+++ trunk/reactos/tools/cabman/cabinet.cxx [iso-8859-1] Sun Sep 29 14:48:37 2013
@@ -607,7 +607,7 @@
SelectCodec(CAB_CODEC_MSZIP);
else
{
- printf("Invalid codec specified!\n");
+ printf("ERROR: Invalid codec specified!\n");
return false;
}
Modified: trunk/reactos/tools/cabman/cabman.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/tools/cabman/cabman.h?rev=…
==============================================================================
--- trunk/reactos/tools/cabman/cabman.h [iso-8859-1] (original)
+++ trunk/reactos/tools/cabman/cabman.h [iso-8859-1] Sun Sep 29 14:48:37 2013
@@ -24,6 +24,7 @@
virtual ~CCABManager();
bool ParseCmdline(int argc, char* argv[]);
bool Run();
+ bool IsVerbose() { return Verbose; }
private:
void Usage();
bool CreateCabinet();
@@ -39,6 +40,9 @@
ULONG Mode;
bool PromptOnOverwrite;
char FileName[PATH_MAX];
+ bool Verbose;
};
+extern CCABManager CABMgr;
+
/* EOF */
Modified: trunk/reactos/tools/cabman/dfp.cxx
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/tools/cabman/dfp.cxx?rev=6…
==============================================================================
--- trunk/reactos/tools/cabman/dfp.cxx [iso-8859-1] (original)
+++ trunk/reactos/tools/cabman/dfp.cxx [iso-8859-1] Sun Sep 29 14:48:37 2013
@@ -14,7 +14,7 @@
*/
#include <stdlib.h>
#include <stdio.h>
-#include "cabinet.h"
+#include "cabman.h"
#include "dfp.h"
@@ -345,7 +345,7 @@
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 @@
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 @@
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 @@
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 @@
}
}
- printf("\nDone.\n");
+ if (CABMgr.IsVerbose())
+ {
+ printf("Done.\n");
+ }
}
return CAB_STATUS_SUCCESS;
@@ -1181,7 +1187,7 @@
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 @@
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 @@
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;
Modified: trunk/reactos/tools/cabman/main.cxx
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/tools/cabman/main.cxx?rev=…
==============================================================================
--- trunk/reactos/tools/cabman/main.cxx [iso-8859-1] (original)
+++ trunk/reactos/tools/cabman/main.cxx [iso-8859-1] Sun Sep 29 14:48:37 2013
@@ -173,6 +173,7 @@
InfFileOnly = false;
Mode = CM_MODE_DISPLAY;
FileName[0] = 0;
+ Verbose = false;
}
@@ -215,7 +216,8 @@
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 @@
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 @@
{
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 @@
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 @@
{
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 @@
// 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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
return bRet;
}
else
- printf("Cannot open file: %s.\n", GetCabinetName());
+ printf("ERROR: Cannot open file: %s.\n", GetCabinetName());
return false;
}
@@ -548,7 +560,10 @@
* FUNCTION: Process cabinet
*/
{
- printf("ReactOS Cabinet Manager\n\n");
+ if (Verbose)
+ {
+ printf("ReactOS Cabinet Manager\n\n");
+ }
switch (Mode)
{
@@ -601,21 +616,27 @@
* 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
- */
-{
- printf("\nChanging to cabinet %s - %s\n\n", CabinetName, DiskLabel);
+ 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
+ */
+{
+ if (Verbose)
+ {
+ printf("\nChanging to cabinet %s - %s\n\n", CabinetName, DiskLabel);
+ }
}
@@ -628,9 +649,13 @@
* 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 @@
* 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);
}