Permalink
Browse files

Merged with UnRAR 3.9.10 (RAR 3.9.3).

git-svn-id: http://svn.php.net/repository/pecl/rar/trunk@298232 c90b9560-bf6c-de11-be94-00142212c4b1
  • Loading branch information...
cataphract
cataphract committed Apr 20, 2010
1 parent 0f76b93 commit 8f206263cbaed82e034eea17f4b3c499862671ce
Showing with 172 additions and 80 deletions.
  1. +2 −1 php_rar.h
  2. +1 −1 rar.c
  3. +1 −1 unrar/LICENSE.txt
  4. +28 −0 unrar/cmddata.cpp
  5. +1 −1 unrar/cmddata.hpp
  6. +1 −1 unrar/errhnd.cpp
  7. +18 −11 unrar/filcreat.cpp
  8. +2 −2 unrar/file.cpp
  9. +52 −24 unrar/match.cpp
  10. +19 −11 unrar/match.hpp
  11. +4 −0 unrar/os.hpp
  12. +1 −5 unrar/scantree.cpp
  13. +38 −19 unrar/unpack.cpp
  14. +1 −0 unrar/unpack.hpp
  15. +3 −3 unrar/version.hpp
View
@@ -33,7 +33,8 @@
extern zend_module_entry rar_module_entry;
#define phpext_rar_ptr &rar_module_entry
-#define PHP_RAR_VERSION "2.0.0-dev"
+#define PHP_RAR_VERSION "2.1.0-dev"
+#define PHP_RAR_REVISION "$Revision$"
#ifdef PHP_WIN32
#define PHP_RAR_API __declspec(dllexport)
View
2 rar.c
@@ -321,7 +321,7 @@ PHP_MINFO_FUNCTION(rar)
php_info_print_table_start();
php_info_print_table_header(2, "Rar support", "enabled");
php_info_print_table_row(2, "Rar EXT version", PHP_RAR_VERSION);
- php_info_print_table_row(2, "Revision", "$Revision$");
+ php_info_print_table_row(2, "Revision", PHP_RAR_REVISION);
#if RARVER_BETA != 0
sprintf(version,"%d.%02d beta%d patch%d %d-%d-%d", RARVER_MAJOR,
View
@@ -1,4 +1,4 @@
- ****** ***** ****** UnRAR - free utility for RAR archives
+ ****** ***** ****** UnRAR - free utility for RAR archives
** ** ** ** ** ** ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
****** ******* ****** License for use and distribution of
** ** ** ** ** ** ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
View
@@ -1054,6 +1054,34 @@ bool CommandData::ExclCheck(char *CheckName,bool CheckFullPath,bool CheckInclLis
}
+// Return 'true' if we need to exclude the directory from archiving as result
+// of -x switch. We do not want -x*. switch to exclude all directories,
+// so when archiving we process exclusion arguments for directories specially.
+bool CommandData::ExclCheckDir(char *CheckName)
+{
+ // If exclusion mask and directory name match exactly, return true.
+ if (ExclCheckArgs(ExclArgs,CheckName,true,MATCH_EXACT))
+ return(true);
+
+ // Now we want to allow wildcards in exclusion mask only if it has
+ // '\' at the end. So 'dir*\' will exclude all dir* directories.
+ // We append '\' to directory name, so it will match only masks having
+ // '\' at the end.
+ char DirName[NM+1];
+ ConvertPath(CheckName,DirName);
+ AddEndSlash(DirName);
+
+ char *CurMask;
+ ExclArgs->Rewind();
+ while ((CurMask=ExclArgs->GetString())!=NULL)
+ if (IsPathDiv(*PointToLastChar(CurMask)))
+ if (CmpName(CurMask,DirName,MATCH_SUBPATH))
+ return(true);
+
+ return(false);
+}
+
+
#ifndef SFX_MODULE
View
@@ -29,7 +29,7 @@ class CommandData:public RAROptions
void OutHelp();
bool IsSwitch(int Ch);
bool ExclCheck(char *CheckName,bool CheckFullPath,bool CheckInclList);
- bool StoreCheck(char *CheckName);
+ bool ExclCheckDir(char *CheckName);
bool TimeCheck(RarTime &ft);
bool SizeCheck(int64 Size);
bool AnyFiltersActive();
View
@@ -288,7 +288,7 @@ void _stdfunction ProcessSignal(int SigType)
Sleep(100);
#endif
}
-#if defined(USE_RC) && !defined(SFX_MODULE) && !defined(_WIN_CE)
+#if defined(USE_RC) && !defined(SFX_MODULE) && !defined(_WIN_CE) && !defined(RARDLL)
ExtRes.UnloadDLL();
#endif
exit(USER_BREAK);
View
@@ -25,11 +25,29 @@ bool FileCreate(RAROptions *Cmd,File *NewFile,char *Name,wchar *NameW,
*UserReject=true;
return(false);
}
+
+ // Must be before Cmd->AllYes check or -y switch would override -or.
+ if (Mode==OVERWRITE_AUTORENAME)
+ {
+ if (GetAutoRenamedName(Name))
+ {
+ if (NameW!=NULL)
+ *NameW=0;
+ }
+ else
+ Mode=OVERWRITE_DEFAULT;
+ continue;
+ }
+
#ifdef SILENT
Mode=OVERWRITE_ALL;
#endif
+
+ // This check must be after OVERWRITE_AUTORENAME processing or -y switch
+ // would override -or.
if (Cmd->AllYes || Mode==OVERWRITE_ALL)
break;
+
if (Mode==OVERWRITE_DEFAULT || Mode==OVERWRITE_FORCE_ASK)
{
eprintf(St(MFileExists),Name);
@@ -86,17 +104,6 @@ bool FileCreate(RAROptions *Cmd,File *NewFile,char *Name,wchar *NameW,
if (Choice==6)
ErrHandler.Exit(USER_BREAK);
}
- if (Mode==OVERWRITE_AUTORENAME)
- {
- if (GetAutoRenamedName(Name))
- {
- if (NameW!=NULL)
- *NameW=0;
- }
- else
- Mode=OVERWRITE_DEFAULT;
- continue;
- }
}
if (NewFile!=NULL && NewFile->Create(Name,NameW))
return(true);
View
@@ -303,11 +303,11 @@ void File::Write(const void *Data,size_t Size)
// writing to stdout can fail in old Windows if data block is too large
const size_t MaxSize=0x4000;
for (size_t I=0;I<Size;I+=MaxSize)
- {
+ {
Success=WriteFile(hFile,(byte *)Data+I,(DWORD)Min(Size-I,MaxSize),&Written,NULL)==TRUE;
if (!Success)
break;
- }
+ }
}
else
Success=WriteFile(hFile,Data,(DWORD)Size,&Written,NULL)==TRUE;
View
@@ -34,33 +34,40 @@ inline uint touppercw(uint ch,bool ForceCase)
}
-bool CmpName(char *Wildcard,char *Name,int CmpPath)
+bool CmpName(char *Wildcard,char *Name,int CmpMode)
{
- bool ForceCase=(CmpPath&MATCH_FORCECASESENSITIVE)!=0;
+ bool ForceCase=(CmpMode&MATCH_FORCECASESENSITIVE)!=0;
- CmpPath&=MATCH_MODEMASK;
+ CmpMode&=MATCH_MODEMASK;
- if (CmpPath!=MATCH_NAMES)
+ if (CmpMode!=MATCH_NAMES)
{
size_t WildLength=strlen(Wildcard);
- if (CmpPath!=MATCH_EXACTPATH && mstrnicompc(Wildcard,Name,WildLength,ForceCase)==0)
+ if (CmpMode!=MATCH_EXACT && CmpMode!=MATCH_EXACTPATH &&
+ mstrnicompc(Wildcard,Name,WildLength,ForceCase)==0)
{
+ // For all modes except MATCH_NAMES, MATCH_EXACT and MATCH_EXACTPATH
+ // "path1" mask must match "path1\path2\filename.ext" and "path1" names.
char NextCh=Name[WildLength];
if (NextCh=='\\' || NextCh=='/' || NextCh==0)
return(true);
+
+ // Nothing more to compare for MATCH_SUBPATHONLY.
+ if (CmpMode==MATCH_SUBPATHONLY)
+ return(false);
}
char Path1[NM],Path2[NM];
GetFilePath(Wildcard,Path1,ASIZE(Path1));
GetFilePath(Name,Path2,ASIZE(Path1));
- if (mstricompc(Wildcard,Path2,ForceCase)==0)
- return(true);
- if ((CmpPath==MATCH_PATH || CmpPath==MATCH_EXACTPATH) && mstricompc(Path1,Path2,ForceCase)!=0)
+
+ if ((CmpMode==MATCH_EXACT || CmpMode==MATCH_EXACTPATH) &&
+ mstricompc(Path1,Path2,ForceCase)!=0)
return(false);
- if (CmpPath==MATCH_SUBPATH || CmpPath==MATCH_WILDSUBPATH)
+ if (CmpMode==MATCH_SUBPATH || CmpMode==MATCH_WILDSUBPATH)
if (IsWildcard(Path1))
return(match(Wildcard,Name,ForceCase));
else
- if (CmpPath==MATCH_SUBPATH || IsWildcard(Wildcard))
+ if (CmpMode==MATCH_SUBPATH || IsWildcard(Wildcard))
{
if (*Path1 && mstrnicompc(Path1,Path2,strlen(Path1),ForceCase)!=0)
return(false);
@@ -72,41 +79,53 @@ bool CmpName(char *Wildcard,char *Name,int CmpPath)
char *Name1=PointToName(Wildcard);
char *Name2=PointToName(Name);
- // always return false for RAR temporary files to exclude them
- // from archiving operations
+ // Always return false for RAR temporary files to exclude them
+ // from archiving operations.
if (mstrnicompc("__rar_",Name2,6,false)==0)
return(false);
+ if (CmpMode==MATCH_EXACT)
+ return(mstricompc(Name1,Name2,ForceCase)==0);
+
return(match(Name1,Name2,ForceCase));
}
#ifndef SFX_MODULE
-bool CmpName(wchar *Wildcard,wchar *Name,int CmpPath)
+bool CmpName(wchar *Wildcard,wchar *Name,int CmpMode)
{
- bool ForceCase=(CmpPath&MATCH_FORCECASESENSITIVE)!=0;
+ bool ForceCase=(CmpMode&MATCH_FORCECASESENSITIVE)!=0;
- CmpPath&=MATCH_MODEMASK;
+ CmpMode&=MATCH_MODEMASK;
- if (CmpPath!=MATCH_NAMES)
+ if (CmpMode!=MATCH_NAMES)
{
size_t WildLength=strlenw(Wildcard);
- if (CmpPath!=MATCH_EXACTPATH && mstrnicompcw(Wildcard,Name,WildLength,ForceCase)==0)
+ if (CmpMode!=MATCH_EXACT && CmpMode!=MATCH_EXACTPATH &&
+ mstrnicompcw(Wildcard,Name,WildLength,ForceCase)==0)
{
+ // For all modes except MATCH_NAMES, MATCH_EXACT and MATCH_EXACTPATH
+ // "path1" mask must match "path1\path2\filename.ext" and "path1" names.
wchar NextCh=Name[WildLength];
if (NextCh==L'\\' || NextCh==L'/' || NextCh==0)
return(true);
+
+ // Nothing more to compare for MATCH_SUBPATHONLY.
+ if (CmpMode==MATCH_SUBPATHONLY)
+ return(false);
}
wchar Path1[NM],Path2[NM];
GetFilePath(Wildcard,Path1,ASIZE(Path1));
GetFilePath(Name,Path2,ASIZE(Path2));
- if ((CmpPath==MATCH_PATH || CmpPath==MATCH_EXACTPATH) && mstricompcw(Path1,Path2,ForceCase)!=0)
+
+ if ((CmpMode==MATCH_EXACT || CmpMode==MATCH_EXACTPATH) &&
+ mstricompcw(Path1,Path2,ForceCase)!=0)
return(false);
- if (CmpPath==MATCH_SUBPATH || CmpPath==MATCH_WILDSUBPATH)
+ if (CmpMode==MATCH_SUBPATH || CmpMode==MATCH_WILDSUBPATH)
if (IsWildcard(NULL,Path1))
return(match(Wildcard,Name,ForceCase));
else
- if (CmpPath==MATCH_SUBPATH || IsWildcard(NULL,Wildcard))
+ if (CmpMode==MATCH_SUBPATH || IsWildcard(NULL,Wildcard))
{
if (*Path1 && mstrnicompcw(Path1,Path2,strlenw(Path1),ForceCase)!=0)
return(false);
@@ -118,11 +137,14 @@ bool CmpName(wchar *Wildcard,wchar *Name,int CmpPath)
wchar *Name1=PointToName(Wildcard);
wchar *Name2=PointToName(Name);
- // always return false for RAR temporary files to exclude them
- // from archiving operations
+ // Always return false for RAR temporary files to exclude them
+ // from archiving operations.
if (mstrnicompcw(L"__rar_",Name2,6,false)==0)
return(false);
+ if (CmpMode==MATCH_EXACT)
+ return(mstricompcw(Name1,Name2,ForceCase)==0);
+
return(match(Name1,Name2,ForceCase));
}
#endif
@@ -166,10 +188,13 @@ bool match(char *pattern,char *string,bool ForceCase)
return(false);
default:
if (patternc != stringc)
- if (patternc=='.' && stringc==0)
+ {
+ // Allow "name." mask match "name" and "name.\" match "name\".
+ if (patternc=='.' && (stringc==0 || stringc=='\\' || stringc=='.'))
return(match(pattern,string,ForceCase));
else
return(false);
+ }
break;
}
}
@@ -215,10 +240,13 @@ bool match(wchar *pattern,wchar *string,bool ForceCase)
return(false);
default:
if (patternc != stringc)
- if (patternc=='.' && stringc==0)
+ {
+ // Allow "name." mask match "name" and "name.\" match "name\".
+ if (patternc=='.' && (stringc==0 || stringc=='\\' || stringc=='.'))
return(match(pattern,string,ForceCase));
else
return(false);
+ }
break;
}
}
View
@@ -2,26 +2,34 @@
#define _RAR_MATCH_
enum {
- MATCH_NAMES, // Compare names only.
+ MATCH_NAMES, // Paths are ignored.
+ // Compares names only using wildcards.
- MATCH_PATH, // Compares names and paths. Both must match exactly.
- // Unlike MATCH_EXACTPATH, also matches names if
- // mask contains path only and this path is a part
- // of name path.
+ MATCH_SUBPATHONLY, // Paths must match either exactly or path in wildcard
+ // must be present in the beginning of file path.
+ // For example, "c:\path1\*" or "c:\path1" will match
+ // "c:\path1\path2\file".
+ // Names are not compared.
- MATCH_EXACTPATH, // Compares names and paths. Both must match exactly.
+ MATCH_EXACT, // Paths must match exactly.
+ // Names must match exactly.
+
+ MATCH_EXACTPATH, // Paths must match exactly.
+ // Names are compared using wildcards.
MATCH_SUBPATH, // Names must be the same, but path in mask is allowed
- // to be only a part of name path.
+ // to be only a part of name path. In other words,
+ // we match all files matching the file mask
+ // in current folder and subfolders.
- MATCH_WILDSUBPATH // Works as MATCH_SUBPATH if mask contains wildcards
- // and as MATCH_PATH otherwise.
+ MATCH_WILDSUBPATH // Works as MATCH_SUBPATH if file mask contains
+ // wildcards and as MATCH_EXACTPATH otherwise.
};
#define MATCH_MODEMASK 0x0000ffff
#define MATCH_FORCECASESENSITIVE 0x80000000
-bool CmpName(char *Wildcard,char *Name,int CmpPath);
-bool CmpName(wchar *Wildcard,wchar *Name,int CmpPath);
+bool CmpName(char *Wildcard,char *Name,int CmpMode);
+bool CmpName(wchar *Wildcard,wchar *Name,int CmpMode);
#endif
View
@@ -8,6 +8,10 @@
#define INCL_BASE
#endif
+#if defined(RARDLL) && !defined(SILENT)
+#define SILENT
+#endif
+
#if defined(_WIN_32) || defined(_EMX)
#define ENABLE_BAD_ALLOC
#endif
View
@@ -309,11 +309,7 @@ SCAN_CODE ScanTree::FindProc(FindData *FindData)
// Let's check if directory name is excluded, so we do not waste
// time searching in directory, which will be excluded anyway.
- // We set CheckInclList parameter of ExclCheck to 'true' to ignore
- // the inclusion list here. We do it to correctly handle the situation,
- // when a user added files in the directory to inclusion list,
- // but did not add their parent directory to this list.
- if (Cmd!=NULL && Cmd->ExclCheck(FindData->Name,false,false))
+ if (Cmd!=NULL && Cmd->ExclCheckDir(FindData->Name))
{
// If we are here in "fast find" mode, it means that entire directory
// specified in command line is excluded. Then we need to return
Oops, something went wrong.

0 comments on commit 8f20626

Please sign in to comment.