mirror of
https://github.com/reactos/reactos.git
synced 2025-04-22 13:10:39 +00:00
- 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 svn path=/trunk/; revision=32139
This commit is contained in:
parent
faa96fba14
commit
ed5e6ac231
2 changed files with 25 additions and 20 deletions
|
@ -375,10 +375,10 @@ bool CCabinet::IsSeparator(char Char)
|
||||||
|
|
||||||
char* CCabinet::ConvertPath(char* Path, bool Allocate)
|
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:
|
* ARGUMENTS:
|
||||||
* Path = Pointer to string with pathname
|
* 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
|
* string or to change the existing buffer
|
||||||
* RETURNS:
|
* RETURNS:
|
||||||
* Pointer to new path
|
* Pointer to new path
|
||||||
|
@ -2100,17 +2100,33 @@ bool CCabinet::CreateSimpleCabinet()
|
||||||
while(Criteria)
|
while(Criteria)
|
||||||
{
|
{
|
||||||
// Store the file path with a trailing slash in szFilePath
|
// 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, '/');
|
pszFile = strrchr(Criteria->Search, '/');
|
||||||
if(!pszFile)
|
#endif
|
||||||
pszFile = strrchr(Criteria->Search, '\\');
|
|
||||||
|
|
||||||
if(pszFile)
|
if(pszFile)
|
||||||
{
|
{
|
||||||
strncpy(szFilePath, Criteria->Search, pszFile - Criteria->Search + 1);
|
// Set the pointer to the start of the file name, not the slash
|
||||||
szFilePath[pszFile - Criteria->Search + 1] = 0;
|
pszFile++;
|
||||||
|
|
||||||
|
strncpy(szFilePath, Criteria->Search, pszFile - Criteria->Search);
|
||||||
|
szFilePath[pszFile - Criteria->Search] = 0;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
{
|
||||||
|
pszFile = Criteria->Search;
|
||||||
|
|
||||||
|
#if defined(WIN32)
|
||||||
szFilePath[0] = 0;
|
szFilePath[0] = 0;
|
||||||
|
#else
|
||||||
|
// needed for opendir()
|
||||||
|
strcpy(szFilePath, "./");
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
#if defined(WIN32)
|
#if defined(WIN32)
|
||||||
// Windows: Use the easy FindFirstFile/FindNextFile API for getting all files and checking them against the pattern
|
// Windows: Use the easy FindFirstFile/FindNextFile API for getting all files and checking them against the pattern
|
||||||
|
@ -2144,9 +2160,6 @@ bool CCabinet::CreateSimpleCabinet()
|
||||||
FindClose(hFind);
|
FindClose(hFind);
|
||||||
#else
|
#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
|
// 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);
|
dirp = opendir(szFilePath);
|
||||||
|
|
||||||
if(dirp)
|
if(dirp)
|
||||||
|
@ -2160,14 +2173,7 @@ bool CCabinet::CreateSimpleCabinet()
|
||||||
{
|
{
|
||||||
if(stbuf.st_mode != S_IFDIR)
|
if(stbuf.st_mode != S_IFDIR)
|
||||||
{
|
{
|
||||||
// As we added "./" to szFilePath above, szFile might contain "./test.txt" now and Criteria->Search "test.txt".
|
if(MatchFileNamePattern(dp->d_name, pszFile))
|
||||||
// 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))
|
|
||||||
{
|
{
|
||||||
Status = AddFile(szFile);
|
Status = AddFile(szFile);
|
||||||
|
|
||||||
|
@ -2188,7 +2194,6 @@ bool CCabinet::CreateSimpleCabinet()
|
||||||
|
|
||||||
closedir(dirp);
|
closedir(dirp);
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
Criteria = Criteria->Next;
|
Criteria = Criteria->Next;
|
||||||
|
|
|
@ -192,9 +192,9 @@ void CCABManager::Usage()
|
||||||
printf("ReactOS Cabinet Manager\n\n");
|
printf("ReactOS Cabinet Manager\n\n");
|
||||||
printf("CABMAN [-D | -E] [-A] [-L dir] cabinet [filename ...]\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] -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(" 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(" Wild cards and multiple filenames\n");
|
||||||
printf(" (separated by blanks) may be used.\n\n");
|
printf(" (separated by blanks) may be used.\n\n");
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue