Author: cfinck
Date: Tue Feb 5 18:31:12 2008
New Revision: 32139
URL: http://svn.reactos.org/svn/reactos?rev=32139&view=rev
Log:
- Handle the different slashes correctly, also in combination (like "../..\*.txt") by using the ConvertPath() function
- Only compare file names, not the whole pathes, in the Unix code path using MatchFileNamePattern
- Small change to the Usage text
Modified:
trunk/reactos/tools/cabman/cabinet.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 (original)
+++ trunk/reactos/tools/cabman/cabinet.cxx Tue Feb 5 18:31:12 2008
@@ -375,10 +375,10 @@
char* CCabinet::ConvertPath(char* Path, bool Allocate)
/*
- * FUNCTION: Replaces \ or / with the one used be the host environment
+ * FUNCTION: Replaces \ or / with the one used by the host environment
* ARGUMENTS:
* Path = Pointer to string with pathname
- * Allocate = Specifies wther to allocate memory for the new
+ * Allocate = Specifies whether to allocate memory for the new
* string or to change the existing buffer
* RETURNS:
* Pointer to new path
@@ -2100,17 +2100,33 @@
while(Criteria)
{
// Store the file path with a trailing slash in szFilePath
+ ConvertPath(Criteria->Search, false);
+
+#if defined(WIN32)
+ pszFile = strrchr(Criteria->Search, '\\');
+#else
pszFile = strrchr(Criteria->Search, '/');
- if(!pszFile)
- pszFile = strrchr(Criteria->Search, '\\');
+#endif
if(pszFile)
{
- strncpy(szFilePath, Criteria->Search, pszFile - Criteria->Search + 1);
- szFilePath[pszFile - Criteria->Search + 1] = 0;
+ // Set the pointer to the start of the file name, not the slash
+ pszFile++;
+
+ strncpy(szFilePath, Criteria->Search, pszFile - Criteria->Search);
+ szFilePath[pszFile - Criteria->Search] = 0;
}
else
+ {
+ pszFile = Criteria->Search;
+
+#if defined(WIN32)
szFilePath[0] = 0;
+#else
+ // needed for opendir()
+ strcpy(szFilePath, "./");
+#endif
+ }
#if defined(WIN32)
// Windows: Use the easy FindFirstFile/FindNextFile API for getting all files and checking them against the pattern
@@ -2144,9 +2160,6 @@
FindClose(hFind);
#else
// Unix: Use opendir/readdir to loop through all entries, stat to check if it's a file and MatchFileNamePattern to match the file against the pattern
- if(szFilePath[0] == 0)
- strcpy(szFilePath, "./");
-
dirp = opendir(szFilePath);
if(dirp)
@@ -2160,14 +2173,7 @@
{
if(stbuf.st_mode != S_IFDIR)
{
- // As we added "./" to szFilePath above, szFile might contain "./test.txt" now and Criteria->Search "test.txt".
- // Therefore they won't match using MatchFileNamePattern. By using pszFile here, we can avoid this problem.
- if(szFile[0] == '.' && szFile[1] == '/')
- pszFile = szFile + 2;
- else
- pszFile = szFile;
-
- if(MatchFileNamePattern(pszFile, Criteria->Search))
+ if(MatchFileNamePattern(dp->d_name, pszFile))
{
Status = AddFile(szFile);
@@ -2188,7 +2194,6 @@
closedir(dirp);
}
-
#endif
Criteria = Criteria->Next;
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 (original)
+++ trunk/reactos/tools/cabman/main.cxx Tue Feb 5 18:31:12 2008
@@ -192,9 +192,9 @@
printf("ReactOS Cabinet Manager\n\n");
printf("CABMAN [-D | -E] [-A] [-L dir] cabinet [filename ...]\n");
printf("CABMAN [-M mode] -C dirfile [-I] [-RC file] [-P dir]\n");
- printf("CABMAN [-M mode] -S cabinet filename ...\n");
+ printf("CABMAN [-M mode] -S cabinet filename [...]\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 add to or extract from the cabinet.\n");
printf(" Wild cards and multiple filenames\n");
printf(" (separated by blanks) may be used.\n\n");