24 Commits

Author SHA1 Message Date
cvs2svn
b442e312bb This commit was manufactured by cvs2svn to create tag 'RELEASE_0_3_0'.
git-svn-id: http://svn.php.net/repository/pecl/rar/tags/RELEASE_0_3_0@214301 c90b9560-bf6c-de11-be94-00142212c4b1
2006-06-06 08:07:45 +00:00
tony2001
6e5f90d038 prepare to 0.3.0
git-svn-id: http://svn.php.net/repository/pecl/rar/trunk@214300 c90b9560-bf6c-de11-be94-00142212c4b1
2006-06-06 08:07:44 +00:00
tony2001
45ac56f43b initialize internal structs
git-svn-id: http://svn.php.net/repository/pecl/rar/trunk@212385 c90b9560-bf6c-de11-be94-00142212c4b1
2006-05-03 21:39:21 +00:00
tony2001
c3913f5ee9 prepare to 0.3
git-svn-id: http://svn.php.net/repository/pecl/rar/trunk@212351 c90b9560-bf6c-de11-be94-00142212c4b1
2006-05-03 13:29:00 +00:00
tony2001
289e63250b add two more flags
git-svn-id: http://svn.php.net/repository/pecl/rar/trunk@212350 c90b9560-bf6c-de11-be94-00142212c4b1
2006-05-03 13:27:36 +00:00
tony2001
9b7245f2ba update unrar to 3.6.2
git-svn-id: http://svn.php.net/repository/pecl/rar/trunk@212349 c90b9560-bf6c-de11-be94-00142212c4b1
2006-05-03 13:26:34 +00:00
tony2001
a4f66e2dca fix/add .cvsignore files
git-svn-id: http://svn.php.net/repository/pecl/rar/trunk@205800 c90b9560-bf6c-de11-be94-00142212c4b1
2006-01-23 14:01:22 +00:00
tony2001
5ec39978bc nuke unused vars
git-svn-id: http://svn.php.net/repository/pecl/rar/trunk@205799 c90b9560-bf6c-de11-be94-00142212c4b1
2006-01-23 13:59:14 +00:00
tony2001
34652b09b2 don't use commandline when built as library
git-svn-id: http://svn.php.net/repository/pecl/rar/trunk@205798 c90b9560-bf6c-de11-be94-00142212c4b1
2006-01-23 13:58:51 +00:00
tony2001
905a30a02d reorganize sources
one more attempt to fix win32 build


git-svn-id: http://svn.php.net/repository/pecl/rar/trunk@205795 c90b9560-bf6c-de11-be94-00142212c4b1
2006-01-23 13:05:54 +00:00
fmk
355edc6bf5 Add missing list.cpp to source list
git-svn-id: http://svn.php.net/repository/pecl/rar/trunk@201052 c90b9560-bf6c-de11-be94-00142212c4b1
2005-11-22 17:33:42 +00:00
fmk
1ba294df92 Remove unused code blocks that breaks win32 builds
git-svn-id: http://svn.php.net/repository/pecl/rar/trunk@201051 c90b9560-bf6c-de11-be94-00142212c4b1
2005-11-22 17:33:11 +00:00
tony2001
c85047e54c update changelog
git-svn-id: http://svn.php.net/repository/pecl/rar/trunk@198129 c90b9560-bf6c-de11-be94-00142212c4b1
2005-10-10 19:27:33 +00:00
tony2001
5cbc4174f7 update bundled unrar to version 3.5.4
git-svn-id: http://svn.php.net/repository/pecl/rar/trunk@198128 c90b9560-bf6c-de11-be94-00142212c4b1
2005-10-10 19:26:35 +00:00
fmk
c3d082f6b3 Make sure the config file is loaded so HAVE_RAR is defined before it's checked.
git-svn-id: http://svn.php.net/repository/pecl/rar/trunk@187510 c90b9560-bf6c-de11-be94-00142212c4b1
2005-06-02 19:15:32 +00:00
wez
884f7db326 macro already includes these, maybe this will fix the rar dll?
git-svn-id: http://svn.php.net/repository/pecl/rar/trunk@187494 c90b9560-bf6c-de11-be94-00142212c4b1
2005-06-02 12:45:57 +00:00
tony2001
d5b4779393 *sigh*
I don't understand Windo$e..


git-svn-id: http://svn.php.net/repository/pecl/rar/trunk@183663 c90b9560-bf6c-de11-be94-00142212c4b1
2005-04-05 14:05:16 +00:00
tony2001
a0021aa3c2 fix build with HEAD
# why it worked nice before, I wonder?


git-svn-id: http://svn.php.net/repository/pecl/rar/trunk@180383 c90b9560-bf6c-de11-be94-00142212c4b1
2005-02-21 20:19:42 +00:00
fmk
80af4abe5a fix debug build on win32
git-svn-id: http://svn.php.net/repository/pecl/rar/trunk@174922 c90b9560-bf6c-de11-be94-00142212c4b1
2004-12-16 20:23:12 +00:00
tony2001
890f103f50 release 0.2
git-svn-id: http://svn.php.net/repository/pecl/rar/trunk@173958 c90b9560-bf6c-de11-be94-00142212c4b1
2004-12-02 13:06:58 +00:00
edink
101fddb80a Older nmake does't like double backslashed in the path
git-svn-id: http://svn.php.net/repository/pecl/rar/trunk@173404 c90b9560-bf6c-de11-be94-00142212c4b1
2004-11-23 20:48:08 +00:00
tony2001
8a59dd703c add .cvsignore
git-svn-id: http://svn.php.net/repository/pecl/rar/trunk@172293 c90b9560-bf6c-de11-be94-00142212c4b1
2004-11-08 21:34:45 +00:00
tony2001
7a18c6a556 fix small shared module build issue
git-svn-id: http://svn.php.net/repository/pecl/rar/trunk@167972 c90b9560-bf6c-de11-be94-00142212c4b1
2004-09-04 12:53:45 +00:00
tony2001
c1a3d3d0a7 add OS constants
git-svn-id: http://svn.php.net/repository/pecl/rar/trunk@167966 c90b9560-bf6c-de11-be94-00142212c4b1
2004-09-04 12:21:50 +00:00
74 changed files with 1698 additions and 770 deletions

View File

@@ -2,7 +2,7 @@ dnl $Id$
dnl config.m4 for extension rar
PHP_ARG_ENABLE(rar, whether to enable rar support,
[ --enable-rar Enable rar support])
[ --enable-rar Enable rar support])
unrar_sources="unrar/rar.cpp unrar/strlist.cpp unrar/strfn.cpp \
unrar/pathfn.cpp unrar/int64.cpp unrar/savepos.cpp \
@@ -24,8 +24,8 @@ if test "$PHP_RAR" != "no"; then
PHP_REQUIRE_CXX
AC_DEFINE(HAVE_RAR, 1, [Whether you have rar support])
PHP_SUBST(RAR_SHARED_LIBADD)
PHP_ADD_BUILD_DIR($ext_builddir/unrar)
PHP_ADD_LIBRARY_WITH_PATH(stdc++, "", RAR_SHARED_LIBADD)
PHP_NEW_EXTENSION(rar, rar.cpp $unrar_sources, $ext_shared,,-I@ext_srcdir@/unrar)
PHP_NEW_EXTENSION(rar, rar.cpp $unrar_sources, $ext_shared,,-DRARDLL -DGUI -DSILENT -I@ext_srcdir@/unrar)
PHP_ADD_BUILD_DIR($ext_builddir/unrar)
fi

View File

@@ -4,8 +4,8 @@
ARG_ENABLE("rar", "Rar support", "no");
if (PHP_RAR != "no") {
EXTENSION("rar", "rar.cpp");
ADD_SOURCES(configure_module_dirname + "/unrar/", "rar.cpp \
EXTENSION("rar", "rar.cpp", PHP_RAR_SHARED, "-DRARDLL -DGUI -DSILENT");
ADD_SOURCES(configure_module_dirname + "/unrar", "rar.cpp \
strlist.cpp strfn.cpp pathfn.cpp int64.cpp \
savepos.cpp global.cpp file.cpp filefn.cpp \
filcreat.cpp archive.cpp arcread.cpp unicode.cpp \
@@ -16,7 +16,7 @@ if (PHP_RAR != "no") {
getbits.cpp sha1.cpp extinfo.cpp extract.cpp \
volume.cpp find.cpp unpack.cpp cmddata.cpp \
dll.cpp filestr.cpp recvol.cpp rs.cpp \
scantree.cpp", "rar");
scantree.cpp list.cpp", "rar");
if (!PHP_RAR_SHARED) {
ADD_DEF_FILE(configure_module_dirname + "\\unrar\\dll.def");

View File

@@ -1,161 +1,187 @@
<?xml version="1.0" encoding="ISO-8859-1" ?>
<package>
<name>rar</name>
<summary>rar extension</summary>
<description>
Rar is a powerful and effective archiver, which was
created by Eugene Roshal and became rather popular quite fast.
This extension gives you possibility to read Rar archives.
</description>
<license>PHP License</license>
<maintainers>
<maintainer>
<user>tony2001</user>
<name>Antony Dovgal</name>
<email>tony2001@phpclub.net</email>
</maintainer>
</maintainers>
<release>
<version>0.1</version>
<date>2004-06-11</date>
<state>alpha</state>
<notes>
1) Initial release
</notes>
</release>
<filelist>
<dir role="src" name="/">
<file role="doc">CREDITS</file>
<file role="doc">example.php</file>
<name>rar</name>
<summary>rar extension</summary>
<description>
Rar is a powerful and effective archiver, which was
created by Eugene Roshal and became rather popular quite fast.
This extension gives you possibility to read Rar archives.
</description>
<license>PHP License</license>
<maintainers>
<maintainer>
<user>tony2001</user>
<name>Antony Dovgal</name>
<email>tony2001@phpclub.net</email>
</maintainer>
</maintainers>
<release>
<version>0.3.0</version>
<date>2006-06-06</date>
<state>beta</state>
<notes>
- Updated bundled unrar to version 3.6.2 (fixes compile errors with GCC4).
- Several minor fixes.
</notes>
</release>
<changelog>
<release>
<version>0.2</version>
<date>2004-12-02</date>
<state>beta</state>
<notes>
1) Added open_basedir and safe_mode checks.
2) Fixed Win32 build issues (thanks to Edin).
Currently only 5.x builds are available.
3) Added OS constants.
4) Fixed 0 bugs. There are no bugs, wee =)
</notes>
</release>
<release>
<version>0.1</version>
<date>2004-06-11</date>
<state>alpha</state>
<notes>
1) Initial release
</notes>
</release>
</changelog>
<filelist>
<dir role="src" name="/">
<file role="doc">CREDITS</file>
<file role="doc">example.php</file>
<file role="src">config.m4</file>
<file role="src">php_rar.h</file>
<file role="src">rar.cpp</file>
<dir role="src" name="/unrar/">
<file role="src">config.m4</file>
<file role="src">php_rar.h</file>
<file role="src">rar.cpp</file>
<file role="doc">LICENSE.txt</file>
<file role="doc">README.txt</file>
<dir role="src" name="/unrar/">
<file role="src">arccmt.cpp</file>
<file role="src">archive.cpp</file>
<file role="src">archive.hpp</file>
<file role="src">arcread.cpp</file>
<file role="src">array.hpp</file>
<file role="src">beosea.cpp</file>
<file role="src">cmddata.cpp</file>
<file role="src">cmddata.hpp</file>
<file role="src">coder.cpp</file>
<file role="src">coder.hpp</file>
<file role="src">compress.hpp</file>
<file role="src">consio.cpp</file>
<file role="src">consio.hpp</file>
<file role="src">crc.cpp</file>
<file role="src">crc.hpp</file>
<file role="src">crypt.cpp</file>
<file role="src">crypt.hpp</file>
<file role="src">dll.cpp</file>
<file role="src">dll.def</file>
<file role="src">dll.hpp</file>
<file role="src">encname.cpp</file>
<file role="src">encname.hpp</file>
<file role="src">errhnd.cpp</file>
<file role="src">errhnd.hpp</file>
<file role="src">extinfo.cpp</file>
<file role="src">extinfo.hpp</file>
<file role="src">extract.cpp</file>
<file role="src">extract.hpp</file>
<file role="src">filcreat.cpp</file>
<file role="src">filcreat.hpp</file>
<file role="src">file.cpp</file>
<file role="src">filefn.cpp</file>
<file role="src">filefn.hpp</file>
<file role="src">file.hpp</file>
<file role="src">filestr.cpp</file>
<file role="src">filestr.hpp</file>
<file role="src">find.cpp</file>
<file role="src">find.hpp</file>
<file role="src">getbits.cpp</file>
<file role="src">getbits.hpp</file>
<file role="src">global.cpp</file>
<file role="src">global.hpp</file>
<file role="src">headers.hpp</file>
<file role="src">int64.cpp</file>
<file role="src">int64.hpp</file>
<file role="src">isnt.cpp</file>
<file role="src">isnt.hpp</file>
<file role="src">list.cpp</file>
<file role="src">list.hpp</file>
<file role="src">loclang.hpp</file>
<file role="src">log.cpp</file>
<file role="src">log.hpp</file>
<file role="src">match.cpp</file>
<file role="src">match.hpp</file>
<file role="src">memfree.hpp</file>
<file role="src">model.cpp</file>
<file role="src">model.hpp</file>
<file role="src">msc.dep</file>
<file role="src">options.cpp</file>
<file role="src">options.hpp</file>
<file role="src">os2ea.cpp</file>
<file role="src">os.hpp</file>
<file role="src">pathfn.cpp</file>
<file role="src">pathfn.hpp</file>
<file role="src">rar.cpp</file>
<file role="src">rardefs.hpp</file>
<file role="src">rarfn.hpp</file>
<file role="src">rar.hpp</file>
<file role="src">rarlang.hpp</file>
<file role="src">raros.hpp</file>
<file role="src">rartypes.hpp</file>
<file role="src">rarvm.cpp</file>
<file role="src">rarvm.hpp</file>
<file role="src">rarvmtbl.cpp</file>
<file role="src">rawread.cpp</file>
<file role="src">rawread.hpp</file>
<file role="src">rdwrfn.cpp</file>
<file role="src">rdwrfn.hpp</file>
<file role="src">recvol.cpp</file>
<file role="src">recvol.hpp</file>
<file role="src">resource.cpp</file>
<file role="src">resource.hpp</file>
<file role="src">rijndael.cpp</file>
<file role="src">rijndael.hpp</file>
<file role="src">rs.cpp</file>
<file role="src">rs.hpp</file>
<file role="src">savepos.cpp</file>
<file role="src">savepos.hpp</file>
<file role="src">scantree.cpp</file>
<file role="src">scantree.hpp</file>
<file role="src">sha1.cpp</file>
<file role="src">sha1.hpp</file>
<file role="src">smallfn.cpp</file>
<file role="src">smallfn.hpp</file>
<file role="src">strfn.cpp</file>
<file role="src">strfn.hpp</file>
<file role="src">strlist.cpp</file>
<file role="src">strlist.hpp</file>
<file role="src">suballoc.cpp</file>
<file role="src">suballoc.hpp</file>
<file role="src">system.cpp</file>
<file role="src">system.hpp</file>
<file role="src">timefn.cpp</file>
<file role="src">timefn.hpp</file>
<file role="src">ulinks.cpp</file>
<file role="src">ulinks.hpp</file>
<file role="src">unicode.cpp</file>
<file role="src">unicode.hpp</file>
<file role="src">unpack15.cpp</file>
<file role="src">unpack20.cpp</file>
<file role="src">unpack.cpp</file>
<file role="src">unpack.hpp</file>
<file role="src">uowners.cpp</file>
<file role="src">version.hpp</file>
<file role="src">volume.cpp</file>
<file role="src">volume.hpp</file>
<file role="src">win32acl.cpp</file>
<file role="src">win32stm.cpp</file>
</dir>
</dir>
</filelist>
<file role="doc">LICENSE.txt</file>
<file role="doc">README.txt</file>
<file role="src">arccmt.cpp</file>
<file role="src">archive.cpp</file>
<file role="src">archive.hpp</file>
<file role="src">arcread.cpp</file>
<file role="src">array.hpp</file>
<file role="src">beosea.cpp</file>
<file role="src">cmddata.cpp</file>
<file role="src">cmddata.hpp</file>
<file role="src">coder.cpp</file>
<file role="src">coder.hpp</file>
<file role="src">compress.hpp</file>
<file role="src">consio.cpp</file>
<file role="src">consio.hpp</file>
<file role="src">crc.cpp</file>
<file role="src">crc.hpp</file>
<file role="src">crypt.cpp</file>
<file role="src">crypt.hpp</file>
<file role="src">dll.cpp</file>
<file role="src">dll.def</file>
<file role="src">dll.hpp</file>
<file role="src">encname.cpp</file>
<file role="src">encname.hpp</file>
<file role="src">errhnd.cpp</file>
<file role="src">errhnd.hpp</file>
<file role="src">extinfo.cpp</file>
<file role="src">extinfo.hpp</file>
<file role="src">extract.cpp</file>
<file role="src">extract.hpp</file>
<file role="src">filcreat.cpp</file>
<file role="src">filcreat.hpp</file>
<file role="src">file.cpp</file>
<file role="src">filefn.cpp</file>
<file role="src">filefn.hpp</file>
<file role="src">file.hpp</file>
<file role="src">filestr.cpp</file>
<file role="src">filestr.hpp</file>
<file role="src">find.cpp</file>
<file role="src">find.hpp</file>
<file role="src">getbits.cpp</file>
<file role="src">getbits.hpp</file>
<file role="src">global.cpp</file>
<file role="src">global.hpp</file>
<file role="src">headers.hpp</file>
<file role="src">int64.cpp</file>
<file role="src">int64.hpp</file>
<file role="src">isnt.cpp</file>
<file role="src">isnt.hpp</file>
<file role="src">list.cpp</file>
<file role="src">list.hpp</file>
<file role="src">loclang.hpp</file>
<file role="src">log.cpp</file>
<file role="src">log.hpp</file>
<file role="src">match.cpp</file>
<file role="src">match.hpp</file>
<file role="src">memfree.hpp</file>
<file role="src">model.cpp</file>
<file role="src">model.hpp</file>
<file role="src">msc.dep</file>
<file role="src">options.cpp</file>
<file role="src">options.hpp</file>
<file role="src">os2ea.cpp</file>
<file role="src">os.hpp</file>
<file role="src">pathfn.cpp</file>
<file role="src">pathfn.hpp</file>
<file role="src">rar.cpp</file>
<file role="src">rardefs.hpp</file>
<file role="src">rarfn.hpp</file>
<file role="src">rar.hpp</file>
<file role="src">rarlang.hpp</file>
<file role="src">raros.hpp</file>
<file role="src">rartypes.hpp</file>
<file role="src">rarvm.cpp</file>
<file role="src">rarvm.hpp</file>
<file role="src">rarvmtbl.cpp</file>
<file role="src">rawread.cpp</file>
<file role="src">rawread.hpp</file>
<file role="src">rdwrfn.cpp</file>
<file role="src">rdwrfn.hpp</file>
<file role="src">recvol.cpp</file>
<file role="src">recvol.hpp</file>
<file role="src">resource.cpp</file>
<file role="src">resource.hpp</file>
<file role="src">rijndael.cpp</file>
<file role="src">rijndael.hpp</file>
<file role="src">rs.cpp</file>
<file role="src">rs.hpp</file>
<file role="src">savepos.cpp</file>
<file role="src">savepos.hpp</file>
<file role="src">scantree.cpp</file>
<file role="src">scantree.hpp</file>
<file role="src">sha1.cpp</file>
<file role="src">sha1.hpp</file>
<file role="src">smallfn.cpp</file>
<file role="src">smallfn.hpp</file>
<file role="src">strfn.cpp</file>
<file role="src">strfn.hpp</file>
<file role="src">strlist.cpp</file>
<file role="src">strlist.hpp</file>
<file role="src">suballoc.cpp</file>
<file role="src">suballoc.hpp</file>
<file role="src">system.cpp</file>
<file role="src">system.hpp</file>
<file role="src">timefn.cpp</file>
<file role="src">timefn.hpp</file>
<file role="src">ulinks.cpp</file>
<file role="src">ulinks.hpp</file>
<file role="src">unicode.cpp</file>
<file role="src">unicode.hpp</file>
<file role="src">unpack15.cpp</file>
<file role="src">unpack20.cpp</file>
<file role="src">unpack.cpp</file>
<file role="src">unpack.hpp</file>
<file role="src">uowners.cpp</file>
<file role="src">version.hpp</file>
<file role="src">volume.cpp</file>
<file role="src">volume.hpp</file>
<file role="src">win32acl.cpp</file>
<file role="src">win32stm.cpp</file>
</dir>
</dir>
</filelist>
</package>
<!--
vim:et:ts=1:sw=1
-->

View File

@@ -53,17 +53,6 @@ PHP_FUNCTION(rar_list);
PHP_FUNCTION(rar_entry_get);
PHP_FUNCTION(rar_close);
PHP_METHOD(rarentry, extract);
PHP_METHOD(rarentry, getName);
PHP_METHOD(rarentry, getUnpackedSize);
PHP_METHOD(rarentry, getPackedSize);
PHP_METHOD(rarentry, getHostOs);
PHP_METHOD(rarentry, getFileTime);
PHP_METHOD(rarentry, getCrc);
PHP_METHOD(rarentry, getAttr);
PHP_METHOD(rarentry, getVersion);
PHP_METHOD(rarentry, getMethod);
typedef struct rar {
int id;
int entry_count;

215
rar.cpp
View File

@@ -30,67 +30,25 @@
#include "config.h"
#endif
#ifdef PHP_WIN32
# include <math.h>
#endif
extern "C" {
#include "php.h"
#include "php_ini.h"
#include "ext/standard/info.h"
#if HAVE_RAR
extern "C" {
#include "php_rar.h"
}
#if HAVE_RAR
#include "php_rar.h"
#include "unrar/rar.hpp"
static int le_rar_file;
#define le_rar_file_name "Rar"
static zend_class_entry *rar_class_entry_ptr;
/* {{{ rar_functions[]
*
*/
function_entry rar_functions[] = {
PHP_FE(rar_open, NULL)
PHP_FE(rar_list, NULL)
PHP_FE(rar_entry_get, NULL)
PHP_FE(rar_close, NULL)
{NULL, NULL, NULL}
};
static zend_function_entry php_rar_class_functions[] = {
PHP_ME(rarentry, extract, NULL, 0)
PHP_ME(rarentry, getName, NULL, 0)
PHP_ME(rarentry, getUnpackedSize, NULL, 0)
PHP_ME(rarentry, getPackedSize, NULL, 0)
PHP_ME(rarentry, getHostOs, NULL, 0)
PHP_ME(rarentry, getFileTime, NULL, 0)
PHP_ME(rarentry, getCrc, NULL, 0)
PHP_ME(rarentry, getAttr, NULL, 0)
PHP_ME(rarentry, getVersion, NULL, 0)
PHP_ME(rarentry, getMethod, NULL, 0)
{NULL, NULL, NULL}
};
/* }}} */
/* {{{ rar_module_entry
*/
zend_module_entry rar_module_entry = {
#if ZEND_MODULE_API_NO >= 20010901
STANDARD_MODULE_HEADER,
#endif
"rar",
rar_functions,
PHP_MINIT(rar),
PHP_MSHUTDOWN(rar),
PHP_RINIT(rar), /* Replace with NULL if there's nothing to do at request start */
PHP_RSHUTDOWN(rar), /* Replace with NULL if there's nothing to do at request end */
PHP_MINFO(rar),
#if ZEND_MODULE_API_NO >= 20010901
"0.1", /* Replace with version number for your extension */
#endif
STANDARD_MODULE_PROPERTIES
};
/* }}} */
/* {{{ internal functions protos */
static void _rar_file_list_dtor(zend_rsrc_list_entry * TSRMLS_DC);
static int _rar_list_files(rar_file_t * TSRMLS_DC);
@@ -263,60 +221,11 @@ static zval **_rar_entry_get_property(zval *id, char *name, int namelen TSRMLS_D
/* </internal> */
#ifdef COMPILE_DL_RAR
extern "C" {
BEGIN_EXTERN_C()
ZEND_GET_MODULE(rar)
}
END_EXTERN_C()
#endif
/* {{{ PHP_MINIT_FUNCTION
*/
PHP_MINIT_FUNCTION(rar)
{
zend_class_entry rar_class_entry;
INIT_CLASS_ENTRY(rar_class_entry, "RarEntry", php_rar_class_functions);
rar_class_entry_ptr = zend_register_internal_class(&rar_class_entry TSRMLS_CC);
le_rar_file = zend_register_list_destructors_ex(_rar_file_list_dtor, NULL, le_rar_file_name, module_number);
return SUCCESS;
}
/* }}} */
/* {{{ PHP_MSHUTDOWN_FUNCTION
*/
PHP_MSHUTDOWN_FUNCTION(rar)
{
return SUCCESS;
}
/* }}} */
/* {{{ PHP_RINIT_FUNCTION
*/
PHP_RINIT_FUNCTION(rar)
{
return SUCCESS;
}
/* }}} */
/* {{{ PHP_RSHUTDOWN_FUNCTION
*/
PHP_RSHUTDOWN_FUNCTION(rar)
{
return SUCCESS;
}
/* }}} */
/* {{{ PHP_MINFO_FUNCTION
*/
PHP_MINFO_FUNCTION(rar)
{
php_info_print_table_start();
php_info_print_table_header(2, "Rar support", "enabled");
php_info_print_table_row(2, "Revision", "$Revision$");
php_info_print_table_end();
}
/* }}} */
/* module functions */
/* {{{ proto rar_open(string filename [, string password])
@@ -325,7 +234,6 @@ PHP_FUNCTION(rar_open)
{
zval **filename, **password;
rar_file_t *rar = NULL;
struct RARHeaderData entry;
int ac = ZEND_NUM_ARGS(), result = 0;
if (ac < 1 || ac > 2 || zend_get_parameters_ex(ac, &filename, &password) == FAILURE) {
@@ -343,10 +251,10 @@ PHP_FUNCTION(rar_open)
}
rar = (rar_file_t *) emalloc(sizeof(rar_file_t));
rar->list_handle = (RAROpenArchiveData *) emalloc(sizeof(RAROpenArchiveData));
rar->list_handle = (RAROpenArchiveData *) ecalloc(1, sizeof(RAROpenArchiveData));
rar->list_handle->ArcName = estrndup(Z_STRVAL_PP(filename), Z_STRLEN_PP(filename));
rar->list_handle->OpenMode = RAR_OM_LIST;
rar->extract_handle = (RAROpenArchiveData *) emalloc(sizeof(RAROpenArchiveData));
rar->extract_handle = (RAROpenArchiveData *) ecalloc(1, sizeof(RAROpenArchiveData));
rar->extract_handle->ArcName = estrndup(Z_STRVAL_PP(filename), Z_STRLEN_PP(filename));
rar->extract_handle->OpenMode = RAR_OM_EXTRACT;
rar->password = NULL;
@@ -481,13 +389,11 @@ PHP_FUNCTION(rar_close)
Extract file from the archive */
PHP_METHOD(rarentry, extract)
{
zval **rarfile, **path, **filename, **tmp, **tmp_name;
zval **path, **filename, **tmp, **tmp_name;
rar_file_t *rar = NULL;
char filename_str[260];
char *path_str = NULL, *extract_to_file = NULL;
int ac = ZEND_NUM_ARGS(), resource_type = 0, result = 0, process_result = 0;
zval *entry_obj = getThis();
unsigned long data_len;
struct RARHeaderData entry;
void *extract_data;
@@ -572,7 +478,7 @@ PHP_METHOD(rarentry, extract)
Return entry name */
PHP_METHOD(rarentry, getName)
{
zval **rarfile, **tmp;
zval **tmp;
rar_file_t *rar = NULL;
zval *entry_obj = getThis();
@@ -589,7 +495,7 @@ PHP_METHOD(rarentry, getName)
Return unpacked size of the entry */
PHP_METHOD(rarentry, getUnpackedSize)
{
zval **rarfile, **tmp;
zval **tmp;
rar_file_t *rar = NULL;
zval *entry_obj = getThis();
@@ -606,7 +512,7 @@ PHP_METHOD(rarentry, getUnpackedSize)
Return packed size of the entry */
PHP_METHOD(rarentry, getPackedSize)
{
zval **rarfile, **tmp;
zval **tmp;
rar_file_t *rar = NULL;
zval *entry_obj = getThis();
@@ -623,7 +529,7 @@ PHP_METHOD(rarentry, getPackedSize)
Return host OS of the entry */
PHP_METHOD(rarentry, getHostOs)
{
zval **rarfile, **tmp;
zval **tmp;
rar_file_t *rar = NULL;
zval *entry_obj = getThis();
@@ -640,7 +546,7 @@ PHP_METHOD(rarentry, getHostOs)
Return modification time of the entry */
PHP_METHOD(rarentry, getFileTime)
{
zval **rarfile, **tmp;
zval **tmp;
rar_file_t *rar = NULL;
zval *entry_obj = getThis();
@@ -657,7 +563,7 @@ PHP_METHOD(rarentry, getFileTime)
Return CRC of the entry */
PHP_METHOD(rarentry, getCrc)
{
zval **rarfile, **tmp;
zval **tmp;
rar_file_t *rar = NULL;
zval *entry_obj = getThis();
@@ -674,7 +580,7 @@ PHP_METHOD(rarentry, getCrc)
Return attributes of the entry */
PHP_METHOD(rarentry, getAttr)
{
zval **rarfile, **tmp;
zval **tmp;
rar_file_t *rar = NULL;
zval *entry_obj = getThis();
@@ -691,7 +597,7 @@ PHP_METHOD(rarentry, getAttr)
Return version of the archiver, used to create this entry */
PHP_METHOD(rarentry, getVersion)
{
zval **rarfile, **tmp;
zval **tmp;
rar_file_t *rar = NULL;
zval *entry_obj = getThis();
@@ -708,7 +614,7 @@ PHP_METHOD(rarentry, getVersion)
Return packing method */
PHP_METHOD(rarentry, getMethod)
{
zval **rarfile, **tmp;
zval **tmp;
rar_file_t *rar = NULL;
zval *entry_obj = getThis();
@@ -721,6 +627,83 @@ PHP_METHOD(rarentry, getMethod)
}
/* }}} */
/* {{{ rar_functions[]
*
*/
function_entry rar_functions[] = {
PHP_FE(rar_open, NULL)
PHP_FE(rar_list, NULL)
PHP_FE(rar_entry_get, NULL)
PHP_FE(rar_close, NULL)
{NULL, NULL, NULL}
};
static zend_function_entry php_rar_class_functions[] = {
PHP_ME(rarentry, extract, NULL, 0)
PHP_ME(rarentry, getName, NULL, 0)
PHP_ME(rarentry, getUnpackedSize, NULL, 0)
PHP_ME(rarentry, getPackedSize, NULL, 0)
PHP_ME(rarentry, getHostOs, NULL, 0)
PHP_ME(rarentry, getFileTime, NULL, 0)
PHP_ME(rarentry, getCrc, NULL, 0)
PHP_ME(rarentry, getAttr, NULL, 0)
PHP_ME(rarentry, getVersion, NULL, 0)
PHP_ME(rarentry, getMethod, NULL, 0)
{NULL, NULL, NULL}
};
/* }}} */
/* {{{ PHP_MINIT_FUNCTION
*/
PHP_MINIT_FUNCTION(rar)
{
zend_class_entry rar_class_entry;
INIT_CLASS_ENTRY(rar_class_entry, "RarEntry", php_rar_class_functions);
rar_class_entry_ptr = zend_register_internal_class(&rar_class_entry TSRMLS_CC);
le_rar_file = zend_register_list_destructors_ex(_rar_file_list_dtor, NULL, le_rar_file_name, module_number);
REGISTER_LONG_CONSTANT("RAR_HOST_MSDOS", HOST_MSDOS, CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("RAR_HOST_OS2", HOST_OS2, CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("RAR_HOST_WIN32", HOST_WIN32, CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("RAR_HOST_UNIX", HOST_UNIX, CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("RAR_HOST_MACOS", HOST_MACOS, CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("RAR_HOST_BEOS", HOST_BEOS, CONST_CS | CONST_PERSISTENT);
return SUCCESS;
}
/* }}} */
/* {{{ PHP_MINFO_FUNCTION
*/
PHP_MINFO_FUNCTION(rar)
{
php_info_print_table_start();
php_info_print_table_header(2, "Rar support", "enabled");
php_info_print_table_row(2, "Revision", "$Revision$");
php_info_print_table_end();
}
/* }}} */
/* {{{ rar_module_entry
*/
zend_module_entry rar_module_entry = {
#if ZEND_MODULE_API_NO >= 20010901
STANDARD_MODULE_HEADER,
#endif
"rar",
rar_functions,
PHP_MINIT(rar),
NULL,
NULL,
NULL,
PHP_MINFO(rar),
#if ZEND_MODULE_API_NO >= 20010901
"0.1", /* Replace with version number for your extension */
#endif
STANDARD_MODULE_PROPERTIES
};
/* }}} */
#endif /* HAVE_RAR */
/*
* Local variables:

View File

@@ -1,4 +1,4 @@
bool Archive::GetComment(Array<byte> &CmtData)
bool Archive::GetComment(Array<byte> *CmtData,Array<wchar> *CmtDataW)
{
if (!MainComment)
return(false);
@@ -22,7 +22,7 @@ bool Archive::GetComment(Array<byte> &CmtData)
else
{
Seek(SFXSize+SIZEOF_MARKHEAD+NewMhd.HeadSize,SEEK_SET);
return(SearchSubBlock(SUBHEAD_TYPE_CMT)!=0 && ReadCommentData(CmtData)!=0);
return(SearchSubBlock(SUBHEAD_TYPE_CMT)!=0 && ReadCommentData(CmtData,CmtDataW)!=0);
}
#ifndef SFX_MODULE
if (CommHead.HeadCRC!=HeaderCRC)
@@ -69,49 +69,77 @@ bool Archive::GetComment(Array<byte> &CmtData)
unsigned char *UnpData;
uint UnpDataSize;
DataIO.GetUnpackedData(&UnpData,&UnpDataSize);
CmtData.Alloc(UnpDataSize);
memcpy(&CmtData[0],UnpData,UnpDataSize);
CmtData->Alloc(UnpDataSize);
memcpy(&((*CmtData)[0]),UnpData,UnpDataSize);
}
}
else
{
CmtData.Alloc(CmtLength);
CmtData->Alloc(CmtLength);
Read(&CmtData[0],CmtLength);
if (!OldFormat && CommHead.CommCRC!=(~CRC(0xffffffff,&CmtData[0],CmtLength)&0xffff))
Read(&((*CmtData)[0]),CmtLength);
if (!OldFormat && CommHead.CommCRC!=(~CRC(0xffffffff,&((*CmtData)[0]),CmtLength)&0xffff))
{
Log(FileName,St(MLogCommBrk));
Alarm();
CmtData.Reset();
CmtData->Reset();
return(false);
}
}
#endif
#if defined(_WIN_32) && !defined(_WIN_CE)
if (CmtData.Size()>0)
OemToCharBuff((char*)&CmtData[0],(char*)&CmtData[0],CmtData.Size());
if (CmtData->Size()>0)
{
int CmtSize=CmtData->Size();
OemToCharBuff((char *)CmtData->Addr(),(char *)CmtData->Addr(),CmtSize);
if (CmtDataW!=NULL)
{
CmtDataW->Alloc(CmtSize+1);
CmtData->Push(0);
CharToWide((char *)CmtData->Addr(),CmtDataW->Addr(),CmtSize+1);
CmtData->Alloc(CmtSize);
CmtDataW->Alloc(strlenw(CmtDataW->Addr()));
}
}
#endif
return(CmtData.Size()>0);
return(CmtData->Size()>0);
}
int Archive::ReadCommentData(Array<byte> &CmtData)
int Archive::ReadCommentData(Array<byte> *CmtData,Array<wchar> *CmtDataW)
{
bool Unicode=SubHead.SubFlags & SUBHEAD_FLAGS_CMT_UNICODE;
if (!ReadSubData(&CmtData,NULL))
if (!ReadSubData(CmtData,NULL))
return(0);
int CmtSize=CmtData.Size();
int CmtSize=CmtData->Size();
if (Unicode)
{
CmtSize/=2;
Array<wchar> CmtDataW(CmtSize+1);
RawToWide(&CmtData[0],&CmtDataW[0],CmtSize);
CmtDataW[CmtSize]=0;
CmtData.Alloc(CmtSize*2);
WideToChar(&CmtDataW[0],(char *)&CmtData[0]);
CmtSize=strlen((char *)&CmtData[0]);
CmtData.Alloc(CmtSize);
Array<wchar> DataW(CmtSize+1);
RawToWide(CmtData->Addr(),DataW.Addr(),CmtSize);
DataW[CmtSize]=0;
int DestSize=CmtSize*4;
CmtData->Alloc(DestSize+1);
WideToChar(DataW.Addr(),(char *)CmtData->Addr(),DestSize);
(*CmtData)[DestSize]=0;
CmtSize=strlen((char *)CmtData->Addr());
CmtData->Alloc(CmtSize);
if (CmtDataW!=NULL)
{
*CmtDataW=DataW;
CmtDataW->Alloc(CmtSize);
}
}
else
if (CmtDataW!=NULL)
{
CmtData->Push(0);
CmtDataW->Alloc(CmtSize+1);
CharToWide((char *)CmtData->Addr(),CmtDataW->Addr(),CmtSize+1);
CmtData->Alloc(CmtSize);
CmtDataW->Alloc(strlenw(CmtDataW->Addr()));
}
return(CmtSize);
}
@@ -122,7 +150,7 @@ void Archive::ViewComment()
if (Cmd->DisableComment)
return;
Array<byte> CmtBuf;
if (GetComment(CmtBuf))
if (GetComment(&CmtBuf,NULL))
{
int CmtSize=CmtBuf.Size();
char *ChPtr=(char *)memchr(&CmtBuf[0],0x1A,CmtSize);
@@ -138,47 +166,46 @@ void Archive::ViewComment()
#ifndef SFX_MODULE
void Archive::ViewFileComment()
{
if (!(NewLhd.Flags & LHD_COMMENT) || Cmd->DisableComment)
if (!(NewLhd.Flags & LHD_COMMENT) || Cmd->DisableComment || OldFormat)
return;
#ifndef GUI
mprintf(St(MFileComment));
#endif
Array<char> CmtBuf(0x8000);
const int MaxSize=0x8000;
Array<char> CmtBuf(MaxSize);
SaveFilePos SavePos(*this);
if (OldFormat)
Seek(CurBlockPos+SIZEOF_NEWLHD+NewLhd.NameSize,SEEK_SET);
Int64 SaveCurBlockPos=CurBlockPos;
Int64 SaveNextBlockPos=NextBlockPos;
int Size=ReadHeader();
CurBlockPos=SaveCurBlockPos;
NextBlockPos=SaveNextBlockPos;
if (Size<7 || CommHead.HeadType!=COMM_HEAD)
return;
if (CommHead.HeadCRC!=HeaderCRC)
{
uint CmtLength=GetByte()+(GetByte()<<8);
Read(&CmtBuf[0],CmtLength);
OutComment(&CmtBuf[0],CmtLength);
#ifndef GUI
Log(FileName,St(MLogCommHead));
#endif
return;
}
if (CommHead.UnpVer < 15 || CommHead.UnpVer > UNP_VER ||
CommHead.Method > 0x30 || CommHead.UnpSize > MaxSize)
return;
Read(&CmtBuf[0],CommHead.UnpSize);
if (CommHead.CommCRC!=((~CRC(0xffffffff,&CmtBuf[0],CommHead.UnpSize)&0xffff)))
{
Log(FileName,St(MLogBrokFCmt));
}
else
{
OutComment(&CmtBuf[0],CommHead.UnpSize);
#ifndef GUI
mprintf("\n");
#endif
}
else
{
if (ReadHeader()<7 || CommHead.HeadType!=COMM_HEAD)
return;
if (CommHead.HeadCRC!=HeaderCRC)
{
#ifndef GUI
Log(FileName,St(MLogCommHead));
#endif
return;
}
if (CommHead.UnpVer < 15 || CommHead.UnpVer > UNP_VER || CommHead.Method > 0x30)
return;
Read(&CmtBuf[0],CommHead.UnpSize);
if (CommHead.CommCRC!=CRC(0xffffffff,&CmtBuf[0],CommHead.UnpSize))
{
Log(FileName,St(MLogBrokFCmt));
}
else
{
OutComment(&CmtBuf[0],CommHead.UnpSize);
#ifndef GUI
mprintf("\n");
#endif
}
}
}
#endif

View File

@@ -47,6 +47,7 @@ Archive::Archive(RAROptions *InitCmd)
NewArchive=false;
SilentOpen=false;
}
@@ -130,12 +131,18 @@ bool Archive::IsArchive(bool EnableBroken)
}
else
{
Array<char> Buffer(0x40000);
Array<char> Buffer(MAXSFXSIZE);
long CurPos=int64to32(Tell());
int ReadSize=Read(&Buffer[0],Buffer.Size()-16);
for (int I=0;I<ReadSize;I++)
if (Buffer[I]==0x52 && IsSignature((byte *)&Buffer[I]))
{
if (OldFormat && I>0 && CurPos<28 && ReadSize>31)
{
char *D=&Buffer[28-CurPos];
if (D[0]!=0x52 || D[1]!=0x53 || D[2]!=0x46 || D[3]!=0x58)
continue;
}
SFXSize=CurPos+I;
Seek(SFXSize,SEEK_SET);
if (!OldFormat)
@@ -174,6 +181,19 @@ bool Archive::IsArchive(bool EnableBroken)
Protected=(NewMhd.Flags & MHD_PROTECT)!=0;
Encrypted=(NewMhd.Flags & MHD_PASSWORD)!=0;
if (NewMhd.EncryptVer>UNP_VER)
{
#ifdef RARDLL
Cmd->DllError=ERAR_UNKNOWN_FORMAT;
#else
ErrHandler.SetErrorCode(RAR_WARNING);
#if !defined(SILENT) && !defined(SFX_MODULE)
Log(FileName,St(MUnknownMeth),FileName);
Log(FileName,St(MVerRequired),NewMhd.EncryptVer/10,NewMhd.EncryptVer%10);
#endif
#endif
return(false);
}
#ifdef RARDLL
SilentOpen=true;
#endif
@@ -233,3 +253,5 @@ int Archive::GetRecoverySize(bool Required)
#endif

View File

@@ -62,7 +62,7 @@ class Archive:public File
void WriteEndBlock(bool CloseVolume);
void CopyFileRecord(Archive &Src);
void CopyArchiveData(Archive &Src);
bool GetComment(Array<byte> &CmtData);
bool GetComment(Array<byte> *CmtData,Array<wchar> *CmtDataW);
void ViewComment();
void ViewFileComment();
void SetLatestTime(RarTime *NewTime);
@@ -71,14 +71,12 @@ class Archive:public File
bool IsArcDir();
bool IsArcLabel();
void ConvertAttributes();
int LhdSize();
int LhdExtraSize();
int GetRecoverySize(bool Required);
void VolSubtractHeaderSize(int SubSize);
void AddSubData(byte *SrcData,int DataSize,File *SrcFile,char *Name,bool AllowSplit);
bool ReadSubData(Array<byte> *UnpData,File *DestFile);
int GetHeaderType() {return(CurHeaderType);};
int ReadCommentData(Array<byte> &CmtData);
int ReadCommentData(Array<byte> *CmtData,Array<wchar> *CmtDataW);
void WriteCommentData(byte *Data,int DataSize,bool FileComment);
RAROptions* GetRAROptions() {return(Cmd);}
void SetSilentOpen(bool Mode) {SilentOpen=Mode;}
@@ -110,7 +108,7 @@ class Archive:public File
bool NotFirstVolume;
bool Protected;
bool Encrypted;
unsigned int SFXSize;
uint SFXSize;
bool BrokenFileHeader;
bool Splitting;

View File

@@ -19,7 +19,7 @@ int Archive::SearchBlock(int BlockType)
int Archive::SearchSubBlock(const char *Type)
{
int Size;
while ((Size=ReadHeader())!=0)
while ((Size=ReadHeader())!=0 && GetHeaderType()!=ENDARC_HEAD)
{
if (GetHeaderType()==NEWSUB_HEAD && SubHead.CmpName(Type))
return(Size);
@@ -65,7 +65,7 @@ int Archive::ReadHeader()
ErrHandler.Exit(RAR_USER_BREAK);
}
#endif
HeadersCrypt.SetCryptKeys(Cmd->Password,HeadersSalt,false);
HeadersCrypt.SetCryptKeys(Cmd->Password,HeadersSalt,false,false,NewMhd.EncryptVer>=36);
Raw.SetCrypt(&HeadersCrypt);
#endif
}
@@ -116,11 +116,15 @@ int Archive::ReadHeader()
*(BaseBlock *)&NewMhd=ShortBlock;
Raw.Get(NewMhd.HighPosAV);
Raw.Get(NewMhd.PosAV);
if (NewMhd.Flags & MHD_ENCRYPTVER)
Raw.Get(NewMhd.EncryptVer);
break;
case ENDARC_HEAD:
*(BaseBlock *)&EndArcHead=ShortBlock;
if (EndArcHead.Flags & EARC_DATACRC)
Raw.Get(EndArcHead.ArcDataCRC);
if (EndArcHead.Flags & EARC_VOLNUMBER)
Raw.Get(EndArcHead.VolNumber);
break;
case FILE_HEAD:
case NEWSUB_HEAD:
@@ -142,7 +146,14 @@ int Archive::ReadHeader()
Raw.Get(hd->HighUnpSize);
}
else
{
hd->HighPackSize=hd->HighUnpSize=0;
if (hd->UnpSize==0xffffffff)
{
hd->UnpSize=int64to32(INT64MAX);
hd->HighUnpSize=int64to32(INT64MAX>>32);
}
}
hd->FullPackSize=int32to64(hd->HighPackSize,hd->PackSize);
hd->FullUnpSize=int32to64(hd->HighUnpSize,hd->UnpSize);
@@ -176,10 +187,20 @@ int Archive::ReadHeader()
if (hd->Flags & LHD_UNICODE)
{
EncodeFileName NameCoder;
int Length=strlen(FileName)+1;
NameCoder.Decode(FileName,(byte *)FileName+Length,
hd->NameSize-Length,hd->FileNameW,
sizeof(hd->FileNameW)/sizeof(hd->FileNameW[0]));
int Length=strlen(FileName);
if (Length==hd->NameSize)
{
UtfToWide(FileName,hd->FileNameW,sizeof(hd->FileNameW)/sizeof(hd->FileNameW[0])-1);
WideToChar(hd->FileNameW,hd->FileName,sizeof(hd->FileName)/sizeof(hd->FileName[0])-1);
ExtToInt(hd->FileName,hd->FileName);
}
else
{
Length++;
NameCoder.Decode(FileName,(byte *)FileName+Length,
hd->NameSize-Length,hd->FileNameW,
sizeof(hd->FileNameW)/sizeof(hd->FileNameW[0]));
}
if (*hd->FileNameW==0)
hd->Flags &= ~LHD_UNICODE;
}
@@ -424,6 +445,11 @@ int Archive::ReadOldHeader()
NewLhd.FullPackSize=NewLhd.PackSize;
NewLhd.FullUnpSize=NewLhd.UnpSize;
NewLhd.mtime.SetDos(NewLhd.FileTime);
NewLhd.ctime.Reset();
NewLhd.atime.Reset();
NewLhd.arctime.Reset();
Raw.Read(OldLhd.NameSize);
Raw.Get((byte *)NewLhd.FileName,OldLhd.NameSize);
NewLhd.FileName[OldLhd.NameSize]=0;
@@ -434,7 +460,7 @@ int Archive::ReadOldHeader()
NextBlockPos=CurBlockPos+NewLhd.HeadSize+NewLhd.PackSize;
CurHeaderType=FILE_HEAD;
}
return(Raw.Size());
return(NextBlockPos>CurBlockPos ? Raw.Size():0);
}
#endif
@@ -564,18 +590,6 @@ void Archive::ConvertUnknownHeader()
}
int Archive::LhdSize()
{
return((NewLhd.Flags & LHD_LARGE) ? SIZEOF_NEWLHD+8:SIZEOF_NEWLHD);
}
int Archive::LhdExtraSize()
{
return(NewLhd.HeadSize-NewLhd.NameSize-LhdSize());
}
#ifndef SHELL_EXT
bool Archive::ReadSubData(Array<byte> *UnpData,File *DestFile)
{
@@ -587,7 +601,7 @@ bool Archive::ReadSubData(Array<byte> *UnpData,File *DestFile)
ErrHandler.SetErrorCode(RAR_CRC_ERROR);
return(false);
}
if (SubHead.Method<0x30 || SubHead.Method>0x35 || SubHead.UnpVer>PACK_VER)
if (SubHead.Method<0x30 || SubHead.Method>0x35 || SubHead.UnpVer>/*PACK_VER*/36)
{
#ifndef SHELL_EXT
Log(FileName,St(MSubHeadUnknown));
@@ -610,7 +624,8 @@ bool Archive::ReadSubData(Array<byte> *UnpData,File *DestFile)
if (SubHead.Flags & LHD_PASSWORD)
if (*Cmd->Password)
SubDataIO.SetEncryption(SubHead.UnpVer,Cmd->Password,
(SubHead.Flags & LHD_SALT) ? SubHead.Salt:NULL,false);
(SubHead.Flags & LHD_SALT) ? SubHead.Salt:NULL,false,
SubHead.UnpVer>=36);
else
return(false);
SubDataIO.SetPackedSizeToRead(SubHead.PackSize);

View File

@@ -21,6 +21,7 @@ template <class T> class Array
void Reset();
void operator = (Array<T> &Src);
void Push(T Item);
T* Addr() {return(Buffer);}
};
template <class T> void Array<T>::CleanData()

View File

@@ -65,7 +65,9 @@ void ExtractBeEA(Archive &Arc,char *FileName)
AttrPos+=10+NameSize+Size;
}
close(fd);
#ifndef GUI
mprintf(St(MShowEA));
#endif
}
@@ -108,6 +110,8 @@ void ExtractBeEANew(Archive &Arc,char *FileName)
AttrPos+=10+NameSize+Size;
}
close(fd);
#ifndef GUI
mprintf(St(MShowEA));
#endif
}

View File

@@ -2,7 +2,7 @@
CommandData::CommandData()
{
FileArgs=ExclArgs=StoreArgs=ArcNames=NULL;
FileArgs=ExclArgs=InclArgs=StoreArgs=ArcNames=NULL;
Init();
}
@@ -26,6 +26,7 @@ void CommandData::Init()
FileArgs=new StringList;
ExclArgs=new StringList;
InclArgs=new StringList;
StoreArgs=new StringList;
ArcNames=new StringList;
}
@@ -35,14 +36,15 @@ void CommandData::Close()
{
delete FileArgs;
delete ExclArgs;
delete InclArgs;
delete StoreArgs;
delete ArcNames;
FileArgs=ExclArgs=StoreArgs=ArcNames=NULL;
FileArgs=ExclArgs=InclArgs=StoreArgs=ArcNames=NULL;
NextVolSizes.Reset();
}
#if !defined(SFX_MODULE) && !defined(_WIN_CE)
#if !defined(SFX_MODULE)
void CommandData::ParseArg(char *Arg,wchar *ArgW)
{
if (IsSwitch(*Arg) && !NoMoreSwitches)
@@ -62,7 +64,7 @@ void CommandData::ParseArg(char *Arg,wchar *ArgW)
if (PointToName(SFXName)!=SFXName || FileExist(SFXName))
strcpy(SFXModule,SFXName);
else
GetConfigName(SFXName,SFXModule);
GetConfigName(SFXName,SFXModule,true);
}
#ifndef GUI
*Command=toupper(*Command);
@@ -95,8 +97,8 @@ void CommandData::ParseArg(char *Arg,wchar *ArgW)
bool Found=FindFile::FastFind(Arg,NULL,&FileData);
if (!Found && *Arg=='@' && !IsWildcard(Arg))
{
ReadTextFile(Arg+1,FileArgs,false,true,true,true,true);
FileLists=true;
ReadTextFile(Arg+1,FileArgs,false,true,true,true,true);
}
else
if (Found && FileData.IsDir && Extract && *ExtrPath==0)
@@ -137,10 +139,19 @@ void CommandData::ParseEnvVar()
#if !defined(GUI) && !defined(SFX_MODULE)
bool CommandData::IsConfigEnabled(int argc,char *argv[])
{
bool ConfigEnabled=true;
for (int I=1;I<argc;I++)
if (IsSwitch(*argv[I]) && stricomp(&argv[I][1],"cfg-")==0)
return(false);
return(true);
if (IsSwitch(*argv[I]))
{
if (stricomp(&argv[I][1],"cfg-")==0)
ConfigEnabled=false;
if (strnicomp(&argv[I][1],"ilog",4)==0)
{
ProcessSwitch(&argv[I][1]);
InitLogOptions(LogName);
}
}
return(ConfigEnabled);
}
#endif
@@ -153,8 +164,12 @@ void CommandData::ReadConfig(int argc,char *argv[])
{
char *Str;
while ((Str=List.GetString())!=NULL)
{
while (isspace(*Str))
Str++;
if (strnicomp(Str,"switches=",9)==0)
ProcessSwitchesString(Str+9);
}
}
}
#endif
@@ -182,7 +197,7 @@ void CommandData::ProcessSwitchesString(char *Str)
#endif
#if !defined(SFX_MODULE) && !defined(_WIN_CE)
#if !defined(SFX_MODULE)
void CommandData::ProcessSwitch(char *Switch)
{
@@ -215,9 +230,24 @@ void CommandData::ProcessSwitch(char *Switch)
MsgStream=MSG_NULL;
break;
}
if (stricomp(&Switch[1],"DP")==0)
if (toupper(Switch[1])=='D')
{
DisablePercentage=true;
for (int I=2;Switch[I]!=0;I++)
switch(toupper(Switch[I]))
{
case 'Q':
MsgStream=MSG_ERRONLY;
break;
case 'C':
DisableCopyright=true;
break;
case 'D':
DisableDone=true;
break;
case 'P':
DisablePercentage=true;
break;
}
break;
}
if (stricomp(&Switch[1],"OFF")==0)
@@ -347,6 +377,9 @@ void CommandData::ProcessSwitch(char *Switch)
case '-':
Overwrite=OVERWRITE_NONE;
break;
case 'R':
Overwrite=OVERWRITE_AUTORENAME;
break;
case 'W':
ProcessOwners=true;
break;
@@ -359,6 +392,9 @@ void CommandData::ProcessSwitch(char *Switch)
case 'S':
SaveStreams=true;
break;
case 'C':
SetCompressedAttr=true;
break;
#endif
default :
BadSwitch(Switch);
@@ -377,26 +413,35 @@ void CommandData::ProcessSwitch(char *Switch)
case '0':
Recurse=RECURSE_WILDCARDS;
break;
#ifndef _WIN_CE
case 'I':
{
Priority=atoi(Switch+2);
char *ChPtr=strchr(Switch+2,':');
if (ChPtr!=NULL)
{
SleepTime=atoi(ChPtr+1);
InitSystemOptions(SleepTime);
}
SetPriority(Priority);
}
break;
#endif
}
break;
case 'Y':
AllYes=true;
break;
case 'N':
case 'X':
if (Switch[1]!=0)
{
StringList *Args=toupper(Switch[0])=='N' ? InclArgs:ExclArgs;
if (Switch[1]=='@' && !IsWildcard(Switch))
ReadTextFile(Switch+2,ExclArgs,false,true,true,true,true);
ReadTextFile(Switch+2,Args,false,true,true,true,true);
else
ExclArgs->AddString(Switch+1);
Args->AddString(Switch+1);
}
break;
case 'E':
switch(toupper(Switch[1]))
@@ -413,6 +458,9 @@ void CommandData::ProcessSwitch(char *Switch)
case '2':
ExclPath=EXCL_SAVEFULLPATH;
break;
case '3':
ExclPath=EXCL_ABSPATH;
break;
}
break;
case 'D':
@@ -425,7 +473,13 @@ void CommandData::ProcessSwitch(char *Switch)
NoEndBlock=true;
break;
default:
ExclFileAttr=GetExclAttr(&Switch[1]);
if (Switch[1]=='+')
{
InclFileAttr=GetExclAttr(&Switch[2]);
InclAttrSet=true;
}
else
ExclFileAttr=GetExclAttr(&Switch[1]);
break;
}
break;
@@ -453,7 +507,8 @@ void CommandData::ProcessSwitch(char *Switch)
}
break;
case 'Z':
strncpy(CommentFile,Switch[1]!=0 ? Switch+1:"stdin",sizeof(CommentFile));
strncpy(CommentFile,Switch[1]!=0 ? Switch+1:"stdin",sizeof(CommentFile)-1);
CommentFile[sizeof(CommentFile)-1]=0;
break;
case 'M':
switch(toupper(Switch[1]))
@@ -539,6 +594,13 @@ void CommandData::ProcessSwitch(char *Switch)
}
}
break;
#ifdef PACK_SMP
case 'T':
Threads=atoi(Switch+2);
if (Threads>MaxSearchThreads)
BadSwitch(Switch);
break;
#endif
default:
Method=Switch[1]-'0';
if (Method>5 || Method<0)
@@ -630,8 +692,23 @@ void CommandData::ProcessSwitch(char *Switch)
}
break;
case 'F':
if (Switch[1]==0)
FreshFiles=true;
switch(toupper(Switch[1]))
{
case 0:
FreshFiles=true;
break;
case 'C':
if (toupper(Switch[2])=='U')
{
UnicodeComment=true;
if (*CommentFile==0 || Switch[3]!=0)
{
strncpy(CommentFile,Switch[3]!=0 ? Switch+3:"stdin",sizeof(CommentFile)-1);
CommentFile[sizeof(CommentFile)-1]=0;
}
}
break;
}
break;
case 'U':
if (Switch[1]==0)
@@ -648,7 +725,7 @@ void CommandData::ProcessSwitch(char *Switch)
if (PointToName(SFXName)!=SFXName || FileExist(SFXName))
strcpy(SFXModule,SFXName);
else
GetConfigName(SFXName,SFXModule);
GetConfigName(SFXName,SFXModule,true);
}
if (isdigit(Switch[1]))
{
@@ -673,6 +750,14 @@ void CommandData::ProcessSwitch(char *Switch)
case 'D':
Solid|=SOLID_VOLUME_DEPENDENT;
break;
case 'L':
if (isdigit(Switch[2]))
FileSizeLess=atoil(Switch+2);
break;
case 'M':
if (isdigit(Switch[2]))
FileSizeMore=atoil(Switch+2);
break;
}
break;
case 'C':
@@ -714,10 +799,12 @@ void CommandData::ProcessSwitch(char *Switch)
#endif
#if !defined(SFX_MODULE) && !defined(_WIN_CE)
#ifndef SFX_MODULE
void CommandData::BadSwitch(char *Switch)
{
#ifndef GUI
mprintf(St(MUnknownOption),Switch);
#endif
ErrHandler.Exit(RAR_USER_ERROR);
}
#endif
@@ -726,7 +813,7 @@ void CommandData::BadSwitch(char *Switch)
#ifndef GUI
void CommandData::OutTitle()
{
if (BareOutput)
if (BareOutput || DisableCopyright)
return;
#if defined(__GNUC__) && defined(SFX_MODULE)
mprintf(St(MCopyrightS));
@@ -763,29 +850,32 @@ void CommandData::OutHelp()
MUNRARTitle1,MRARTitle2,MCHelpCmd,MCHelpCmdE,MCHelpCmdL,MCHelpCmdP,
MCHelpCmdT,MCHelpCmdV,MCHelpCmdX,MCHelpSw,MCHelpSwm,MCHelpSwAC,MCHelpSwAD,
MCHelpSwAP,MCHelpSwAVm,MCHelpSwCm,MCHelpSwCFGm,MCHelpSwCL,MCHelpSwCU,
MCHelpSwDH,MCHelpSwEP,MCHelpSwF,MCHelpSwIDP,MCHelpSwIERR,MCHelpSwINUL,
MCHelpSwIOFF,MCHelpSwKB,MCHelpSwOp,MCHelpSwOm,MCHelpSwOW,MCHelpSwP,
MCHelpSwPm,MCHelpSwR,MCHelpSwRI,MCHelpSwTA,MCHelpSwTB,MCHelpSwTN,
MCHelpSwTO,MCHelpSwTS,MCHelpSwU,MCHelpSwVUnr,MCHelpSwVER,MCHelpSwVP,
MCHelpSwX,MCHelpSwXa,MCHelpSwXal,MCHelpSwY
MCHelpSwDH,MCHelpSwEP,MCHelpSwEP3,MCHelpSwF,MCHelpSwIDP,MCHelpSwIERR,
MCHelpSwINUL,MCHelpSwIOFF,MCHelpSwKB,MCHelpSwN,MCHelpSwNa,MCHelpSwNal,
MCHelpSwOp,MCHelpSwOm,MCHelpSwOC,MCHelpSwOR,MCHelpSwOW,MCHelpSwP,
MCHelpSwPm,MCHelpSwR,MCHelpSwRI,MCHelpSwSL,MCHelpSwSM,MCHelpSwTA,
MCHelpSwTB,MCHelpSwTN,MCHelpSwTO,MCHelpSwTS,MCHelpSwU,MCHelpSwVUnr,
MCHelpSwVER,MCHelpSwVP,MCHelpSwX,MCHelpSwXa,MCHelpSwXal,MCHelpSwY
#else
MRARTitle1,MRARTitle2,MCHelpCmd,MCHelpCmdA,MCHelpCmdC,MCHelpCmdCF,
MCHelpCmdCW,MCHelpCmdD,MCHelpCmdE,MCHelpCmdF,MCHelpCmdI,MCHelpCmdK,
MCHelpCmdL,MCHelpCmdM,MCHelpCmdP,MCHelpCmdR,MCHelpCmdRC,MCHelpCmdRN,
MCHelpCmdRR,MCHelpCmdRV,MCHelpCmdS,MCHelpCmdT,MCHelpCmdU,MCHelpCmdV,
MCHelpCmdX,MCHelpSw,MCHelpSwm,MCHelpSwAC,MCHelpSwAD,MCHelpSwAG,
MCHelpCmdCH,MCHelpCmdCW,MCHelpCmdD,MCHelpCmdE,MCHelpCmdF,MCHelpCmdI,
MCHelpCmdK,MCHelpCmdL,MCHelpCmdM,MCHelpCmdP,MCHelpCmdR,MCHelpCmdRC,
MCHelpCmdRN,MCHelpCmdRR,MCHelpCmdRV,MCHelpCmdS,MCHelpCmdT,MCHelpCmdU,
MCHelpCmdV,MCHelpCmdX,MCHelpSw,MCHelpSwm,MCHelpSwAC,MCHelpSwAD,MCHelpSwAG,
MCHelpSwAO,MCHelpSwAP,MCHelpSwAS,MCHelpSwAV,MCHelpSwAVm,MCHelpSwCm,
MCHelpSwCFGm,MCHelpSwCL,MCHelpSwCU,MCHelpSwDF,MCHelpSwDH,MCHelpSwDS,
MCHelpSwEa,MCHelpSwED,MCHelpSwEE,MCHelpSwEN,MCHelpSwEP,MCHelpSwEP1,
MCHelpSwEP2,MCHelpSwF,MCHelpSwHP,MCHelpSwIDP,MCHelpSwIEML,MCHelpSwIERR,
MCHelpSwILOG,MCHelpSwINUL,MCHelpSwIOFF,MCHelpSwISND,MCHelpSwK,MCHelpSwKB,
MCHelpSwMn,MCHelpSwMC,MCHelpSwMD,MCHelpSwMS,MCHelpSwOp,MCHelpSwOm,
MCHelpSwOL,MCHelpSwOS,MCHelpSwOW,MCHelpSwP,MCHelpSwPm,MCHelpSwR,
MCHelpSwR0,MCHelpSwRI,MCHelpSwRR,MCHelpSwRV,MCHelpSwS,MCHelpSwSm,
MCHelpSwSFX,MCHelpSwSI,MCHelpSwT,MCHelpSwTA,MCHelpSwTB,MCHelpSwTK,
MCHelpSwTL,MCHelpSwTN,MCHelpSwTO,MCHelpSwTS,MCHelpSwU,MCHelpSwV,
MCHelpSwVn,MCHelpSwVD,MCHelpSwVER,MCHelpSwVN,MCHelpSwVP,MCHelpSwW,
MCHelpSwX,MCHelpSwXa,MCHelpSwXal,MCHelpSwY,MCHelpSwZ
MCHelpSwEP2,MCHelpSwEP3,MCHelpSwF,MCHelpSwFCU,MCHelpSwHP,MCHelpSwIDP,
MCHelpSwIEML,MCHelpSwIERR,MCHelpSwILOG,MCHelpSwINUL,MCHelpSwIOFF,
MCHelpSwISND,MCHelpSwK,MCHelpSwKB,MCHelpSwMn,MCHelpSwMC,MCHelpSwMD,
MCHelpSwMS,MCHelpSwMT,MCHelpSwN,MCHelpSwNa,MCHelpSwNal,MCHelpSwOp,
MCHelpSwOm,MCHelpSwOC,MCHelpSwOL,MCHelpSwOR,MCHelpSwOS,MCHelpSwOW,
MCHelpSwP,MCHelpSwPm,MCHelpSwR,MCHelpSwR0,MCHelpSwRI,MCHelpSwRR,
MCHelpSwRV,MCHelpSwS,MCHelpSwSm,MCHelpSwSFX,MCHelpSwSI,MCHelpSwSL,
MCHelpSwSM,MCHelpSwT,MCHelpSwTA,MCHelpSwTB,MCHelpSwTK,MCHelpSwTL,
MCHelpSwTN,MCHelpSwTO,MCHelpSwTS,MCHelpSwU,MCHelpSwV,MCHelpSwVn,
MCHelpSwVD,MCHelpSwVER,MCHelpSwVN,MCHelpSwVP,MCHelpSwW,MCHelpSwX,
MCHelpSwXa,MCHelpSwXal,MCHelpSwY,MCHelpSwZ
#endif
};
@@ -797,8 +887,18 @@ void CommandData::OutHelp()
continue;
#endif
#ifndef _WIN_32
if (Help[I]==MCHelpSwIEML || Help[I]==MCHelpSwVD || Help[I]==MCHelpSwAC ||
Help[I]==MCHelpSwAO || Help[I]==MCHelpSwOS || Help[I]==MCHelpSwIOFF)
static MSGID Win32Only[]={
MCHelpSwIEML,MCHelpSwVD,MCHelpSwAC,MCHelpSwAO,MCHelpSwOS,MCHelpSwIOFF,
MCHelpSwEP2,MCHelpSwOC
};
bool Found=false;
for (int J=0;J<sizeof(Win32Only)/sizeof(Win32Only[0]);J++)
if (Help[I]==Win32Only[J])
{
Found=true;
break;
}
if (Found)
continue;
#endif
#if !defined(_UNIX) && !defined(_WIN_32)
@@ -809,11 +909,15 @@ void CommandData::OutHelp()
if (Help[I]==MCHelpSwOL)
continue;
#endif
#if defined(_WIN_32) && !defined(_WIN_CE)
#ifndef _WIN_32
if (Help[I]==MCHelpSwRI)
continue;
#endif
#if !defined(_BEOS)
#ifndef PACK_SMP
if (Help[I]==MCHelpSwMT)
continue;
#endif
#ifndef _BEOS
if (Help[I]==MCHelpSwEE)
{
#if defined(_EMX) && !defined(_DJGPP)
@@ -828,31 +932,43 @@ void CommandData::OutHelp()
mprintf(St(Help[I]));
}
mprintf("\n");
ErrHandler.Exit(0);
ErrHandler.Exit(RAR_USER_ERROR);
#endif
}
bool CommandData::ExclCheckArgs(StringList *Args,char *CheckName,bool CheckFullPath,int MatchMode)
{
char *Name=ConvertPath(CheckName,NULL);
char FullName[NM],*CurName;
*FullName=0;
Args->Rewind();
while ((CurName=Args->GetString())!=NULL)
#ifndef SFX_MODULE
if (CheckFullPath && IsFullPath(CurName))
{
if (*FullName==0)
ConvertNameToFull(CheckName,FullName);
if (CmpName(CurName,FullName,MatchMode))
return(true);
}
else
#endif
if (CmpName(ConvertPath(CurName,NULL),Name,MatchMode))
return(true);
return(false);
}
bool CommandData::ExclCheck(char *CheckName,bool CheckFullPath)
{
char *Name=ConvertPath(CheckName,NULL);
char FullName[NM],*ExclName;
*FullName=0;
ExclArgs->Rewind();
while ((ExclName=ExclArgs->GetString())!=NULL)
#ifndef SFX_MODULE
if (CheckFullPath && IsFullPath(ExclName))
{
if (*FullName==0)
ConvertNameToFull(CheckName,FullName);
if (CmpName(ExclName,FullName,MATCH_WILDSUBPATH))
return(true);
}
else
#endif
if (CmpName(ConvertPath(ExclName,NULL),Name,MATCH_WILDSUBPATH))
return(true);
return(false);
if (ExclCheckArgs(ExclArgs,CheckName,CheckFullPath,MATCH_WILDSUBPATH))
return(true);
if (InclArgs->ItemsCount()==0)
return(false);
if (ExclCheckArgs(InclArgs,CheckName,CheckFullPath,MATCH_WILDSUBPATH))
return(false);
return(true);
}
@@ -888,6 +1004,18 @@ bool CommandData::TimeCheck(RarTime &ft)
#endif
#ifndef SFX_MODULE
bool CommandData::SizeCheck(Int64 Size)
{
if (FileSizeLess!=INT64ERR && Size>=FileSizeLess)
return(true);
if (FileSizeMore!=INT64ERR && Size<=FileSizeMore)
return(true);
return(false);
}
#endif
int CommandData::IsProcessFile(FileHeader &NewLhd,bool *ExactMatch,int MatchType)
{
if (strlen(NewLhd.FileName)>=NM || strlenw(NewLhd.FileNameW)>=NM)
@@ -897,6 +1025,10 @@ int CommandData::IsProcessFile(FileHeader &NewLhd,bool *ExactMatch,int MatchType
#ifndef SFX_MODULE
if (TimeCheck(NewLhd.mtime))
return(0);
if ((NewLhd.FileAttr & ExclFileAttr)!=0 || InclAttrSet && (NewLhd.FileAttr & InclFileAttr)==0)
return(0);
if ((NewLhd.Flags & LHD_WINDOWMASK)!=LHD_DIRECTORY && SizeCheck(NewLhd.FullUnpSize))
return(0);
#endif
char *ArgName;
wchar *ArgNameW;
@@ -908,14 +1040,17 @@ int CommandData::IsProcessFile(FileHeader &NewLhd,bool *ExactMatch,int MatchType
if (Unicode)
{
wchar NameW[NM],ArgW[NM],*NamePtr=NewLhd.FileNameW;
bool CorrectUnicode=true;
if (ArgNameW==NULL)
{
CharToWide(ArgName,ArgW);
if (!CharToWide(ArgName,ArgW) || *ArgW==0)
CorrectUnicode=false;
ArgNameW=ArgW;
}
if ((NewLhd.Flags & LHD_UNICODE)==0)
{
CharToWide(NewLhd.FileName,NameW);
if (!CharToWide(NewLhd.FileName,NameW) || *NameW==0)
CorrectUnicode=false;
NamePtr=NameW;
}
if (CmpName(ArgNameW,NamePtr,MatchType))
@@ -924,6 +1059,8 @@ int CommandData::IsProcessFile(FileHeader &NewLhd,bool *ExactMatch,int MatchType
*ExactMatch=stricompcw(ArgNameW,NamePtr)==0;
return(StringCount);
}
if (CorrectUnicode)
continue;
}
#endif
if (CmpName(ArgName,NewLhd.FileName,MatchType))
@@ -937,7 +1074,7 @@ int CommandData::IsProcessFile(FileHeader &NewLhd,bool *ExactMatch,int MatchType
}
#ifndef _WIN_CE
#ifndef GUI
void CommandData::ProcessCommand()
{
#ifndef SFX_MODULE
@@ -977,7 +1114,7 @@ void CommandData::ProcessCommand()
Extract.DoExtract(this);
}
break;
#if !defined(GUI) && !defined(SILENT)
#ifndef SILENT
case 'V':
case 'L':
ListArchive(this);
@@ -986,10 +1123,8 @@ void CommandData::ProcessCommand()
OutHelp();
#endif
}
#ifndef GUI
if (!BareOutput)
mprintf("\n");
#endif
}
#endif
@@ -1021,18 +1156,22 @@ bool CommandData::IsSwitch(int Ch)
#ifndef SFX_MODULE
uint CommandData::GetExclAttr(char *Str)
{
#ifdef _UNIX
return(strtol(Str,NULL,0));
#endif
#if defined(_WIN_32) || defined(_EMX)
uint Attr;
if (isdigit(*Str))
return(strtol(Str,NULL,0));
else
{
uint Attr;
for (Attr=0;*Str;Str++)
switch(toupper(*Str))
{
#ifdef _UNIX
case 'D':
Attr|=S_IFDIR;
break;
case 'V':
Attr|=S_IFCHR;
break;
#elif defined(_WIN_32) || defined(_EMX)
case 'R':
Attr|=0x1;
break;
@@ -1048,10 +1187,10 @@ uint CommandData::GetExclAttr(char *Str)
case 'A':
Attr|=0x20;
break;
#endif
}
return(Attr);
}
#endif
}
#endif

View File

@@ -1,7 +1,7 @@
#ifndef _RAR_CMDDATA_
#define _RAR_CMDDATA_
#define DefaultStoreList "ace;arj;bz2;cab;gz;jpeg;jpg;lha;lzh;mp3;rar;zip;taz;tgz;z"
#define DefaultStoreList "7z;ace;arj;bz2;cab;gz;jpeg;jpg;lha;lzh;mp3;rar;taz;tgz;z;zip"
class CommandData:public RAROptions
{
@@ -9,6 +9,7 @@ class CommandData:public RAROptions
void ProcessSwitchesString(char *Str);
void ProcessSwitch(char *Switch);
void BadSwitch(char *Switch);
bool ExclCheckArgs(StringList *Args,char *CheckName,bool CheckFullPath,int MatchMode);
uint GetExclAttr(char *Str);
bool FileLists;
@@ -31,6 +32,7 @@ class CommandData:public RAROptions
bool ExclCheck(char *CheckName,bool CheckFullPath);
bool StoreCheck(char *CheckName);
bool TimeCheck(RarTime &ft);
bool SizeCheck(Int64 Size);
int IsProcessFile(FileHeader &NewLhd,bool *ExactMatch=NULL,int MatchType=MATCH_WILDSUBPATH);
void ProcessCommand();
void AddArcName(char *Name,wchar *NameW);
@@ -47,6 +49,7 @@ class CommandData:public RAROptions
StringList *FileArgs;
StringList *ExclArgs;
StringList *InclArgs;
StringList *ArcNames;
StringList *StoreArgs;
};

View File

@@ -4,7 +4,9 @@
#include "log.cpp"
#endif
#if !defined(GUI) && !defined(SILENT)
static void RawPrint(char *Msg,MESSAGE_TYPE MessageType);
#endif
static MESSAGE_TYPE MsgStream=MSG_STDOUT;
static bool Sound=false;
@@ -19,7 +21,7 @@ void InitConsoleOptions(MESSAGE_TYPE MsgStream,bool Sound)
#if !defined(GUI) && !defined(SILENT)
void mprintf(const char *fmt,...)
{
if (MsgStream==MSG_NULL)
if (MsgStream==MSG_NULL || MsgStream==MSG_ERRONLY)
return;
safebuf char Msg[MaxMsgSize];
va_list argptr;
@@ -56,6 +58,7 @@ void RawPrint(char *Msg,MESSAGE_TYPE MessageType)
OutFile.SetHandleType(FILE_HANDLESTD);
break;
case MSG_STDERR:
case MSG_ERRONLY:
OutFile.SetHandleType(FILE_HANDLEERR);
break;
default:
@@ -118,7 +121,7 @@ void GetPasswordText(char *Str,int MaxLength)
OemToChar(Str,Str);
SetConsoleMode(hConIn,ConInMode);
SetConsoleMode(hConOut,ConOutMode);
#elif defined(_EMX) || defined(_BEOS)
#elif defined(_EMX) || defined(_BEOS) || defined(__sparc) || defined(sparc)
fgets(Str,MaxLength-1,stdin);
#else
strncpy(Str,getpass(""),MaxLength-1);

View File

@@ -21,12 +21,21 @@ int KbdAnsi(char *Addr,int Size);
void OutComment(char *Comment,int Size);
#ifdef SILENT
inline void mprintf(const char *fmt,const char *a=NULL,const char *b=NULL) {}
inline void eprintf(const char *fmt,const char *a=NULL,const char *b=NULL) {}
inline void mprintf(const char *fmt,int b) {}
inline void eprintf(const char *fmt,int b) {}
inline void mprintf(const char *fmt,const char *a,int b) {}
inline void eprintf(const char *fmt,const char *a,int b) {}
#ifdef __GNUC__
#define mprintf(args...)
#define eprintf(args...)
#else
#ifdef _MSC_VER
inline void mprintf(const char *fmt,...) {}
#else
inline void mprintf(const char *fmt,const char *a=NULL,const char *b=NULL) {}
#endif
inline void eprintf(const char *fmt,const char *a=NULL,const char *b=NULL) {}
inline void mprintf(const char *fmt,int b) {}
inline void eprintf(const char *fmt,int b) {}
inline void mprintf(const char *fmt,const char *a,int b) {}
inline void eprintf(const char *fmt,const char *a,int b) {}
#endif
inline void Alarm() {}
inline void GetPasswordText(char *Str,int MaxLength) {}
inline unsigned int GetKey() {return(0);}

View File

@@ -14,13 +14,13 @@ void InitCRC()
}
uint CRC(uint StartCRC,void *Addr,uint Size)
uint CRC(uint StartCRC,const void *Addr,uint Size)
{
if (CRCTab[1]==0)
InitCRC();
byte *Data=(byte *)Addr;
#if defined(LITTLE_ENDIAN) && defined(PRESENT_INT32)
while (Size>0 && ((int)Data & 7))
#if defined(LITTLE_ENDIAN) && defined(PRESENT_INT32) && defined(ALLOW_NOT_ALIGNED_INT)
while (Size>0 && ((long)Data & 7))
{
StartCRC=CRCTab[(byte)(StartCRC^Data[0])]^(StartCRC>>8);
Size--;
@@ -48,7 +48,7 @@ uint CRC(uint StartCRC,void *Addr,uint Size)
}
#ifndef SFX_MODULE
ushort OldCRC(ushort StartCRC,void *Addr,uint Size)
ushort OldCRC(ushort StartCRC,const void *Addr,uint Size)
{
byte *Data=(byte *)Addr;
for (int I=0;I<Size;I++)

View File

@@ -4,7 +4,7 @@
extern uint CRCTab[256];
void InitCRC();
uint CRC(uint StartCRC,void *Addr,uint Size);
ushort OldCRC(ushort StartCRC,void *Addr,uint Size);
uint CRC(uint StartCRC,const void *Addr,uint Size);
ushort OldCRC(ushort StartCRC,const void *Addr,uint Size);
#endif

View File

@@ -39,11 +39,6 @@ static byte InitSubstTable[256]={
};
#endif
CryptData::CryptData()
{
}
void CryptData::DecryptBlock(byte *Buf,int Size)
@@ -190,7 +185,7 @@ void CryptData::Swap(byte *Ch1,byte *Ch2)
#endif
void CryptData::SetCryptKeys(char *Password,byte *Salt,bool Encrypt,bool OldOnly)
void CryptData::SetCryptKeys(char *Password,byte *Salt,bool Encrypt,bool OldOnly,bool HandsOffHash)
{
if (*Password==0)
return;
@@ -231,7 +226,8 @@ void CryptData::SetCryptKeys(char *Password,byte *Salt,bool Encrypt,bool OldOnly
for (int I=0;I<sizeof(Cache)/sizeof(Cache[0]);I++)
if (strcmp(Cache[I].Password,Password)==0 &&
(Salt==NULL && !Cache[I].SaltPresent || Salt!=NULL &&
Cache[I].SaltPresent && memcmp(Cache[I].Salt,Salt,SALT_SIZE)==0))
Cache[I].SaltPresent && memcmp(Cache[I].Salt,Salt,SALT_SIZE)==0) &&
Cache[I].HandsOffHash==HandsOffHash)
{
memcpy(AESKey,Cache[I].AESKey,sizeof(AESKey));
memcpy(AESInit,Cache[I].AESInit,sizeof(AESInit));
@@ -258,22 +254,22 @@ void CryptData::SetCryptKeys(char *Password,byte *Salt,bool Encrypt,bool OldOnly
const int HashRounds=0x40000;
for (int I=0;I<HashRounds;I++)
{
hash_process( &c, RawPsw, RawLength);
hash_process( &c, RawPsw, RawLength, HandsOffHash);
byte PswNum[3];
PswNum[0]=(byte)I;
PswNum[1]=(byte)(I>>8);
PswNum[2]=(byte)(I>>16);
hash_process( &c, PswNum, 3);
hash_process( &c, PswNum, 3, HandsOffHash);
if (I%(HashRounds/16)==0)
{
hash_context tempc=c;
uint32 digest[5];
hash_final( &tempc, digest);
hash_final( &tempc, digest, HandsOffHash);
AESInit[I/(HashRounds/16)]=(byte)digest[4];
}
}
uint32 digest[5];
hash_final( &c, digest);
hash_final( &c, digest, HandsOffHash);
for (int I=0;I<4;I++)
for (int J=0;J<4;J++)
AESKey[I*4+J]=(byte)(digest[I]>>(J*8));
@@ -281,6 +277,7 @@ void CryptData::SetCryptKeys(char *Password,byte *Salt,bool Encrypt,bool OldOnly
strcpy(Cache[CachePos].Password,Password);
if ((Cache[CachePos].SaltPresent=(Salt!=NULL))==true)
memcpy(Cache[CachePos].Salt,Salt,SALT_SIZE);
Cache[CachePos].HandsOffHash=HandsOffHash;
memcpy(Cache[CachePos].AESKey,AESKey,sizeof(AESKey));
memcpy(Cache[CachePos].AESInit,AESInit,sizeof(AESInit));
CachePos=(CachePos+1)%(sizeof(Cache)/sizeof(Cache[0]));

View File

@@ -3,6 +3,7 @@
enum { OLD_DECODE=0,OLD_ENCODE=1,NEW_CRYPT=2 };
struct CryptKeyCacheItem
{
#ifndef _SFX_RTL_
@@ -22,6 +23,7 @@ struct CryptKeyCacheItem
char Password[MAXPASSWORD];
bool SaltPresent;
byte Salt[SALT_SIZE];
bool HandsOffHash;
};
class CryptData
@@ -46,8 +48,7 @@ class CryptData
static CryptKeyCacheItem Cache[4];
static int CachePos;
public:
CryptData();
void SetCryptKeys(char *Password,byte *Salt,bool Encrypt,bool OldOnly=false);
void SetCryptKeys(char *Password,byte *Salt,bool Encrypt,bool OldOnly,bool HandsOffHash);
void SetAV15Encryption();
void SetCmt13Encryption();
void EncryptBlock20(byte *Buf);

View File

@@ -37,6 +37,7 @@ HANDLE PASCAL RAROpenArchiveEx(struct RAROpenArchiveDataEx *r)
{
r->OpenResult=0;
DataSet *Data=new DataSet;
Data->Cmd.DllError=0;
Data->OpenMode=r->OpenMode;
Data->Cmd.FileArgs->AddString("*");
@@ -59,12 +60,12 @@ HANDLE PASCAL RAROpenArchiveEx(struct RAROpenArchiveDataEx *r)
if (!Data->Arc.IsArchive(false))
{
delete Data;
r->OpenResult=ERAR_BAD_ARCHIVE;
r->OpenResult=Data->Cmd.DllError!=0 ? Data->Cmd.DllError:ERAR_BAD_ARCHIVE;
return(NULL);
}
r->Flags=Data->Arc.NewMhd.Flags;
Array<byte> CmtData;
if (r->CmtBufSize!=0 && Data->Arc.GetComment(CmtData))
if (r->CmtBufSize!=0 && Data->Arc.GetComment(&CmtData,NULL))
{
r->Flags|=2;
int Size=CmtData.Size()+1;
@@ -118,8 +119,11 @@ int PASCAL RARReadHeader(HANDLE hArcData,struct RARHeaderData *D)
}
if (Data->OpenMode==RAR_OM_LIST && (Data->Arc.NewLhd.Flags & LHD_SPLIT_BEFORE))
{
if (RARProcessFile(hArcData,RAR_SKIP,NULL,NULL)==0)
int Code=RARProcessFile(hArcData,RAR_SKIP,NULL,NULL);
if (Code==0)
return(RARReadHeader(hArcData,D));
else
return(Code);
}
strncpy(D->ArcName,Data->Arc.FileName,sizeof(D->ArcName));
strncpy(D->FileName,Data->Arc.NewLhd.FileName,sizeof(D->FileName));
@@ -163,8 +167,11 @@ int PASCAL RARReadHeaderEx(HANDLE hArcData,struct RARHeaderDataEx *D)
}
if (Data->OpenMode==RAR_OM_LIST && (Data->Arc.NewLhd.Flags & LHD_SPLIT_BEFORE))
{
if (RARProcessFile(hArcData,RAR_SKIP,NULL,NULL)==0)
int Code=RARProcessFile(hArcData,RAR_SKIP,NULL,NULL);
if (Code==0)
return(RARReadHeaderEx(hArcData,D));
else
return(Code);
}
strncpy(D->ArcName,Data->Arc.FileName,sizeof(D->ArcName));
if (*Data->Arc.FileNameW)

View File

@@ -63,7 +63,7 @@ void ErrorHandler::ReadError(const char *FileName)
bool ErrorHandler::AskRepeatRead(const char *FileName)
{
#if !defined(SILENT) && !defined(SFX_MODULE) && !defined(_WIN_CE)
#if !defined(SILENT) && !defined(SFX_MODULE) && !defined(_WIN_CE) && !defined(GUI)
if (!Silent)
{
mprintf("\n");
@@ -102,7 +102,7 @@ void ErrorHandler::WriteErrorFAT(const char *FileName)
bool ErrorHandler::AskRepeatWrite(const char *FileName)
{
#if !defined(SILENT) && !defined(_WIN_CE)
#if !defined(SILENT) && !defined(_WIN_CE) && !defined(GUI)
if (!Silent)
{
mprintf("\n");
@@ -129,6 +129,15 @@ void ErrorHandler::SeekError(const char *FileName)
}
void ErrorHandler::GeneralErrMsg(const char *Msg)
{
#ifndef SILENT
Log(NULL,"%s",Msg);
SysErrMsg();
#endif
}
void ErrorHandler::MemoryErrorMsg()
{
#ifndef SILENT
@@ -319,7 +328,8 @@ void ErrorHandler::Throw(int Code)
void ErrorHandler::SysErrMsg()
{
#if defined(_WIN_32) && !defined(SFX_MODULE) && !defined(SILENT)
#if !defined(SFX_MODULE) && !defined(SILENT)
#ifdef _WIN_32
#define STRCHR strchr
#define ERRCHAR char
ERRCHAR *lpMsgBuf=NULL;
@@ -349,4 +359,16 @@ void ErrorHandler::SysErrMsg()
}
LocalFree( lpMsgBuf );
#endif
#if defined(_UNIX) || defined(_EMX)
char *err=strerror(errno);
if (err!=NULL)
Log(NULL,"\n%s",err);
#endif
#endif
}

View File

@@ -40,6 +40,7 @@ class ErrorHandler
void WriteErrorFAT(const char *FileName);
bool AskRepeatWrite(const char *FileName);
void SeekError(const char *FileName);
void GeneralErrMsg(const char *Msg);
void MemoryErrorMsg();
void OpenErrorMsg(const char *FileName);
void OpenErrorMsg(const char *ArcName,const char *FileName);

View File

@@ -18,6 +18,7 @@ CmdExtract::~CmdExtract()
void CmdExtract::DoExtract(CommandData *Cmd)
{
PasswordCancelled=false;
DataIO.SetCurrentCommand(*Cmd->Command);
struct FindData FD;
@@ -35,18 +36,24 @@ void CmdExtract::DoExtract(CommandData *Cmd)
if (TotalFileCount==0 && *Cmd->Command!='I')
{
mprintf(St(MExtrNoFiles));
if (!PasswordCancelled)
{
#ifndef GUI
mprintf(St(MExtrNoFiles));
#endif
}
ErrHandler.SetErrorCode(RAR_WARNING);
}
#ifndef GUI
else
if (*Cmd->Command=='I')
mprintf(St(MDone));
else
if (ErrHandler.GetErrorCount()==0)
mprintf(St(MExtrAllOk));
if (!Cmd->DisableDone)
if (*Cmd->Command=='I')
mprintf(St(MDone));
else
mprintf(St(MExtrTotalErr),ErrHandler.GetErrorCount());
if (ErrHandler.GetErrorCount()==0)
mprintf(St(MExtrAllOk));
else
mprintf(St(MExtrTotalErr),ErrHandler.GetErrorCount());
#endif
}
@@ -210,8 +217,10 @@ bool CmdExtract::ExtractCurrentFile(CommandData *Cmd,Archive &Arc,int HeaderSize
wchar ArcFileNameW[NM];
*ArcFileNameW=0;
int MatchType=MATCH_WILDSUBPATH;
bool EqualNames=false;
int MatchNumber=Cmd->IsProcessFile(Arc.NewLhd,&EqualNames);
int MatchNumber=Cmd->IsProcessFile(Arc.NewLhd,&EqualNames,MatchType);
bool ExactMatch=MatchNumber!=0;
#if !defined(SFX_MODULE) && !defined(_WIN_CE)
if (Cmd->ExclPath==EXCL_BASEPATH)
@@ -229,7 +238,7 @@ bool CmdExtract::ExtractCurrentFile(CommandData *Cmd,Archive &Arc,int HeaderSize
AllMatchesExact=false;
#ifdef UNICODE_SUPPORTED
bool WideName=(Arc.NewLhd.Flags & LHD_UNICODE);
bool WideName=(Arc.NewLhd.Flags & LHD_UNICODE) && UnicodeEnabled();
#else
bool WideName=false;
#endif
@@ -249,8 +258,7 @@ bool CmdExtract::ExtractCurrentFile(CommandData *Cmd,Archive &Arc,int HeaderSize
{
ConvertPath(Arc.NewLhd.FileNameW,ArcFileNameW);
char Name[NM];
WideToChar(ArcFileNameW,Name);
if (IsNameUsable(Name))
if (WideToChar(ArcFileNameW,Name) && IsNameUsable(Name))
strcpy(ArcFileName,Name);
}
#endif
@@ -326,6 +334,7 @@ bool CmdExtract::ExtractCurrentFile(CommandData *Cmd,Archive &Arc,int HeaderSize
#ifdef RARDLL
Cmd->DllError=ERAR_BAD_DATA;
#endif
ErrHandler.SetErrorCode(RAR_WARNING);
}
ExactMatch=false;
}
@@ -350,6 +359,7 @@ bool CmdExtract::ExtractCurrentFile(CommandData *Cmd,Archive &Arc,int HeaderSize
#else
if (!GetPassword(PASSWORD_FILE,ArcFileName,Password,sizeof(Password)))
{
PasswordCancelled=true;
return(false);
}
#endif
@@ -395,21 +405,34 @@ bool CmdExtract::ExtractCurrentFile(CommandData *Cmd,Archive &Arc,int HeaderSize
char *ExtrName=ArcFileName;
bool EmptyName=false;
#ifndef SFX_MODULE
int Length=strlen(Cmd->ArcPath);
if (Length>1 && IsPathDiv(Cmd->ArcPath[Length-1]) &&
strlen(ArcFileName)==Length-1)
Length--;
if (Length>0 && strnicomp(Cmd->ArcPath,ArcFileName,Length)==0)
{
ExtrName+=Length;
while (*ExtrName==CPATHDIVIDER)
ExtrName++;
if (*ExtrName==0)
EmptyName=true;
}
#endif
bool AbsPaths=Cmd->ExclPath==EXCL_ABSPATH && Command=='X' && IsDriveDiv(':');
if (AbsPaths)
*DestFileName=0;
if (Command=='E' || Cmd->ExclPath==EXCL_SKIPWHOLEPATH)
strcat(DestFileName,PointToName(ExtrName));
else
strcat(DestFileName,ExtrName);
if (AbsPaths && DestFileName[1]=='_' && IsPathDiv(DestFileName[2]))
DestFileName[1]=':';
#ifndef SFX_MODULE
if (!WideName && *Cmd->ExtrPathW!=0)
{
@@ -452,15 +475,21 @@ bool CmdExtract::ExtractCurrentFile(CommandData *Cmd,Archive &Arc,int HeaderSize
ExtrNameW++;
#endif
if (AbsPaths)
*DestFileNameW=0;
if (Command=='E' || Cmd->ExclPath==EXCL_SKIPWHOLEPATH)
strcatw(DestFileNameW,PointToName(ExtrNameW));
else
strcatw(DestFileNameW,ExtrNameW);
if (AbsPaths && DestFileNameW[1]=='_' && IsPathDiv(DestFileNameW[2]))
DestFileNameW[1]=':';
}
else
*DestFileNameW=0;
ExtrFile=!SkipSolid/* && *ExtrName*/;
ExtrFile=!SkipSolid && !EmptyName && (Arc.NewLhd.Flags & LHD_SPLIT_BEFORE)==0/* && *ExtrName*/;
if ((Cmd->FreshFiles || Cmd->UpdateFiles) && (Command=='E' || Command=='X'))
{
struct FindData FD;
@@ -492,7 +521,8 @@ bool CmdExtract::ExtractCurrentFile(CommandData *Cmd,Archive &Arc,int HeaderSize
#endif
#ifdef SFX_MODULE
if (Arc.NewLhd.UnpVer!=UNP_VER && Arc.NewLhd.Method!=0x30)
if ((Arc.NewLhd.UnpVer!=UNP_VER && Arc.NewLhd.UnpVer!=29) &&
Arc.NewLhd.Method!=0x30)
#else
if (Arc.NewLhd.UnpVer<13 || Arc.NewLhd.UnpVer>UNP_VER)
#endif
@@ -541,7 +571,7 @@ bool CmdExtract::ExtractCurrentFile(CommandData *Cmd,Archive &Arc,int HeaderSize
if (DirExist && !IsDir(GetFileAttr(DestFileName,DestNameW)))
{
bool UserReject;
FileCreate(Cmd,NULL,DestFileName,DestNameW,Cmd->Overwrite,&UserReject,Arc.NewLhd.UnpSize,Arc.NewLhd.FileTime);
FileCreate(Cmd,NULL,DestFileName,DestNameW,Cmd->Overwrite,&UserReject,Arc.NewLhd.FullUnpSize,Arc.NewLhd.FileTime);
DirExist=false;
}
CreatePath(DestFileName,DestNameW,true);
@@ -571,10 +601,17 @@ bool CmdExtract::ExtractCurrentFile(CommandData *Cmd,Archive &Arc,int HeaderSize
ErrHandler.SetErrorCode(RAR_CREATE_ERROR);
}
if (PrevExtracted)
{
#if defined(_WIN_32) && !defined(_WIN_CE) && !defined(SFX_MODULE)
if (Cmd->SetCompressedAttr &&
(Arc.NewLhd.FileAttr & FILE_ATTRIBUTE_COMPRESSED)!=0 && WinNT())
SetFileCompression(DestFileName,DestFileNameW,true);
#endif
SetDirTime(DestFileName,
Cmd->xmtime==EXTTIME_NONE ? NULL:&Arc.NewLhd.mtime,
Cmd->xctime==EXTTIME_NONE ? NULL:&Arc.NewLhd.ctime,
Cmd->xatime==EXTTIME_NONE ? NULL:&Arc.NewLhd.atime);
}
return(true);
}
else
@@ -588,7 +625,7 @@ bool CmdExtract::ExtractCurrentFile(CommandData *Cmd,Archive &Arc,int HeaderSize
if ((Command=='E' || Command=='X') && ExtrFile && !Cmd->Test)
{
bool UserReject;
if (!FileCreate(Cmd,&CurFile,DestFileName,DestNameW,Cmd->Overwrite,&UserReject,Arc.NewLhd.UnpSize,Arc.NewLhd.FileTime))
if (!FileCreate(Cmd,&CurFile,DestFileName,DestNameW,Cmd->Overwrite,&UserReject,Arc.NewLhd.FullUnpSize,Arc.NewLhd.FileTime))
{
ExtrFile=false;
if (!UserReject)
@@ -601,10 +638,19 @@ bool CmdExtract::ExtractCurrentFile(CommandData *Cmd,Archive &Arc,int HeaderSize
if (!IsNameUsable(DestFileName))
{
Log(Arc.FileName,St(MCorrectingName));
char OrigName[sizeof(DestFileName)];
strncpy(OrigName,DestFileName,sizeof(OrigName)-1);
OrigName[sizeof(OrigName)-1]=0;
MakeNameUsable(DestFileName,true);
CreatePath(DestFileName,NULL,true);
if (FileCreate(Cmd,&CurFile,DestFileName,NULL,Cmd->Overwrite,&UserReject,Arc.NewLhd.FullUnpSize,Arc.NewLhd.FileTime))
{
#ifndef SFX_MODULE
Log(Arc.FileName,St(MRenaming),OrigName,DestFileName);
#endif
ExtrFile=true;
}
else
ErrHandler.CreateErrorMsg(Arc.FileName,DestFileName);
}
@@ -660,7 +706,8 @@ bool CmdExtract::ExtractCurrentFile(CommandData *Cmd,Archive &Arc,int HeaderSize
DataIO.PackedCRC=0xffffffff;
DataIO.SetEncryption(
(Arc.NewLhd.Flags & LHD_PASSWORD) ? Arc.NewLhd.UnpVer:0,Password,
(Arc.NewLhd.Flags & LHD_SALT) ? Arc.NewLhd.Salt:NULL,false);
(Arc.NewLhd.Flags & LHD_SALT) ? Arc.NewLhd.Salt:NULL,false,
Arc.NewLhd.UnpVer>=36);
DataIO.SetPackedSizeToRead(Arc.NewLhd.FullPackSize);
DataIO.SetFiles(&Arc,&CurFile);
DataIO.SetTestMode(TestMode);
@@ -674,20 +721,23 @@ bool CmdExtract::ExtractCurrentFile(CommandData *Cmd,Archive &Arc,int HeaderSize
CurFile.SetAllowDelete(!Cmd->KeepBroken);
if (!ExtractLink(DataIO,Arc,DestFileName,DataIO.UnpFileCRC,Command=='X' || Command=='E') &&
(Arc.NewLhd.Flags & LHD_SPLIT_BEFORE)==0)
if (Arc.NewLhd.Method==0x30)
UnstoreFile(DataIO,Arc.NewLhd.FullUnpSize);
else
{
Unp->SetDestSize(Arc.NewLhd.FullUnpSize);
#ifndef SFX_MODULE
if (Arc.NewLhd.UnpVer<=15)
Unp->DoUnpack(15,FileCount>1 && Arc.Solid);
bool LinkCreateMode=!Cmd->Test && !SkipSolid;
if (ExtractLink(DataIO,Arc,DestFileName,DataIO.UnpFileCRC,LinkCreateMode))
PrevExtracted=LinkCreateMode;
else
if ((Arc.NewLhd.Flags & LHD_SPLIT_BEFORE)==0)
if (Arc.NewLhd.Method==0x30)
UnstoreFile(DataIO,Arc.NewLhd.FullUnpSize);
else
{
Unp->SetDestSize(Arc.NewLhd.FullUnpSize);
#ifndef SFX_MODULE
if (Arc.NewLhd.UnpVer<=15)
Unp->DoUnpack(15,FileCount>1 && Arc.Solid);
else
#endif
Unp->DoUnpack(Arc.NewLhd.UnpVer,Arc.NewLhd.Flags & LHD_SOLID);
}
Unp->DoUnpack(Arc.NewLhd.UnpVer,Arc.NewLhd.Flags & LHD_SOLID);
}
if (Arc.IsOpened())
Arc.SeekToNext();
@@ -705,7 +755,7 @@ bool CmdExtract::ExtractCurrentFile(CommandData *Cmd,Archive &Arc,int HeaderSize
}
else
{
char *BadArcName=(Arc.NewLhd.Flags & LHD_SPLIT_BEFORE) ? NULL:Arc.FileName;
char *BadArcName=/*(Arc.NewLhd.Flags & LHD_SPLIT_BEFORE) ? NULL:*/Arc.FileName;
if (Arc.NewLhd.Flags & LHD_PASSWORD)
{
Log(BadArcName,St(MEncrBadCRC),ArcFileName);
@@ -743,6 +793,11 @@ bool CmdExtract::ExtractCurrentFile(CommandData *Cmd,Archive &Arc,int HeaderSize
Cmd->xctime==EXTTIME_NONE ? NULL:&Arc.NewLhd.ctime,
Cmd->xatime==EXTTIME_NONE ? NULL:&Arc.NewLhd.atime);
CurFile.Close();
#if defined(_WIN_32) && !defined(_WIN_CE) && !defined(SFX_MODULE)
if (Cmd->SetCompressedAttr &&
(Arc.NewLhd.FileAttr & FILE_ATTRIBUTE_COMPRESSED)!=0 && WinNT())
SetFileCompression(CurFile.FileName,CurFile.FileNameW,true);
#endif
CurFile.SetCloseFileStat(
Cmd->xmtime==EXTTIME_NONE ? NULL:&Arc.NewLhd.mtime,
Cmd->xatime==EXTTIME_NONE ? NULL:&Arc.NewLhd.atime,
@@ -780,3 +835,4 @@ void CmdExtract::UnstoreFile(ComprDataIO &DataIO,Int64 DestUnpSize)
DestUnpSize-=Code;
}
}

View File

@@ -25,6 +25,7 @@ class CmdExtract
bool SignatureFound;
char DestFileName[NM];
wchar DestFileNameW[NM];
bool PasswordCancelled;
public:
CmdExtract();
~CmdExtract();

View File

@@ -6,8 +6,19 @@ bool FileCreate(RAROptions *Cmd,File *NewFile,char *Name,wchar *NameW,
{
if (UserReject!=NULL)
*UserReject=false;
#if defined(_WIN_32) && !defined(_WIN_CE)
bool ShortNameChanged=false;
#endif
while (FileExist(Name,NameW))
{
#if defined(_WIN_32) && !defined(_WIN_CE)
if (!ShortNameChanged)
{
ShortNameChanged=true;
if (UpdateExistingShortName(Name,NameW))
continue;
}
#endif
if (Mode==OVERWRITE_NONE)
{
if (UserReject!=NULL)
@@ -45,13 +56,15 @@ bool FileCreate(RAROptions *Cmd,File *NewFile,char *Name,wchar *NameW,
}
if (Choice==5)
{
#ifndef GUI
mprintf(St(MAskNewName));
#endif
char NewName[NM];
#ifdef _WIN_32
File SrcFile;
SrcFile.SetHandleType(FILE_HANDLESTD);
int Size=SrcFile.Read(NewName,NM);
int Size=SrcFile.Read(NewName,sizeof(NewName)-1);
NewName[Size]=0;
OemToChar(NewName,NewName);
#else
@@ -69,6 +82,17 @@ bool FileCreate(RAROptions *Cmd,File *NewFile,char *Name,wchar *NameW,
if (Choice==6)
ErrHandler.Exit(RAR_USER_BREAK);
}
if (Mode==OVERWRITE_AUTORENAME)
{
if (GetAutoRenamedName(Name))
{
if (NameW!=NULL)
*NameW=0;
}
else
Mode=OVERWRITE_ASK;
continue;
}
}
if (NewFile!=NULL && NewFile->Create(Name,NameW))
return(true);
@@ -76,3 +100,142 @@ bool FileCreate(RAROptions *Cmd,File *NewFile,char *Name,wchar *NameW,
CreatePath(Name,NameW,true);
return(NewFile!=NULL ? NewFile->Create(Name,NameW):DelFile(Name,NameW));
}
bool GetAutoRenamedName(char *Name)
{
char NewName[NM];
if (strlen(Name)>sizeof(NewName)-10)
return(false);
char *Ext=GetExt(Name);
if (Ext==NULL)
Ext=Name+strlen(Name);
for (int FileVer=1;;FileVer++)
{
sprintf(NewName,"%.*s(%d)%s",Ext-Name,Name,FileVer,Ext);
if (!FileExist(NewName))
{
strcpy(Name,NewName);
break;
}
if (FileVer>=1000000)
return(false);
}
return(true);
}
#if defined(_WIN_32) && !defined(_WIN_CE)
bool UpdateExistingShortName(char *Name,wchar *NameW)
{
FindData fd;
if (!FindFile::FastFind(Name,NameW,&fd))
return(false);
if (*fd.Name==0 || *fd.ShortName==0)
return(false);
if (stricomp(PointToName(fd.Name),fd.ShortName)==0 ||
stricomp(PointToName(Name),fd.ShortName)!=0)
return(false);
char NewName[NM];
for (int I=0;I<10000;I+=123)
{
strncpy(NewName,Name,sizeof(NewName));
sprintf(PointToName(NewName),"rtmp%d",I);
if (!FileExist(NewName))
break;
}
if (FileExist(NewName))
return(false);
char FullName[NM];
strncpy(FullName,Name,sizeof(FullName));
strcpy(PointToName(FullName),PointToName(fd.Name));
if (!MoveFile(FullName,NewName))
return(false);
File KeepShortFile;
bool Created=false;
if (!FileExist(Name))
Created=KeepShortFile.Create(Name);
MoveFile(NewName,FullName);
if (Created)
{
KeepShortFile.Close();
KeepShortFile.Delete();
}
return(true);
}
/*
bool UpdateExistingShortName(char *Name,wchar *NameW)
{
if (WinNT()<5)
return(false);
FindData fd;
if (!FindFile::FastFind(Name,NameW,&fd))
return(false);
if (*fd.Name==0 || *fd.ShortName==0)
return(false);
if (stricomp(PointToName(fd.Name),fd.ShortName)==0 ||
stricomp(PointToName(Name),fd.ShortName)!=0)
return(false);
typedef BOOL (WINAPI *SETFILESHORTNAME)(HANDLE,LPCSTR);
static SETFILESHORTNAME pSetFileShortName=NULL;
if (pSetFileShortName==NULL)
{
HMODULE hKernel=GetModuleHandle("kernel32.dll");
if (hKernel!=NULL)
pSetFileShortName=(SETFILESHORTNAME)GetProcAddress(hKernel,"SetFileShortNameA");
if (pSetFileShortName==NULL)
return(false);
}
static bool RestoreEnabled=false;
if (!RestoreEnabled)
{
HANDLE hToken;
if (!OpenProcessToken(GetCurrentProcess(), TOKEN_ADJUST_PRIVILEGES, &hToken))
return(false);
TOKEN_PRIVILEGES tp;
tp.PrivilegeCount = 1;
tp.Privileges[0].Attributes = SE_PRIVILEGE_ENABLED;
if (LookupPrivilegeValue(NULL,SE_RESTORE_NAME,&tp.Privileges[0].Luid))
AdjustTokenPrivileges(hToken, FALSE, &tp, 0, NULL, NULL);
CloseHandle(hToken);
RestoreEnabled=true;
}
wchar FileNameW[NM];
GetWideName(Name,NameW,FileNameW);
HANDLE hFile=CreateFileW(FileNameW,GENERIC_WRITE|DELETE,FILE_SHARE_READ|FILE_SHARE_WRITE,
NULL,OPEN_EXISTING,FILE_FLAG_BACKUP_SEMANTICS,NULL);
if (hFile==INVALID_HANDLE_VALUE)
return(false);
bool RetCode=false;
char FullName[NM];
wchar FullNameW[NM];
strcpy(FullName,Name);
strcpyw(FullNameW,NullToEmpty(NameW));
for (int I=1;I<1000000;I++)
{
char NewName[NM];
sprintf(NewName,"NAME~%d.%d",I%1000,I/1000+1);
strcpy(PointToName(FullName),NewName);
if (*FullNameW)
CharToWide(NewName,PointToName(FullNameW));
if (!FileExist(FullName,FullNameW))
{
RetCode=pSetFileShortName(hFile,NewName);
break;
}
}
CloseHandle(hFile);
return(RetCode);
}
*/
#endif

View File

@@ -4,5 +4,10 @@
bool FileCreate(RAROptions *Cmd,File *NewFile,char *Name,wchar *NameW,
OVERWRITE_MODE Mode,bool *UserReject,Int64 FileSize=INT64ERR,
uint FileTime=0);
bool GetAutoRenamedName(char *Name);
#if defined(_WIN_32) && !defined(_WIN_CE)
bool UpdateExistingShortName(char *Name,wchar *NameW);
#endif
#endif

View File

@@ -1,6 +1,6 @@
#include "rar.hpp"
static File *CreatedFiles[32];
static File *CreatedFiles[256];
static int RemoveCreatedActive=0;
File::File()
@@ -18,6 +18,9 @@ File::File()
AllowDelete=true;
CloseCount=0;
AllowExceptions=true;
#ifdef _WIN_32
NoSequentialRead=false;
#endif
}
@@ -55,12 +58,11 @@ bool File::Open(const char *Name,const wchar *NameW,bool OpenShared,bool Update)
uint ShareMode=FILE_SHARE_READ;
if (OpenShared)
ShareMode|=FILE_SHARE_WRITE;
uint Flags=NoSequentialRead ? 0:FILE_FLAG_SEQUENTIAL_SCAN;
if (WinNT() && NameW!=NULL && *NameW!=0)
hNewFile=CreateFileW(NameW,Access,ShareMode,NULL,OPEN_EXISTING,
FILE_FLAG_SEQUENTIAL_SCAN,NULL);
hNewFile=CreateFileW(NameW,Access,ShareMode,NULL,OPEN_EXISTING,Flags,NULL);
else
hNewFile=CreateFile(Name,Access,ShareMode,NULL,OPEN_EXISTING,
FILE_FLAG_SEQUENTIAL_SCAN,NULL);
hNewFile=CreateFile(Name,Access,ShareMode,NULL,OPEN_EXISTING,Flags,NULL);
if (hNewFile==BAD_HANDLE && GetLastError()==ERROR_FILE_NOT_FOUND)
ErrorType=FILE_NOTFOUND;
@@ -78,6 +80,11 @@ bool File::Open(const char *Name,const wchar *NameW,bool OpenShared,bool Update)
#else
int handle=open(Name,flags);
#ifdef LOCK_EX
#ifdef _OSF_SOURCE
extern "C" int flock(int, int);
#endif
if (!OpenShared && Update && handle>=0 && flock(handle,LOCK_EX|LOCK_NB)==-1)
{
close(handle);
@@ -292,7 +299,8 @@ void File::Write(const void *Data,int Size)
else
Success=WriteFile(hFile,Data,Size,&Written,NULL);
#else
Success=fwrite(Data,1,Size,hFile)==Size && !ferror(hFile);
int Written=fwrite(Data,1,Size,hFile);
Success=Written==Size && !ferror(hFile);
#endif
if (!Success && AllowExceptions && HandleType==FILE_HANDLENORMAL)
{
@@ -309,6 +317,8 @@ void File::Write(const void *Data,int Size)
#ifndef _WIN_32
clearerr(hFile);
#endif
if (Written<Size && Written>0)
Seek(Tell()-Written,SEEK_SET);
continue;
}
ErrHandler.WriteError(NULL,FileName);
@@ -422,10 +432,10 @@ bool File::RawSeek(Int64 Offset,int Method)
return(false);
#else
LastWrite=false;
#ifdef _LARGEFILE_SOURCE
#if defined(_LARGEFILE_SOURCE) && !defined(_OSF_SOURCE)
if (fseeko(hFile,Offset,Method)!=0)
#else
if (fseek(hFile,int64to32(Offset),Method)!=0)
if (fseek(hFile,(long)int64to32(Offset),Method)!=0)
#endif
return(false);
#endif
@@ -445,7 +455,7 @@ Int64 File::Tell()
return(-1);
return(int32to64(HighDist,LowDist));
#else
#ifdef _LARGEFILE_SOURCE
#if defined(_LARGEFILE_SOURCE) && !defined(_OSF_SOURCE)
return(ftello(hFile));
#else
return(ftell(hFile));

View File

@@ -37,6 +37,9 @@ class File
bool NewFile;
bool AllowDelete;
bool AllowExceptions;
#ifdef _WIN_32
bool NoSequentialRead;
#endif
protected:
bool OpenShared;
public:
@@ -89,6 +92,9 @@ class File
long Copy(File &Dest,Int64 Length=INT64ERR);
void SetAllowDelete(bool Allow) {AllowDelete=Allow;}
void SetExceptions(bool Allow) {AllowExceptions=Allow;}
#ifdef _WIN_32
void RemoveSequentialFlag() {NoSequentialRead=true;}
#endif
};
#endif

View File

@@ -49,7 +49,7 @@ void CreatePath(const char *Path,const wchar *PathW,bool SkipLastName)
uint DirAttr=0777;
#endif
#ifdef UNICODE_SUPPORTED
bool Wide=PathW!=NULL && *PathW!=0;
bool Wide=PathW!=NULL && *PathW!=0 && UnicodeEnabled();
#else
bool Wide=false;
#endif
@@ -76,6 +76,15 @@ void CreatePath(const char *Path,const wchar *PathW,bool SkipLastName)
WideToChar(DirPtrW,DirName);
else
{
#ifndef DBCS_SUPPORTED
if (*s!=CPATHDIVIDER)
for (const char *n=s;*n!=0 && n-Path<NM;n++)
if (*n==CPATHDIVIDER)
{
s=n;
break;
}
#endif
strncpy(DirName,Path,s-Path);
DirName[s-Path]=0;
}
@@ -90,19 +99,25 @@ void CreatePath(const char *Path,const wchar *PathW,bool SkipLastName)
if (!IgnoreAscii)
s=charnext(s);
}
if (!SkipLastName)
if (!SkipLastName && !IsPathDiv(*PointToLastChar(Path)))
MakeDir(Path,PathW,DirAttr);
}
void SetDirTime(const char *Name,RarTime *ftm,RarTime *ftc,RarTime *fta)
{
bool sm=ftm!=NULL && ftm->IsSet();
bool sc=ftc!=NULL && ftc->IsSet();
bool sa=ftc!=NULL && fta->IsSet();
#ifdef _WIN_32
if (!WinNT())
return;
bool sm=ftm!=NULL && ftm->IsSet();
bool sc=ftc!=NULL && ftc->IsSet();
bool sa=fta!=NULL && fta->IsSet();
unsigned int DirAttr=GetFileAttr(Name);
bool ResetAttr=(DirAttr!=0xffffffff && (DirAttr & FA_RDONLY)!=0);
if (ResetAttr)
SetFileAttr(Name,NULL,0);
HANDLE hFile=CreateFile(Name,GENERIC_WRITE,FILE_SHARE_READ|FILE_SHARE_WRITE,
NULL,OPEN_EXISTING,FILE_FLAG_BACKUP_SEMANTICS,NULL);
if (hFile==INVALID_HANDLE_VALUE)
@@ -116,6 +131,8 @@ void SetDirTime(const char *Name,RarTime *ftm,RarTime *ftc,RarTime *fta)
fta->GetWin32(&fa);
SetFileTime(hFile,sc ? &fc:NULL,sa ? &fa:NULL,sm ? &fm:NULL);
CloseHandle(hFile);
if (ResetAttr)
SetFileAttr(Name,NULL,DirAttr);
#endif
#if defined(_UNIX) || defined(_EMX)
File::SetCloseFileTimeByName(Name,ftm,fta);
@@ -153,7 +170,7 @@ Int64 GetFreeDisk(const char *Name)
if (pGetDiskFreeSpaceEx==NULL)
{
HMODULE hKernel=GetModuleHandle("kernel32.dll");
HMODULE hKernel=GetModuleHandle("kernel32.dll");
if (hKernel!=NULL)
pGetDiskFreeSpaceEx=(GETDISKFREESPACEEX)GetProcAddress(hKernel,"GetDiskFreeSpaceExA");
}
@@ -460,7 +477,8 @@ uint CalcFileCRC(File *SrcFile,Int64 Size)
SrcFile->Seek(0,SEEK_SET);
while ((ReadSize=SrcFile->Read(&Data[0],int64to32(Size==INT64ERR ? Int64(BufSize):Min(Int64(BufSize),Size))))!=0)
{
if ((++BlockCount & 15)==0)
++BlockCount;
if ((BlockCount & 15)==0)
{
Wait();
}
@@ -501,3 +519,23 @@ bool DelDir(const char *Name,const wchar *NameW)
{
return(rmdir(Name)==0);
}
#if defined(_WIN_32) && !defined(_WIN_CE)
bool SetFileCompression(char *Name,wchar *NameW,bool State)
{
wchar FileNameW[NM];
GetWideName(Name,NameW,FileNameW);
HANDLE hFile=CreateFileW(FileNameW,FILE_READ_DATA|FILE_WRITE_DATA,
FILE_SHARE_READ|FILE_SHARE_WRITE,NULL,OPEN_EXISTING,
FILE_FLAG_BACKUP_SEMANTICS|FILE_FLAG_SEQUENTIAL_SCAN,NULL);
if (hFile==INVALID_HANDLE_VALUE)
return(false);
SHORT NewState=State ? COMPRESSION_FORMAT_DEFAULT:COMPRESSION_FORMAT_NONE;
DWORD Result;
int RetCode=DeviceIoControl(hFile,FSCTL_SET_COMPRESSION,&NewState,
sizeof(NewState),NULL,0,&Result,NULL);
CloseHandle(hFile);
return(RetCode!=0);
}
#endif

View File

@@ -32,4 +32,8 @@ bool DelFile(const char *Name,const wchar *NameW);
bool DelDir(const char *Name);
bool DelDir(const char *Name,const wchar *NameW);
#if defined(_WIN_32) && !defined(_WIN_CE)
bool SetFileCompression(char *Name,wchar *NameW,bool State);
#endif
#endif

View File

@@ -7,7 +7,7 @@ bool ReadTextFile(char *Name,StringList *List,bool Config,bool AbortOnError,
{
char FileName[NM];
if (Config)
GetConfigName(Name,FileName);
GetConfigName(Name,FileName,true);
else
strcpy(FileName,Name);
@@ -64,7 +64,7 @@ bool ReadTextFile(char *Name,StringList *List,bool Config,bool AbortOnError,
if (*CurStr)
{
int Length=strlenw(CurStr);
int AddSize=Length-AnsiName.Size()+1;
int AddSize=4*(Length-AnsiName.Size()+1);
if (AddSize>0)
AnsiName.Add(AddSize);
if (Unquote && *CurStr=='\"' && CurStr[Length-1]=='\"')
@@ -72,7 +72,7 @@ bool ReadTextFile(char *Name,StringList *List,bool Config,bool AbortOnError,
CurStr[Length-1]=0;
CurStr++;
}
WideToChar(CurStr,&AnsiName[0]);
WideToChar(CurStr,&AnsiName[0],AnsiName.Size());
List->AddString(&AnsiName[0],CurStr);
}
CurStr=NextStr+1;

View File

@@ -106,6 +106,9 @@ bool FindFile::Next(struct FindData *fd,bool GetSymLink)
#ifdef _APPLE
if (!LowAscii(fd->Name))
UtfToWide(fd->Name,fd->NameW,sizeof(fd->NameW));
#elif defined(UNICODE_SUPPORTED)
if (!LowAscii(fd->Name) && UnicodeEnabled())
CharToWide(fd->Name,fd->NameW);
#endif
#endif
fd->IsDir=IsDir(fd->FileAttr);
@@ -163,10 +166,14 @@ bool FindFile::FastFind(const char *FindMask,const wchar *FindMaskW,struct FindD
fd->ctime=st.st_ctime;
fd->FileTime=fd->mtime.GetDos();
strcpy(fd->Name,FindMask);
*fd->NameW=0;
#ifdef _APPLE
if (!LowAscii(fd->Name))
UtfToWide(fd->Name,fd->NameW,sizeof(fd->NameW));
#elif defined(UNICODE_SUPPORTED)
if (!LowAscii(fd->Name) && UnicodeEnabled())
CharToWide(fd->Name,fd->NameW);
#endif
#endif
fd->IsDir=IsDir(fd->FileAttr);
@@ -213,6 +220,7 @@ HANDLE FindFile::Win32Find(HANDLE hFind,const char *Mask,const wchar *MaskW,stru
WideToChar(fd->NameW,fd->Name);
fd->Size=int32to64(FindData.nFileSizeHigh,FindData.nFileSizeLow);
fd->FileAttr=FindData.dwFileAttributes;
WideToChar(FindData.cAlternateFileName,fd->ShortName);
fd->ftCreationTime=FindData.ftCreationTime;
fd->ftLastAccessTime=FindData.ftLastAccessTime;
fd->ftLastWriteTime=FindData.ftLastWriteTime;
@@ -260,6 +268,7 @@ HANDLE FindFile::Win32Find(HANDLE hFind,const char *Mask,const wchar *MaskW,stru
CharToWide(fd->Name,fd->NameW);
fd->Size=int32to64(FindData.nFileSizeHigh,FindData.nFileSizeLow);
fd->FileAttr=FindData.dwFileAttributes;
strcpy(fd->ShortName,FindData.cAlternateFileName);
fd->ftCreationTime=FindData.ftCreationTime;
fd->ftLastAccessTime=FindData.ftLastAccessTime;
fd->ftLastWriteTime=FindData.ftLastWriteTime;

View File

@@ -13,6 +13,7 @@ struct FindData
RarTime ctime;
RarTime atime;
#ifdef _WIN_32
char ShortName[NM];
FILETIME ftCreationTime;
FILETIME ftLastAccessTime;
FILETIME ftLastWriteTime;

View File

@@ -21,7 +21,7 @@
#define PACK_VER 29
#define PACK_CRYPT_VER 29
#define UNP_VER 29
#define UNP_VER 36
#define CRYPT_VER 29
#define AV_VER 20
#define PROTECT_VER 20
@@ -36,6 +36,7 @@
#define MHD_PROTECT 0x0040
#define MHD_PASSWORD 0x0080
#define MHD_FIRSTVOLUME 0x0100
#define MHD_ENCRYPTVER 0x0200
#define LHD_SPLIT_BEFORE 0x0001
#define LHD_SPLIT_AFTER 0x0002
@@ -66,6 +67,7 @@
#define EARC_NEXT_VOLUME 0x0001
#define EARC_DATACRC 0x0002
#define EARC_REVSPACE 0x0004
#define EARC_VOLNUMBER 0x0008
enum HEADER_TYPE {
MARK_HEAD=0x72,MAIN_HEAD=0x73,FILE_HEAD=0x74,COMM_HEAD=0x75,AV_HEAD=0x76,
@@ -150,10 +152,11 @@ struct BlockHeader:BaseBlock
};
struct MainHeader:BlockHeader
struct MainHeader:BaseBlock
{
ushort HighPosAV;
uint PosAV;
byte EncryptVer;
};
@@ -216,6 +219,7 @@ struct FileHeader:BlockHeader
struct EndArcHeader:BaseBlock
{
uint ArcDataCRC;
ushort VolNumber;
};

View File

@@ -6,7 +6,7 @@
typedef __int64 Int64;
#endif
#if defined(__GNUC__)
#if defined(__GNUC__) || defined(__HP_aCC) || defined(__SUNPRO_CC)
#define NATIVE_INT64
typedef long long Int64;
#endif
@@ -78,6 +78,7 @@ inline uint int64to32(Int64 n) {return(n.GetLowPart());}
#endif
#define INT64ERR int32to64(0x80000000,0)
#define INT64MAX int32to64(0x7fffffff,0)
void itoa(Int64 n,char *Str);
Int64 atoil(char *Str);

View File

@@ -20,6 +20,9 @@ void ListArchive(CommandData *Cmd)
while (Cmd->GetArcName(ArcName,ArcNameW,sizeof(ArcName)))
{
Archive Arc(Cmd);
#ifdef _WIN_32
Arc.RemoveSequentialFlag();
#endif
if (!Arc.WOpen(ArcName,ArcNameW))
continue;
bool FileMatched=true;
@@ -76,6 +79,10 @@ void ListArchive(CommandData *Cmd)
TotalPackSize+=Arc.NewLhd.FullPackSize;
if (Technical)
ListSymLink(Arc);
#ifndef SFX_MODULE
if (Verbose)
Arc.ViewFileComment();
#endif
}
break;
#ifndef SFX_MODULE
@@ -107,11 +114,19 @@ void ListArchive(CommandData *Cmd)
char PackSizeText[20];
itoa(TotalPackSize,PackSizeText);
mprintf("\n%5lu %16s %8s %3d%%\n",FileCount,UnpSizeText,
mprintf("\n%5lu %16s %8s %3d%%",FileCount,UnpSizeText,
PackSizeText,ToPercent(TotalPackSize,TotalUnpSize));
SumFileCount+=FileCount;
SumUnpSize+=TotalUnpSize;
SumPackSize+=TotalPackSize;
#ifndef SFX_MODULE
if (Arc.EndArcHead.Flags & EARC_VOLNUMBER)
{
mprintf(" ");
mprintf(St(MVolumeNumber),Arc.EndArcHead.VolNumber+1);
}
#endif
mprintf("\n");
}
else
mprintf(St(MListNoFiles));
@@ -177,10 +192,10 @@ void ListFileHeader(FileHeader &hd,bool Verbose,bool Technical,bool &TitleShown,
#ifdef UNICODE_SUPPORTED
char ConvertedName[NM];
if ((hd.Flags & LHD_UNICODE)!=0 && *hd.FileNameW!=0)
if ((hd.Flags & LHD_UNICODE)!=0 && *hd.FileNameW!=0 && UnicodeEnabled())
{
WideToChar(hd.FileNameW,ConvertedName);
Name=ConvertedName;
if (WideToChar(hd.FileNameW,ConvertedName) && *ConvertedName!=0)
Name=ConvertedName;
}
#endif
@@ -196,7 +211,10 @@ void ListFileHeader(FileHeader &hd,bool Verbose,bool Technical,bool &TitleShown,
mprintf("%-12s",PointToName(Name));
char UnpSizeText[20],PackSizeText[20];
itoa(hd.FullUnpSize,UnpSizeText);
if (hd.FullUnpSize==INT64MAX)
strcpy(UnpSizeText,"?");
else
itoa(hd.FullUnpSize,UnpSizeText);
itoa(hd.FullPackSize,PackSizeText);
mprintf(" %8s %8s ",UnpSizeText,PackSizeText);
@@ -221,7 +239,7 @@ void ListFileHeader(FileHeader &hd,bool Verbose,bool Technical,bool &TitleShown,
else
ListFileAttr(hd.FileAttr,hd.HostOS);
mprintf(" %8.8lX",hd.FileCRC);
mprintf(" %8.8X",hd.FileCRC);
mprintf(" m%d",hd.Method-0x30);
if ((hd.Flags & LHD_WINDOWMASK)<=6*32)
mprintf("%c",((hd.Flags&LHD_WINDOWMASK)>>5)+'a');
@@ -229,12 +247,13 @@ void ListFileHeader(FileHeader &hd,bool Verbose,bool Technical,bool &TitleShown,
mprintf(" ");
mprintf(" %d.%d",hd.UnpVer/10,hd.UnpVer%10);
static char *RarOS[]={
static const char *RarOS[]={
"DOS","OS/2","Win95/NT","Unix","MacOS","BeOS","WinCE","","",""
};
if (Technical)
mprintf("\n%22s %8s %4s",RarOS[hd.HostOS],
mprintf("\n%22s %8s %4s",
(hd.HostOS<sizeof(RarOS)/sizeof(RarOS[0]) ? RarOS[hd.HostOS]:""),
(hd.Flags & LHD_SOLID) ? St(MYes):St(MNo),
(hd.Flags & LHD_VERSION) ? St(MYes):St(MNo));
}
@@ -261,13 +280,14 @@ void ListFileAttr(uint A,int HostOS)
case HOST_OS2:
case HOST_WIN32:
case HOST_MACOS:
mprintf(" %c%c%c%c%c%c ",
mprintf(" %c%c%c%c%c%c%c ",
(A & 0x08) ? 'V' : '.',
(A & 0x10) ? 'D' : '.',
(A & 0x01) ? 'R' : '.',
(A & 0x02) ? 'H' : '.',
(A & 0x04) ? 'S' : '.',
(A & 0x20) ? 'A' : '.');
(A & 0x20) ? 'A' : '.',
(A & 0x800) ? 'C' : '.');
break;
case HOST_UNIX:
case HOST_BEOS:
@@ -332,11 +352,11 @@ void ListOldSubHeader(Archive &Arc)
void ListNewSubHeader(CommandData *Cmd,Archive &Arc,bool Technical)
{
if (Arc.SubHead.CmpName(SUBHEAD_TYPE_CMT) &&
if (Technical && Arc.SubHead.CmpName(SUBHEAD_TYPE_CMT) &&
(Arc.SubHead.Flags & LHD_SPLIT_BEFORE)==0 && !Cmd->DisableComment)
{
Array<byte> CmtData;
int ReadSize=Arc.ReadCommentData(CmtData);
int ReadSize=Arc.ReadCommentData(&CmtData,NULL);
if (ReadSize!=0)
{
mprintf(St(MFileComment));

View File

@@ -3,10 +3,10 @@
#define MYesNoAllRenQ "_Yes_No_All_nEver_Rename_Quit"
#define MContinueQuit "_Continue_Quit"
#define MRetryAbort "_Retry_Abort"
#define MCopyright "\nRAR %s Copyright (c) 1993-%d Eugene Roshal %d %s %d"
#define MCopyright "\nRAR %s Copyright (c) 1993-%d Alexander Roshal %d %s %d"
#define MRegTo "\nRegistered to %s\n"
#define MShare "\nShareware version Type RAR -? for help\n"
#define MUCopyright "\nUNRAR %s freeware Copyright (c) 1993-%d Eugene Roshal\n"
#define MUCopyright "\nUNRAR %s freeware Copyright (c) 1993-%d Alexander Roshal\n"
#define MBeta "beta"
#define MMonthJan "Jan"
#define MMonthFeb "Feb"
@@ -27,6 +27,7 @@
#define MCHelpCmdA "\n a Add files to archive"
#define MCHelpCmdC "\n c Add archive comment"
#define MCHelpCmdCF "\n cf Add files comment"
#define MCHelpCmdCH "\n ch Change archive parameters"
#define MCHelpCmdCW "\n cw Write archive comment to file"
#define MCHelpCmdD "\n d Delete files from archive"
#define MCHelpCmdE "\n e Extract files to current directory"
@@ -63,16 +64,18 @@
#define MCHelpSwDF "\n df Delete files after archiving"
#define MCHelpSwDH "\n dh Open shared files"
#define MCHelpSwDS "\n ds Disable name sort for solid archive"
#define MCHelpSwEa "\n e<attr> Set file exclude attributes"
#define MCHelpSwEa "\n e[+]<attr> Set file exclude and include attributes"
#define MCHelpSwED "\n ed Do not add empty directories"
#define MCHelpSwEE "\n ee Do not save and extract extended attributes"
#define MCHelpSwEN "\n en Do not put 'end of archive' block"
#define MCHelpSwEP "\n ep Exclude paths from names"
#define MCHelpSwEP1 "\n ep1 Exclude base directory from names"
#define MCHelpSwEP2 "\n ep2 Expand paths to full"
#define MCHelpSwEP3 "\n ep3 Expand paths to full including the drive letter"
#define MCHelpSwF "\n f Freshen files"
#define MCHelpSwFCU "\n fcu[file] Read archive comment from Unicode file"
#define MCHelpSwHP "\n hp[password] Encrypt both file data and headers"
#define MCHelpSwIDP "\n idp Disable percentage display"
#define MCHelpSwIDP "\n id[c,d,p,q] Disable messages"
#define MCHelpSwIEML "\n ieml[addr] Send archive by email"
#define MCHelpSwIERR "\n ierr Send all messages to stderr"
#define MCHelpSwILOG "\n ilog[name] Log errors to file (registered versions only)"
@@ -85,9 +88,15 @@
#define MCHelpSwMC "\n mc<par> Set advanced compression parameters"
#define MCHelpSwMD "\n md<size> Dictionary size in KB (64,128,256,512,1024,2048,4096 or A-G)"
#define MCHelpSwMS "\n ms[ext;ext] Specify file types to store"
#define MCHelpSwMT "\n mt<threads> Set the number of threads"
#define MCHelpSwN "\n n<file> Include only specified file"
#define MCHelpSwNa "\n n@ Read file names to include from stdin"
#define MCHelpSwNal "\n n@<list> Include files in specified list file"
#define MCHelpSwOp "\n o+ Overwrite existing files"
#define MCHelpSwOm "\n o- Do not overwrite existing files"
#define MCHelpSwOC "\n oc Set NTFS Compressed attribute"
#define MCHelpSwOL "\n ol Save symbolic links as the link instead of the file"
#define MCHelpSwOR "\n or Rename files automatically"
#define MCHelpSwOS "\n os Save NTFS streams"
#define MCHelpSwOW "\n ow Save or restore file owner and group"
#define MCHelpSwP "\n p[password] Set password"
@@ -101,6 +110,8 @@
#define MCHelpSwSm "\n s- Disable solid archiving"
#define MCHelpSwSFX "\n sfx[name] Create SFX archive"
#define MCHelpSwSI "\n si[name] Read data from standard input (stdin)"
#define MCHelpSwSL "\n sl<size> Process files with size less than specified"
#define MCHelpSwSM "\n sm<size> Process files with size more than specified"
#define MCHelpSwT "\n t Test files after archiving"
#define MCHelpSwTK "\n tk Keep original archive time"
#define MCHelpSwTL "\n tl Set archive time to latest file"
@@ -331,3 +342,6 @@
#define MSHelpCmdT "\n -t Test archive files"
#define MSHelpCmdV "\n -v Verbosely list contents of archive"
#define MMaxPathLimit "\nTotal path and file name length must not exceed %d characters"
#define MRecVolLimit "\nTotal number of usual and recovery volumes must not exceed 255"
#define MVolumeNumber "volume %d"
#define MCannotDelete "\nCannot delete %s"

View File

@@ -1,13 +1,18 @@
#include "rar.hpp"
static bool match(char *pattern,char *string);
static bool match(wchar *pattern,wchar *string);
static bool match(char *pattern,char *string,bool ForceCase);
static bool match(wchar *pattern,wchar *string,bool ForceCase);
inline uint toupperc(byte ch)
static int mstricompc(const char *Str1,const char *Str2,bool ForceCase);
static int mstricompcw(const wchar *Str1,const wchar *Str2,bool ForceCase);
static int mstrnicompc(const char *Str1,const char *Str2,int N,bool ForceCase);
static int mstrnicompcw(const wchar *Str1,const wchar *Str2,int N,bool ForceCase);
inline uint toupperc(byte ch,bool ForceCase)
{
/*
*/
#if defined(_WIN_32)
if (ForceCase)
return(ch);
#ifdef _WIN_32
return((uint)CharUpper((LPTSTR)(ch)));
#elif defined(_UNIX)
return(ch);
@@ -17,10 +22,10 @@ inline uint toupperc(byte ch)
}
inline uint touppercw(uint ch)
inline uint touppercw(uint ch,bool ForceCase)
{
/*
*/
if (ForceCase)
return(ch);
#if defined(_UNIX)
return(ch);
#else
@@ -31,10 +36,14 @@ inline uint touppercw(uint ch)
bool CmpName(char *Wildcard,char *Name,int CmpPath)
{
bool ForceCase=(CmpPath&MATCH_FORCECASESENSITIVE)!=0;
CmpPath&=MATCH_MODEMASK;
if (CmpPath!=MATCH_NAMES)
{
int WildLength=strlen(Wildcard);
if (CmpPath!=MATCH_EXACTPATH && strnicompc(Wildcard,Name,WildLength)==0)
if (CmpPath!=MATCH_EXACTPATH && mstrnicompc(Wildcard,Name,WildLength,ForceCase)==0)
{
char NextCh=Name[WildLength];
if (NextCh=='\\' || NextCh=='/' || NextCh==0)
@@ -43,38 +52,42 @@ bool CmpName(char *Wildcard,char *Name,int CmpPath)
char Path1[NM],Path2[NM];
GetFilePath(Wildcard,Path1);
GetFilePath(Name,Path2);
if (stricompc(Wildcard,Path2)==0)
if (mstricompc(Wildcard,Path2,ForceCase)==0)
return(true);
if ((CmpPath==MATCH_PATH || CmpPath==MATCH_EXACTPATH) && stricompc(Path1,Path2)!=0)
if ((CmpPath==MATCH_PATH || CmpPath==MATCH_EXACTPATH) && mstricompc(Path1,Path2,ForceCase)!=0)
return(false);
if (CmpPath==MATCH_SUBPATH || CmpPath==MATCH_WILDSUBPATH)
if (IsWildcard(Path1))
return(match(Wildcard,Name));
return(match(Wildcard,Name,ForceCase));
else
if (CmpPath==MATCH_SUBPATH || IsWildcard(Wildcard))
{
if (*Path1 && strnicompc(Path1,Path2,strlen(Path1))!=0)
if (*Path1 && mstrnicompc(Path1,Path2,strlen(Path1),ForceCase)!=0)
return(false);
}
else
if (stricompc(Path1,Path2)!=0)
if (mstricompc(Path1,Path2,ForceCase)!=0)
return(false);
}
char *Name1=PointToName(Wildcard);
char *Name2=PointToName(Name);
if (strnicompc("__rar_",Name2,6)==0)
if (mstrnicompc("__rar_",Name2,6,false)==0)
return(false);
return(match(Name1,Name2));
return(match(Name1,Name2,ForceCase));
}
#ifndef SFX_MODULE
bool CmpName(wchar *Wildcard,wchar *Name,int CmpPath)
{
bool ForceCase=(CmpPath&MATCH_FORCECASESENSITIVE)!=0;
CmpPath&=MATCH_MODEMASK;
if (CmpPath!=MATCH_NAMES)
{
int WildLength=strlenw(Wildcard);
if (CmpPath!=MATCH_EXACTPATH && strnicompcw(Wildcard,Name,WildLength)==0)
if (CmpPath!=MATCH_EXACTPATH && mstrnicompcw(Wildcard,Name,WildLength,ForceCase)==0)
{
wchar NextCh=Name[WildLength];
if (NextCh==L'\\' || NextCh==L'/' || NextCh==0)
@@ -83,36 +96,36 @@ bool CmpName(wchar *Wildcard,wchar *Name,int CmpPath)
wchar Path1[NM],Path2[NM];
GetFilePath(Wildcard,Path1);
GetFilePath(Name,Path2);
if ((CmpPath==MATCH_PATH || CmpPath==MATCH_EXACTPATH) && stricompcw(Path1,Path2)!=0)
if ((CmpPath==MATCH_PATH || CmpPath==MATCH_EXACTPATH) && mstricompcw(Path1,Path2,ForceCase)!=0)
return(false);
if (CmpPath==MATCH_SUBPATH || CmpPath==MATCH_WILDSUBPATH)
if (IsWildcard(NULL,Path1))
return(match(Wildcard,Name));
return(match(Wildcard,Name,ForceCase));
else
if (CmpPath==MATCH_SUBPATH || IsWildcard(NULL,Wildcard))
{
if (*Path1 && strnicompcw(Path1,Path2,strlenw(Path1))!=0)
if (*Path1 && mstrnicompcw(Path1,Path2,strlenw(Path1),ForceCase)!=0)
return(false);
}
else
if (stricompcw(Path1,Path2)!=0)
if (mstricompcw(Path1,Path2,ForceCase)!=0)
return(false);
}
wchar *Name1=PointToName(Wildcard);
wchar *Name2=PointToName(Name);
if (strnicompcw(L"__rar_",Name2,6)==0)
if (mstrnicompcw(L"__rar_",Name2,6,false)==0)
return(false);
return(match(Name1,Name2));
return(match(Name1,Name2,ForceCase));
}
#endif
bool match(char *pattern,char *string)
bool match(char *pattern,char *string,bool ForceCase)
{
for (;; ++string)
{
char stringc=toupperc(*string);
char patternc=toupperc(*pattern++);
char stringc=toupperc(*string,ForceCase);
char patternc=toupperc(*pattern++,ForceCase);
switch (patternc)
{
case 0:
@@ -135,18 +148,18 @@ bool match(char *pattern,char *string)
{
string=dot;
if (strpbrk(pattern,"*?")==NULL && strchr(string+1,'.')==NULL)
return(stricompc(pattern+1,string+1)==0);
return(mstricompc(pattern+1,string+1,ForceCase)==0);
}
}
while (*string)
if (match(pattern,string++))
if (match(pattern,string++,ForceCase))
return(true);
return(false);
default:
if (patternc != stringc)
if (patternc=='.' && stringc==0)
return(match(pattern,string));
return(match(pattern,string,ForceCase));
else
return(false);
break;
@@ -156,12 +169,12 @@ bool match(char *pattern,char *string)
#ifndef SFX_MODULE
bool match(wchar *pattern,wchar *string)
bool match(wchar *pattern,wchar *string,bool ForceCase)
{
for (;; ++string)
{
wchar stringc=touppercw(*string);
wchar patternc=touppercw(*pattern++);
wchar stringc=touppercw(*string,ForceCase);
wchar patternc=touppercw(*pattern++,ForceCase);
switch (patternc)
{
case 0:
@@ -184,18 +197,18 @@ bool match(wchar *pattern,wchar *string)
{
string=dot;
if (strpbrkw(pattern,L"*?")==NULL && strchrw(string+1,'.')==NULL)
return(stricompcw(pattern+1,string+1)==0);
return(mstricompcw(pattern+1,string+1,ForceCase)==0);
}
}
while (*string)
if (match(pattern,string++))
if (match(pattern,string++,ForceCase))
return(true);
return(false);
default:
if (patternc != stringc)
if (patternc=='.' && stringc==0)
return(match(pattern,string));
return(match(pattern,string,ForceCase));
else
return(false);
break;
@@ -205,36 +218,28 @@ bool match(wchar *pattern,wchar *string)
#endif
int stricompc(const char *Str1,const char *Str2)
int mstricompc(const char *Str1,const char *Str2,bool ForceCase)
{
/*
*/
#if defined(_UNIX)
return(strcmp(Str1,Str2));
#else
return(stricomp(Str1,Str2));
#endif
if (ForceCase)
return(strcmp(Str1,Str2));
return(stricompc(Str1,Str2));
}
#ifndef SFX_MODULE
int stricompcw(const wchar *Str1,const wchar *Str2)
int mstricompcw(const wchar *Str1,const wchar *Str2,bool ForceCase)
{
/*
*/
#if defined(_UNIX)
return(strcmpw(Str1,Str2));
#else
return(stricmpw(Str1,Str2));
#endif
if (ForceCase)
return(strcmpw(Str1,Str2));
return(stricompcw(Str1,Str2));
}
#endif
int strnicompc(const char *Str1,const char *Str2,int N)
int mstrnicompc(const char *Str1,const char *Str2,int N,bool ForceCase)
{
/*
*/
if (ForceCase)
return(strncmp(Str1,Str2,N));
#if defined(_UNIX)
return(strncmp(Str1,Str2,N));
#else
@@ -244,10 +249,10 @@ int strnicompc(const char *Str1,const char *Str2,int N)
#ifndef SFX_MODULE
int strnicompcw(const wchar *Str1,const wchar *Str2,int N)
int mstrnicompcw(const wchar *Str1,const wchar *Str2,int N,bool ForceCase)
{
/*
*/
if (ForceCase)
return(strncmpw(Str1,Str2,N));
#if defined(_UNIX)
return(strncmpw(Str1,Str2,N));
#else

View File

@@ -3,12 +3,10 @@
enum {MATCH_NAMES,MATCH_PATH,MATCH_EXACTPATH,MATCH_SUBPATH,MATCH_WILDSUBPATH};
#define MATCH_MODEMASK 0x0000ffff
#define MATCH_FORCECASESENSITIVE 0x80000000
bool CmpName(char *Wildcard,char *Name,int CmpPath);
bool CmpName(wchar *Wildcard,wchar *Name,int CmpPath);
int stricompc(const char *Str1,const char *Str2);
int stricompcw(const wchar *Str1,const wchar *Str2);
int strnicompc(const char *Str1,const char *Str2,int N);
int strnicompcw(const wchar *Str1,const wchar *Str2,int N);
#endif

View File

@@ -564,6 +564,8 @@ int ModelPPM::DecodeChar()
return(-1);
if (MinContext->NumStats != 1)
{
if ((byte*)MinContext->U.Stats <= SubAlloc.pText || (byte*)MinContext->U.Stats>SubAlloc.HeapEnd)
return(-1);
if (!MinContext->decodeSymbol1(this))
return(-1);
}

View File

@@ -9,7 +9,9 @@ const int MAX_O=64; /* maximum allowed model order */
const int INT_BITS=7, PERIOD_BITS=7, TOT_BITS=INT_BITS+PERIOD_BITS,
INTERVAL=1 << INT_BITS, BIN_SCALE=1 << TOT_BITS, MAX_FREQ=124;
#ifndef STRICT_ALIGNMENT_REQUIRED
#pragma pack(1)
#endif
struct SEE2_CONTEXT
{ // SEE-contexts for PPM-contexts with masked symbols
@@ -47,16 +49,18 @@ struct STATE
PPM_CONTEXT* Successor;
};
struct FreqData
{
ushort SummFreq;
STATE _PACK_ATTR * Stats;
};
struct PPM_CONTEXT
{
ushort NumStats;
union
{
struct
{
ushort SummFreq;
STATE _PACK_ATTR * Stats;
} U;
FreqData U;
STATE OneState;
};
@@ -73,9 +77,16 @@ struct PPM_CONTEXT
inline PPM_CONTEXT* createChild(ModelPPM *Model,STATE* pStats,STATE& FirstState);
inline SEE2_CONTEXT* makeEscFreq2(ModelPPM *Model,int Diff);
};
#pragma pack()
const uint UNIT_SIZE=sizeof(PPM_CONTEXT);
#ifndef STRICT_ALIGNMENT_REQUIRED
#ifdef _AIX
#pragma pack(pop)
#else
#pragma pack()
#endif
#endif
const uint UNIT_SIZE=Max(sizeof(PPM_CONTEXT),sizeof(RAR_MEM_BLK));
const uint FIXED_UNIT_SIZE=12;
/*

View File

@@ -22,5 +22,7 @@ void RAROptions::Init()
ConvertNames=NAMES_ORIGINALCASE;
ProcessEA=true;
xmtime=EXTTIME_HIGH3;
NextVolNum=0;
CurVolNum=0;
FileSizeLess=INT64ERR;
FileSizeMore=INT64ERR;
}

View File

@@ -6,7 +6,8 @@
#define DEFAULT_RECVOLUMES -10
enum PathExclMode {
EXCL_NONE,EXCL_BASEPATH,EXCL_SKIPWHOLEPATH,EXCL_SAVEFULLPATH,EXCL_SKIPABSPATH
EXCL_NONE,EXCL_BASEPATH,EXCL_SKIPWHOLEPATH,EXCL_SAVEFULLPATH,
EXCL_SKIPABSPATH,EXCL_ABSPATH
};
enum {SOLID_NONE=0,SOLID_NORMAL=1,SOLID_COUNT=2,SOLID_FILEEXT=4,
SOLID_VOLUME_DEPENDENT=8,SOLID_VOLUME_INDEPENDENT=16};
@@ -15,12 +16,15 @@ enum EXTTIME_MODE {
EXTTIME_NONE,EXTTIME_1S,EXTTIME_HIGH1,EXTTIME_HIGH2,EXTTIME_HIGH3
};
enum {NAMES_ORIGINALCASE,NAMES_UPPERCASE,NAMES_LOWERCASE};
enum MESSAGE_TYPE {MSG_STDOUT,MSG_STDERR,MSG_NULL};
enum OVERWRITE_MODE { OVERWRITE_ASK,OVERWRITE_ALL,OVERWRITE_NONE};
enum MESSAGE_TYPE {MSG_STDOUT,MSG_STDERR,MSG_ERRONLY,MSG_NULL};
enum OVERWRITE_MODE {
OVERWRITE_ASK,OVERWRITE_ALL,OVERWRITE_NONE,OVERWRITE_AUTORENAME
};
#define MAX_FILTERS 16
enum FilterState {FILTER_DEFAULT=0,FILTER_AUTO,FILTER_FORCE,FILTER_DISABLE};
struct FilterMode
{
FilterState State;
@@ -37,12 +41,15 @@ class RAROptions
void Init();
uint ExclFileAttr;
uint InclFileAttr;
bool InclAttrSet;
uint WinSize;
char TempPath[NM];
char SFXModule[NM];
char ExtrPath[NM];
wchar ExtrPathW[NM];
char CommentFile[NM];
bool UnicodeComment;
char ArcPath[NM];
char Password[MAXPASSWORD];
bool EncryptHeaders;
@@ -54,6 +61,8 @@ class RAROptions
int Recovery;
int RecVolNumber;
bool DisablePercentage;
bool DisableCopyright;
bool DisableDone;
int Solid;
int SolidCount;
bool ClearArc;
@@ -66,7 +75,7 @@ class RAROptions
int Recurse;
Int64 VolSize;
Array<Int64> NextVolSizes;
int NextVolNum;
int CurVolNum;
bool AllYes;
bool DisableViewAV;
bool DisableSortSolid;
@@ -86,10 +95,13 @@ class RAROptions
char GenerateMask[80];
bool ProcessEA;
bool SaveStreams;
bool SetCompressedAttr;
uint FileTimeOlder;
uint FileTimeNewer;
RarTime FileTimeBefore;
RarTime FileTimeAfter;
Int64 FileSizeLess;
Int64 FileSizeMore;
bool OldNumbering;
bool Lock;
bool Test;
@@ -106,6 +118,11 @@ class RAROptions
EXTTIME_MODE xarctime;
char CompressStdin[NM];
#ifdef PACK_SMP
uint Threads;
#endif
#ifdef RARDLL

View File

@@ -20,25 +20,31 @@
#ifdef _WIN_32
#define STRICT
#define WINVER 0x0400
#define _WIN32_WINNT 0x0300
#define STRICT
#undef WINVER
#undef _WIN32_WINNT
#define WINVER 0x0400
#define _WIN32_WINNT 0x0300
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
#include <prsht.h>
#ifndef _WIN_CE
#include <winioctl.h>
#endif
#endif
#ifndef _WIN_CE
#include <sys/types.h>
#include <sys/stat.h>
#include <dos.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <dos.h>
#endif
#if !defined(_EMX) && !defined(_MSC_VER) && !defined(_WIN_CE)
#define ENABLE_MKTEMP
#include <dir.h>
#endif
#ifdef _MSC_VER
@@ -51,7 +57,7 @@
#endif
#ifndef _WIN_CE
#include <share.h>
#include <share.h>
#endif
#if defined(ENABLE_BAD_ALLOC) && !defined(_WIN_CE)
@@ -71,7 +77,7 @@
#include <emx/syscalls.h>
#endif
#else
#ifdef _MSC_VER
#if defined(_MSC_VER) || defined(__MINGW32__)
#include <exception>
#else
#include <except.h>
@@ -196,7 +202,7 @@
#endif
#endif
#if defined(__sparc) || defined(sparc)
#if defined(__sparc) || defined(sparc) || defined(__hpux)
#ifndef BIG_ENDIAN
#define BIG_ENDIAN
#endif
@@ -219,7 +225,14 @@ typedef const char* MSGID;
#endif
#if !defined(BIG_ENDIAN) && !defined(_WIN_CE) && defined(_WIN_32)
/* allow not aligned integer access, increases speed in some operations */
#define ALLOW_NOT_ALIGNED_INT
#endif
#if defined(__sparc) || defined(sparc) || defined(__sparcv9)
/* prohibit not aligned access to data structures in text comression
algorithm, increases memory requirements */
#define STRICT_ALIGNMENT_REQUIRED
#endif
#endif // _RAR_OS_

View File

@@ -32,9 +32,13 @@ char* PointToLastChar(const char *Path)
char* ConvertPath(const char *SrcPath,char *DestPath)
{
const char *DestPtr=SrcPath;
/* prevents \..\ in any part of path string */
for (const char *s=DestPtr;*s!=0;s++)
if (IsPathDiv(s[0]) && s[1]=='.' && s[2]=='.' && IsPathDiv(s[3]))
DestPtr=s+4;
/* removes any sequence of . and \ in the beginning of path string */
while (*DestPtr)
{
const char *s=DestPtr;
@@ -56,6 +60,11 @@ char* ConvertPath(const char *SrcPath,char *DestPath)
break;
DestPtr=s;
}
/* code above does not remove last "..", doing here */
if (DestPtr[0]=='.' && DestPtr[1]=='.' && DestPtr[2]==0)
DestPtr+=2;
if (DestPath!=NULL)
{
char TmpStr[NM];
@@ -311,11 +320,12 @@ bool EnumConfigPaths(char *Path,int Number)
char *EnvStr=getenv("HOME");
if (EnvStr==NULL)
return(false);
strcpy(Path,EnvStr);
strncpy(Path,EnvStr,NM);
Path[NM-1]=0;
return(true);
}
static char *AltPath[]={
"/etc","/usr/lib","/usr/local/lib","/usr/local/etc"
static const char *AltPath[]={
"/etc","/etc/rar","/usr/lib","/usr/local/lib","/usr/local/etc"
};
Number--;
if (Number<0 || Number>=sizeof(AltPath)/sizeof(AltPath[0]))
@@ -336,13 +346,13 @@ bool EnumConfigPaths(char *Path,int Number)
#ifndef SFX_MODULE
void GetConfigName(const char *Name,char *FullName)
void GetConfigName(const char *Name,char *FullName,bool CheckExist)
{
for (int I=0;EnumConfigPaths(FullName,I);I++)
{
AddEndSlash(FullName);
strcat(FullName,Name);
if (WildFileExist(FullName))
if (!CheckExist || WildFileExist(FullName))
break;
}
}
@@ -426,8 +436,11 @@ bool IsNameUsable(const char *Name)
#ifndef _UNIX
if (Name[0] && Name[1] && strchr(Name+2,':')!=NULL)
return(false);
for (const char *s=Name;*s!=0;s=charnext(s))
if (*s<32)
return(false);
#endif
return(*Name!=0 && strpbrk(Name,"?*<>|")==NULL);
return(*Name!=0 && strpbrk(Name,"?*<>|\"")==NULL);
}
@@ -449,10 +462,16 @@ void MakeNameUsable(char *Name,bool Extended)
}
char* UnixSlashToDos(char *SrcName,char *DestName)
char* UnixSlashToDos(char *SrcName,char *DestName,uint MaxLength)
{
if (DestName!=NULL && DestName!=SrcName)
strcpy(DestName,SrcName);
if (strlen(SrcName)>=MaxLength)
{
*DestName=0;
return(DestName);
}
else
strcpy(DestName,SrcName);
for (char *s=SrcName;*s!=0;s=charnext(s))
{
if (*s=='/')
@@ -465,10 +484,16 @@ char* UnixSlashToDos(char *SrcName,char *DestName)
}
char* DosSlashToUnix(char *SrcName,char *DestName)
char* DosSlashToUnix(char *SrcName,char *DestName,uint MaxLength)
{
if (DestName!=NULL && DestName!=SrcName)
strcpy(DestName,SrcName);
if (strlen(SrcName)>=MaxLength)
{
*DestName=0;
return(DestName);
}
else
strcpy(DestName,SrcName);
for (char *s=SrcName;*s!=0;s=charnext(s))
{
if (*s=='\\')
@@ -603,6 +628,17 @@ char* VolNameToFirstName(const char *VolName,char *FirstName,bool NewNumbering)
wchar* GetWideName(const char *Name,const wchar *NameW,wchar *DestW)
{
if (NameW!=NULL && *NameW!=0)
{
if (DestW!=NameW)
strcpyw(DestW,NameW);
}
else
CharToWide(Name,DestW);
return(DestW);
}

View File

@@ -24,19 +24,19 @@ void GetFilePath(const wchar *FullName,wchar *Path);
void RemoveNameFromPath(char *Path);
void RemoveNameFromPath(wchar *Path);
bool EnumConfigPaths(char *Path,int Number);
void GetConfigName(const char *Name,char *FullName);
void GetConfigName(const char *Name,char *FullName,bool CheckExist);
char* GetVolNumPart(char *ArcName);
void NextVolumeName(char *ArcName,bool OldNumbering);
bool IsNameUsable(const char *Name);
void MakeNameUsable(char *Name,bool Extended);
char* UnixSlashToDos(char *SrcName,char *DestName=NULL);
char* DosSlashToUnix(char *SrcName,char *DestName=NULL);
char* UnixSlashToDos(char *SrcName,char *DestName=NULL,uint MaxLength=NM);
char* DosSlashToUnix(char *SrcName,char *DestName=NULL,uint MaxLength=NM);
bool IsFullPath(const char *Path);
bool IsDiskLetter(const char *Path);
void GetPathRoot(const char *Path,char *Root);
int ParseVersionFileName(char *Name,wchar *NameW,bool Truncate);
char* VolNameToFirstName(const char *VolName,char *FirstName,bool NewNumbering);
wchar* GetWideName(const char *Name,const wchar *NameW,wchar *DestW);
inline char* GetOutputName(const char *Name) {return((char *)Name);};

View File

@@ -14,6 +14,9 @@ int main(int argc, char *argv[])
#ifdef _UNIX
setlocale(LC_ALL,"");
#endif
#if defined(_EMX) && !defined(_DJGPP)
uni_init(0);
#endif
#ifndef SFX_MODULE
setbuf(stdout,NULL);
@@ -36,11 +39,11 @@ int main(int argc, char *argv[])
#endif
#ifdef _WIN_32
SetErrorMode(SEM_FAILCRITICALERRORS|SEM_NOOPENFILEERRORBOX);
SetErrorMode(SEM_NOALIGNMENTFAULTEXCEPT|SEM_FAILCRITICALERRORS|SEM_NOOPENFILEERRORBOX);
#endif
bool ShutdownOnClose;
#ifdef ALLOW_EXCEPTIONS
try
@@ -92,7 +95,6 @@ int main(int argc, char *argv[])
InitConsoleOptions(Cmd.MsgStream,Cmd.Sound);
InitSystemOptions(Cmd.SleepTime);
InitLogOptions(Cmd.LogName);
ErrHandler.SetSilent(Cmd.AllYes || Cmd.MsgStream==MSG_NULL);
ErrHandler.SetShutdown(Cmd.Shutdown);
@@ -119,6 +121,9 @@ int main(int argc, char *argv[])
File::RemoveCreated();
#if defined(SFX_MODULE) && defined(_DJGPP)
_chmod(ModuleName,1,0x20);
#endif
#if defined(_EMX) && !defined(_DJGPP)
uni_done();
#endif
return(ErrHandler.GetErrorCode());
}

View File

@@ -4,8 +4,6 @@
#include "raros.hpp"
#include "os.hpp"
#define RARDLL
#define SILENT
#ifdef RARDLL
#include "dll.hpp"

View File

@@ -4,7 +4,10 @@
#define Min(x,y) (((x)<(y)) ? (x):(y))
#define Max(x,y) (((x)>(y)) ? (x):(y))
#define ASIZE(x) (sizeof(x)/sizeof(x[0]))
#define MAXPASSWORD 128
#define MAXSFXSIZE 0x80000
#define DefSFXName "default.sfx"
#define DefSortListName "rarfiles.lst"

View File

@@ -9,7 +9,7 @@ typedef unsigned int uint32; //32 bits exactly
typedef int sint32; //signed 32 bits exactly
#define PRESENT_INT32
#if defined(_WIN_32) || defined(__GNUC__) || defined(__sgi) || defined(_AIX) || defined(__sun)
#if defined(_WIN_32) || defined(__GNUC__) || defined(__sgi) || defined(_AIX) || defined(__sun) || defined(__hpux) || defined(_OSF_SOURCE)
typedef wchar_t wchar;
#else
typedef ushort wchar;

View File

@@ -10,7 +10,7 @@ RarVM::RarVM()
RarVM::~RarVM()
{
delete Mem;
delete[] Mem;
}
@@ -456,9 +456,6 @@ bool RarVM::ExecuteCode(VM_PreparedCommand *PreparedCode,int CodeSize)
break;
#endif
case VM_PRINT:
#ifdef DEBUG
PrintState(Cmd-PreparedCode);
#endif
break;
}
Cmd++;
@@ -467,16 +464,6 @@ bool RarVM::ExecuteCode(VM_PreparedCommand *PreparedCode,int CodeSize)
}
void RarVM::PrintState(uint IP)
{
#if defined(DEBUG) && !defined(GUI) && !defined(SILENT)
mprintf("\n");
for (int I=0;I<sizeof(R)/sizeof(R[0]);I++)
mprintf("R%d=%08X\t%s",I,R[I],I==3 ? "\n":"");
mprintf("\nIP=%08X\tFlags: C=%d S=%d",IP,(Flags & VM_FC)!=0,(Flags & VM_FS)!=0);
mprintf("\n");
#endif
}
void RarVM::Prepare(byte *Code,int CodeSize,VM_PreparedProgram *Prg)
@@ -503,6 +490,7 @@ void RarVM::Prepare(byte *Code,int CodeSize,VM_PreparedProgram *Prg)
CurCmd->Op1.Data=FilterType;
CurCmd->Op1.Addr=&CurCmd->Op1.Data;
CurCmd->Op2.Addr=&CurCmd->Op2.Data;
CurCmd->Op1.Type=CurCmd->Op2.Type=VM_OPNONE;
CodeSize=0;
}
#endif
@@ -579,6 +567,7 @@ void RarVM::Prepare(byte *Code,int CodeSize,VM_PreparedProgram *Prg)
CurCmd->OpCode=VM_RET;
CurCmd->Op1.Addr=&CurCmd->Op1.Data;
CurCmd->Op2.Addr=&CurCmd->Op2.Data;
CurCmd->Op1.Type=CurCmd->Op2.Type=VM_OPNONE;
for (int I=0;I<Prg->CmdCount;I++)
{

View File

@@ -73,13 +73,12 @@ struct VM_PreparedProgram
unsigned int FilteredDataSize;
};
class RarVM:BitInput
class RarVM:private BitInput
{
private:
inline uint GetValue(bool ByteMode,uint *Addr);
inline void SetValue(bool ByteMode,uint *Addr,uint Value);
inline uint* GetOperand(VM_PreparedOperand *CmdOp);
void PrintState(uint IP);
void DecodeArg(VM_PreparedOperand &Op,bool ByteMode);
#ifdef VM_OPTIMIZE
void Optimize(VM_PreparedProgram *Prg);

View File

@@ -118,7 +118,13 @@ void ComprDataIO::UnpWrite(byte *Addr,uint Count)
ErrHandler.Exit(RAR_USER_BREAK);
if (Cmd->ProcessDataProc!=NULL)
{
#if defined(_WIN_32) && !defined(_MSC_VER) && !defined(__MINGW32__)
_EBX=_ESP;
#endif
int RetCode=Cmd->ProcessDataProc(Addr,Count);
#if defined(_WIN_32) && !defined(_MSC_VER) && !defined(__MINGW32__)
_ESP=_EBX;
#endif
if (RetCode==0)
ErrHandler.Exit(RAR_USER_BREAK);
}
@@ -169,7 +175,9 @@ void ComprDataIO::ShowUnpRead(Int64 ArcPos,Int64 ArcSize)
int CurPercent=ToPercent(ArcPos,ArcSize);
if (!Cmd->DisablePercentage && CurPercent!=LastPercent)
{
#ifndef GUI
mprintf("\b\b\b\b%3d%%",CurPercent);
#endif
LastPercent=CurPercent;
}
}
@@ -205,20 +213,20 @@ void ComprDataIO::GetUnpackedData(byte **Data,uint *Size)
}
void ComprDataIO::SetEncryption(int Method,char *Password,byte *Salt,bool Encrypt)
void ComprDataIO::SetEncryption(int Method,char *Password,byte *Salt,bool Encrypt,bool HandsOffHash)
{
if (Encrypt)
{
Encryption=*Password ? Method:0;
#ifndef NOCRYPT
Crypt.SetCryptKeys(Password,Salt,Encrypt);
Crypt.SetCryptKeys(Password,Salt,Encrypt,false,HandsOffHash);
#endif
}
else
{
Decryption=*Password ? Method:0;
#ifndef NOCRYPT
Decrypt.SetCryptKeys(Password,Salt,Encrypt,Method<29);
Decrypt.SetCryptKeys(Password,Salt,Encrypt,Method<29,HandsOffHash);
#endif
}
}

View File

@@ -60,7 +60,7 @@ class ComprDataIO
void SetFiles(File *SrcFile,File *DestFile);
void SetCommand(CmdAdd *Cmd) {Command=Cmd;}
void SetSubHeader(FileHeader *hd,Int64 *Pos) {SubHead=hd;SubHeadPos=Pos;}
void SetEncryption(int Method,char *Password,byte *Salt,bool Encrypt);
void SetEncryption(int Method,char *Password,byte *Salt,bool Encrypt,bool HandsOffHash);
void SetAV15Encryption();
void SetCmt13Encryption();
void SetUnpackToMemory(byte *Addr,uint Size);

View File

@@ -191,16 +191,8 @@ bool RecVolumes::Restore(RAROptions *Cmd,const char *Name,
ValidVolume=NewFile->IsArchive(false);
if (ValidVolume)
{
bool EndFound=false,EndBlockRequired=false;
while (!EndFound && NewFile->ReadHeader()!=0)
while (NewFile->ReadHeader()!=0)
{
if (NewFile->GetHeaderType()==FILE_HEAD)
{
if (NewFile->NewLhd.UnpVer>=29)
EndBlockRequired=true;
if (!EndBlockRequired && (NewFile->NewLhd.Flags & LHD_SPLIT_AFTER))
EndFound=true;
}
if (NewFile->GetHeaderType()==ENDARC_HEAD)
{
if ((NewFile->EndArcHead.Flags&EARC_DATACRC)!=0 &&
@@ -211,12 +203,10 @@ bool RecVolumes::Restore(RAROptions *Cmd,const char *Name,
mprintf(St(MCRCFailed),ArcName);
#endif
}
EndFound=true;
break;
}
NewFile->SeekToNext();
}
if (!EndFound)
ValidVolume=false;
}
if (!ValidVolume)
{
@@ -263,12 +253,12 @@ bool RecVolumes::Restore(RAROptions *Cmd,const char *Name,
if (MissingVolumes>FoundRecVolumes)
{
#ifndef SILENT
#if !defined(SILENT) && !defined(GUI)
mprintf(St(MRecVolCannotFix));
#endif
return(false);
}
#ifndef SILENT
#if !defined(SILENT) && !defined(GUI)
mprintf(St(MReconstructing));
#endif
@@ -308,7 +298,7 @@ bool RecVolumes::Restore(RAROptions *Cmd,const char *Name,
}
if (MaxRead==0)
break;
#ifndef SILENT
#if !defined(SILENT) && !defined(GUI)
int CurPercent=ToPercent(ProcessedSize,RecFileSize);
if (!Cmd->DisablePercentage && CurPercent!=LastPercent)
{
@@ -370,7 +360,7 @@ bool RecVolumes::Restore(RAROptions *Cmd,const char *Name,
#if !defined(GUI) && !defined(SILENT)
if (!Cmd->DisablePercentage)
mprintf("\b\b\b\b100%%");
if (!Silent)
if (!Silent && !Cmd->DisableDone)
mprintf(St(MDone));
#endif
return(true);

View File

@@ -7,6 +7,7 @@ ScanTree::ScanTree(StringList *FileMasks,int Recurse,bool GetLinks,int GetDirs)
ScanTree::GetLinks=GetLinks;
ScanTree::GetDirs=GetDirs;
SetAllMaskDepth=0;
*CurMask=0;
*CurMaskW=0;
memset(FindStack,0,sizeof(FindStack));
@@ -14,6 +15,7 @@ ScanTree::ScanTree(StringList *FileMasks,int Recurse,bool GetLinks,int GetDirs)
Errors=0;
FastFindFile=false;
*ErrArcName=0;
Cmd=NULL;
}
@@ -85,8 +87,6 @@ bool ScanTree::PrepareMasks()
strcatw(CurMaskW,MASKALLW);
}
SpecPathLengthW=NameW-CurMaskW;
// if (SpecPathLengthW>1)
// SpecPathLengthW--;
}
else
{
@@ -95,6 +95,10 @@ bool ScanTree::PrepareMasks()
SpecPathLengthW=PointToName(WideMask)-WideMask;
}
Depth=0;
strcpy(OrigCurMask,CurMask);
strcpyw(OrigCurMaskW,CurMaskW);
return(true);
}
@@ -135,6 +139,8 @@ int ScanTree::FindProc(FindData *FindData)
FastFindFile=true;
if (!FindCode)
{
if (Cmd!=NULL && Cmd->ExclCheck(CurMask,true))
return(SCAN_NEXT);
ErrHandler.OpenErrorMsg(ErrArcName,CurMask);
return(FindData->Error ? SCAN_ERROR:SCAN_NEXT);
}
@@ -150,6 +156,9 @@ int ScanTree::FindProc(FindData *FindData)
Error=false;
#endif
if (Cmd!=NULL && Cmd->ExclCheck(CurMask,true))
Error=false;
#ifndef SILENT
if (Error)
{
@@ -177,6 +186,8 @@ int ScanTree::FindProc(FindData *FindData)
{
char Mask[NM];
strcpy(Mask,Slash);
if (Depth<SetAllMaskDepth)
strcpy(Mask+1,PointToName(OrigCurMask));
*Slash=0;
strcpy(DirName,CurMask);
char *PrevSlash=strrchrd(CurMask,CPATHDIVIDER);
@@ -193,6 +204,8 @@ int ScanTree::FindProc(FindData *FindData)
{
wchar Mask[NM];
strcpyw(Mask,Slash);
if (Depth<SetAllMaskDepth)
strcpyw(Mask+1,PointToName(OrigCurMaskW));
*Slash=0;
strcpyw(DirNameW,CurMaskW);
wchar *PrevSlash=strrchrw(CurMaskW,CPATHDIVIDER);
@@ -217,8 +230,15 @@ int ScanTree::FindProc(FindData *FindData)
if (!FastFindFile && Depth==0 && !SearchAllInRoot)
return(GetDirs==SCAN_GETCURDIRS ? SCAN_SUCCESS:SCAN_NEXT);
// if (GetDirs==SCAN_GETCURDIRS && Depth==0 && !SearchAllInRoot)
// return(SCAN_SUCCESS);
char Mask[NM];
strcpy(Mask,FastFindFile ? MASKALL:PointToName(CurMask));
bool MaskAll=FastFindFile;
// bool MaskAll=CmpName(CurMask,FindData->Name,MATCH_NAMES);
strcpy(Mask,MaskAll ? MASKALL:PointToName(CurMask));
strcpy(CurMask,FindData->Name);
if (strlen(CurMask)+strlen(Mask)+1>=NM || Depth>=MAXSCANDEPTH-1)
@@ -250,6 +270,8 @@ int ScanTree::FindProc(FindData *FindData)
strcatw(CurMaskW,Mask);
}
Depth++;
if (MaskAll)
SetAllMaskDepth=Depth;
}
if (!FastFindFile && !CmpName(CurMask,FindData->Name,MATCH_NAMES))
return(SCAN_NEXT);

View File

@@ -7,6 +7,8 @@ enum { SCAN_SUCCESS,SCAN_DONE,SCAN_ERROR,SCAN_NEXT };
#define MAXSCANDEPTH (NM/2)
class CommandData;
class ScanTree
{
private:
@@ -16,6 +18,8 @@ class ScanTree
FindFile *FindStack[MAXSCANDEPTH];
int Depth;
int SetAllMaskDepth;
StringList *FileMasks;
int Recurse;
bool GetLinks;
@@ -24,12 +28,16 @@ class ScanTree
char CurMask[NM];
wchar CurMaskW[NM];
char OrigCurMask[NM];
wchar OrigCurMaskW[NM];
bool SearchAllInRoot;
bool FastFindFile;
int SpecPathLength;
int SpecPathLengthW;
char ErrArcName[NM];
CommandData *Cmd;
public:
ScanTree(StringList *FileMasks,int Recurse,bool GetLinks,int GetDirs);
~ScanTree();
@@ -38,6 +46,7 @@ class ScanTree
int GetSpecPathLengthW() {return(SpecPathLengthW);};
int GetErrors() {return(Errors);};
void SetErrArcName(const char *Name) {strcpy(ErrArcName,Name);}
void SetCommandData(CommandData *Cmd) {ScanTree::Cmd=Cmd;}
};
#endif

View File

@@ -47,7 +47,7 @@ A million repetitions of "a"
/* Hash a single 512-bit block. This is the core of the algorithm. */
void SHA1Transform(uint32 state[5], unsigned char buffer[64])
void SHA1Transform(uint32 state[5], unsigned char buffer[64], bool handsoff)
{
uint32 a, b, c, d, e;
typedef union {
@@ -55,13 +55,14 @@ void SHA1Transform(uint32 state[5], unsigned char buffer[64])
uint32 l[16];
} CHAR64LONG16;
CHAR64LONG16* block;
#ifdef SHA1HANDSOFF
static unsigned char workspace[64];
block = (CHAR64LONG16*)workspace;
memcpy(block, buffer, 64);
#else
block = (CHAR64LONG16*)buffer;
#endif
if (handsoff)
{
block = (CHAR64LONG16*)workspace;
memcpy(block, buffer, 64);
}
else
block = (CHAR64LONG16*)buffer;
#ifdef SFX_MODULE
static int pos[80][5];
static bool pinit=false;
@@ -151,7 +152,8 @@ void hash_initial(hash_context* context)
/* Run your data through this. */
void hash_process( hash_context * context, unsigned char * data, unsigned len )
void hash_process( hash_context * context, unsigned char * data, unsigned len,
bool handsoff )
{
unsigned int i, j;
uint blen = ((uint)len)<<3;
@@ -161,18 +163,28 @@ uint blen = ((uint)len)<<3;
context->count[1] += (len >> 29);
if ((j + len) > 63) {
memcpy(&context->buffer[j], data, (i = 64-j));
SHA1Transform(context->state, context->buffer);
SHA1Transform(context->state, context->buffer, handsoff);
for ( ; i + 63 < len; i += 64) {
SHA1Transform(context->state, &data[i]);
#ifdef ALLOW_NOT_ALIGNED_INT
SHA1Transform(context->state, &data[i], handsoff);
#else
unsigned char buffer[64];
memcpy(buffer,data+i,sizeof(buffer));
SHA1Transform(context->state, buffer, handsoff);
memcpy(data+i,buffer,sizeof(buffer));
#endif
#ifdef BIG_ENDIAN
unsigned char *d=data+i;
for (int k=0;k<64;k+=4)
if (!handsoff)
{
byte b0=d[k],b1=d[k+1];
d[k]=d[k+3];
d[k+1]=d[k+2];
d[k+2]=b1;
d[k+3]=b0;
unsigned char *d=data+i;
for (int k=0;k<64;k+=4)
{
byte b0=d[k],b1=d[k+1];
d[k]=d[k+3];
d[k+1]=d[k+2];
d[k+2]=b1;
d[k+3]=b0;
}
}
#endif
}
@@ -186,7 +198,7 @@ uint blen = ((uint)len)<<3;
/* Add padding and return the message digest. */
void hash_final( hash_context* context, uint32 digest[5] )
void hash_final( hash_context* context, uint32 digest[5], bool handsoff)
{
uint i, j;
unsigned char finalcount[8];
@@ -196,12 +208,12 @@ unsigned char finalcount[8];
>> ((3-(i & 3)) * 8) ) & 255); /* Endian independent */
}
unsigned char ch='\200';
hash_process(context, &ch, 1);
hash_process(context, &ch, 1, handsoff);
while ((context->count[0] & 504) != 448) {
ch=0;
hash_process(context, &ch, 1);
hash_process(context, &ch, 1, handsoff);
}
hash_process(context, finalcount, 8); /* Should cause a SHA1Transform() */
hash_process(context, finalcount, 8, handsoff); /* Should cause a SHA1Transform() */
for (i = 0; i < 5; i++) {
digest[i] = context->state[i] & 0xffffffff;
}
@@ -212,9 +224,8 @@ unsigned char finalcount[8];
memset(context->state, 0, 20);
memset(context->count, 0, 8);
memset(&finalcount, 0, 8);
#ifdef SHA1HANDSOFF /* make SHA1Transform overwrite it's own static vars */
SHA1Transform(context->state, context->buffer);
#endif
if (handsoff)
SHA1Transform(context->state, context->buffer, true);
}

View File

@@ -10,7 +10,8 @@ typedef struct {
} hash_context;
void hash_initial( hash_context * c );
void hash_process( hash_context * c, unsigned char * data, unsigned len );
void hash_final( hash_context * c, uint32[HW] );
void hash_process( hash_context * c, unsigned char * data, unsigned len,
bool handsoff);
void hash_final( hash_context * c, uint32[HW], bool handsoff);
#endif

View File

@@ -141,3 +141,25 @@ bool LowAscii(const wchar *Str)
}
int stricompc(const char *Str1,const char *Str2)
{
#if defined(_UNIX)
return(strcmp(Str1,Str2));
#else
return(stricomp(Str1,Str2));
#endif
}
#ifndef SFX_MODULE
int stricompcw(const wchar *Str1,const wchar *Str2)
{
#if defined(_UNIX)
return(strcmpw(Str1,Str2));
#else
return(stricmpw(Str1,Str2));
#endif
}
#endif

View File

@@ -21,4 +21,9 @@ bool LowAscii(const char *Str);
bool LowAscii(const wchar *Str);
int stricompc(const char *Str1,const char *Str2);
#ifndef SFX_MODULE
int stricompcw(const wchar *Str1,const wchar *Str2);
#endif
#endif

View File

@@ -38,6 +38,16 @@ inline uint SubAllocator::U2B(int NU)
}
/*
calculate RAR_MEM_BLK + Items address. Real RAR_MEM_BLK size must be
equal to UNIT_SIZE, so we cannot just add Items to RAR_MEM_BLK address
*/
inline RAR_MEM_BLK* SubAllocator::MBPtr(RAR_MEM_BLK *BasePtr,int Items)
{
return((RAR_MEM_BLK*)( ((byte *)(BasePtr))+U2B(Items) ));
}
inline void SubAllocator::SplitBlock(void* pv,int OldIndx,int NewIndx)
{
int i, UDiff=Indx2Units[OldIndx]-Indx2Units[NewIndx];
@@ -71,6 +81,9 @@ bool SubAllocator::StartSubAllocator(int SASize)
return TRUE;
StopSubAllocator();
uint AllocSize=t/FIXED_UNIT_SIZE*UNIT_SIZE+UNIT_SIZE;
#ifdef STRICT_ALIGNMENT_REQUIRED
AllocSize+=UNIT_SIZE;
#endif
if ((HeapStart=(byte *)rarmalloc(AllocSize)) == NULL)
{
ErrHandler.MemoryError();
@@ -91,6 +104,10 @@ void SubAllocator::InitSubAllocator()
uint RealSize2=Size2/FIXED_UNIT_SIZE*UNIT_SIZE;
uint Size1=SubAllocatorSize-Size2;
uint RealSize1=Size1/FIXED_UNIT_SIZE*UNIT_SIZE+Size1%FIXED_UNIT_SIZE;
#ifdef STRICT_ALIGNMENT_REQUIRED
if (Size1%FIXED_UNIT_SIZE!=0)
RealSize1+=UNIT_SIZE-Size1%FIXED_UNIT_SIZE;
#endif
HiUnit=HeapStart+SubAllocatorSize;
LoUnit=UnitsStart=HeapStart+RealSize1;
FakeUnitsStart=HeapStart+Size1;
@@ -126,19 +143,19 @@ inline void SubAllocator::GlueFreeBlocks()
p->NU=Indx2Units[i];
}
for (p=s0.next;p != &s0;p=p->next)
while ((p1=p+p->NU)->Stamp == 0xFFFF && int(p->NU)+p1->NU < 0x10000)
while ((p1=MBPtr(p,p->NU))->Stamp == 0xFFFF && int(p->NU)+p1->NU < 0x10000)
{
p1->remove();
p->NU += p1->NU;
}
while ((p=s0.next) != &s0)
{
for (p->remove(), sz=p->NU;sz > 128;sz -= 128, p += 128)
for (p->remove(), sz=p->NU;sz > 128;sz -= 128, p=MBPtr(p,128))
InsertNode(p,N_INDEXES-1);
if (Indx2Units[i=Units2Indx[sz-1]] != sz)
{
k=sz-Indx2Units[--i];
InsertNode(p+(sz-k),k-1);
InsertNode(MBPtr(p,sz-k),k-1);
}
InsertNode(p,i);
}
@@ -160,7 +177,7 @@ void* SubAllocator::AllocUnitsRare(int indx)
{
GlueCount--;
i=U2B(Indx2Units[indx]);
int j=12*Indx2Units[indx];
int j=FIXED_UNIT_SIZE*Indx2Units[indx];
if (FakeUnitsStart-pText > j)
{
FakeUnitsStart-=j;

View File

@@ -10,13 +10,16 @@
const int N1=4, N2=4, N3=4, N4=(128+3-1*N1-2*N2-3*N3)/4;
const int N_INDEXES=N1+N2+N3+N4;
#if defined(__GNUC__)
#if defined(__GNUC__) && !defined(STRICT_ALIGNMENT_REQUIRED)
#define _PACK_ATTR __attribute__ ((packed))
#else
#define _PACK_ATTR
#endif /* defined(__GNUC__) */
#ifndef STRICT_ALIGNMENT_REQUIRED
#pragma pack(1)
#endif
struct RAR_MEM_BLK
{
ushort Stamp, NU;
@@ -32,7 +35,15 @@ struct RAR_MEM_BLK
next->prev=prev;
}
} _PACK_ATTR;
#ifndef STRICT_ALIGNMENT_REQUIRED
#ifdef _AIX
#pragma pack(pop)
#else
#pragma pack()
#endif
#endif
struct RAR_NODE
{
@@ -49,6 +60,7 @@ class SubAllocator
uint GetUsedMemory();
inline void GlueFreeBlocks();
void* AllocUnitsRare(int indx);
inline RAR_MEM_BLK* MBPtr(RAR_MEM_BLK *BasePtr,int Items);
long SubAllocatorSize;
byte Indx2Units[N_INDEXES], Units2Indx[128], GlueCount;

View File

@@ -11,6 +11,12 @@ void InitSystemOptions(int SleepTime)
#if !defined(SFX_MODULE) && !defined(_WIN_CE)
#if defined(_WIN_32) && !defined(BELOW_NORMAL_PRIORITY_CLASS)
#define BELOW_NORMAL_PRIORITY_CLASS 0x00004000
#define ABOVE_NORMAL_PRIORITY_CLASS 0x00008000
#endif
void SetPriority(int Priority)
{
#ifdef _WIN_32
@@ -18,6 +24,7 @@ void SetPriority(int Priority)
int PriorityLevel;
if (Priority<1 || Priority>15)
return;
if (Priority==1)
{
PriorityClass=IDLE_PRIORITY_CLASS;
@@ -30,16 +37,28 @@ void SetPriority(int Priority)
PriorityLevel=Priority-4;
}
else
if (Priority<11)
if (Priority==7)
{
PriorityClass=NORMAL_PRIORITY_CLASS;
PriorityLevel=Priority-9;
PriorityClass=BELOW_NORMAL_PRIORITY_CLASS;
PriorityLevel=THREAD_PRIORITY_ABOVE_NORMAL;
}
else
{
PriorityClass=HIGH_PRIORITY_CLASS;
PriorityLevel=Priority-13;
}
if (Priority<10)
{
PriorityClass=NORMAL_PRIORITY_CLASS;
PriorityLevel=Priority-7;
}
else
if (Priority==10)
{
PriorityClass=ABOVE_NORMAL_PRIORITY_CLASS;
PriorityLevel=THREAD_PRIORITY_NORMAL;
}
else
{
PriorityClass=HIGH_PRIORITY_CLASS;
PriorityLevel=Priority-13;
}
SetPriorityClass(GetCurrentProcess(),PriorityClass);
SetThreadPriority(GetCurrentThread(),PriorityLevel);
#endif
@@ -49,6 +68,10 @@ void SetPriority(int Priority)
void Wait()
{
#if defined(_WIN_32) && !defined(_WIN_CE) && !defined(SFX_MODULE)
if (SleepTime!=0)
Sleep(SleepTime);
#endif
}

View File

@@ -23,7 +23,7 @@ RarTime& RarTime::operator =(FILETIME &ft)
for (int I=1;I<rlt.Month;I++)
{
static int mdays[12]={31,28,31,30,31,30,31,31,30,31,30,31};
rlt.yDay+=mdays[I];
rlt.yDay+=mdays[I-1];
}
if (rlt.Month>2 && IsLeapYear(rlt.Year))
rlt.yDay++;
@@ -118,7 +118,7 @@ void RarTime::SetRaw(Int64 RawTime)
#elif defined(_UNIX) || defined(_EMX)
time_t ut=int64to32(RawTime/10000000);
*this=ut;
rlt.Reminder=RawTime%10000000;
rlt.Reminder=int64to32(RawTime%10000000);
#endif
}
#endif

View File

@@ -32,7 +32,7 @@ class RarTime
#endif
#if defined(_UNIX) || defined(_EMX)
RarTime& operator =(time_t ut);
time_t RarTime::GetUnix();
time_t GetUnix();
#endif
bool operator == (RarTime &rt);
bool operator < (RarTime &rt);

View File

@@ -23,7 +23,8 @@ int ExtractLink(ComprDataIO &DataIO,Archive &Arc,char *DestName,uint &LinkCRC,bo
ErrHandler.SetErrorCode(RAR_WARNING);
}
}
LinkCRC=CRC(0xffffffff,FileName,DataSize);
int NameSize=Min(DataSize,strlen(FileName));
LinkCRC=CRC(0xffffffff,FileName,NameSize);
return(1);
}
#endif

View File

@@ -1,49 +1,82 @@
#include "rar.hpp"
void WideToChar(const wchar *Src,char *Dest,int DestSize)
#if defined(_EMX) && !defined(_DJGPP)
#include "unios2.cpp"
#endif
bool WideToChar(const wchar *Src,char *Dest,int DestSize)
{
bool RetCode=true;
#ifdef _WIN_32
WideCharToMultiByte(CP_ACP,0,Src,-1,Dest,DestSize,NULL,NULL);
if (WideCharToMultiByte(CP_ACP,0,Src,-1,Dest,DestSize,NULL,NULL)==0)
RetCode=false;
#else
#ifdef _APPLE
WideToUtf(Src,Dest,DestSize);
#else
#ifdef MBFUNCTIONS
if (wcstombs(Dest,Src,DestSize)==-1)
*Dest=0;
RetCode=false;
#else
for (int I=0;I<DestSize;I++)
if (UnicodeEnabled())
{
Dest[I]=(char)Src[I];
if (Src[I]==0)
break;
#if defined(_EMX) && !defined(_DJGPP)
int len=Min(strlenw(Src)+1,DestSize-1);
if (uni_fromucs((UniChar*)Src,len,Dest,(size_t*)&DestSize)==-1 ||
DestSize>len*2)
RetCode=false;
Dest[DestSize]=0;
#endif
}
else
for (int I=0;I<DestSize;I++)
{
Dest[I]=(char)Src[I];
if (Src[I]==0)
break;
}
#endif
#endif
#endif
return(RetCode);
}
void CharToWide(const char *Src,wchar *Dest,int DestSize)
bool CharToWide(const char *Src,wchar *Dest,int DestSize)
{
bool RetCode=true;
#ifdef _WIN_32
MultiByteToWideChar(CP_ACP,0,Src,-1,Dest,DestSize);
if (MultiByteToWideChar(CP_ACP,0,Src,-1,Dest,DestSize)==0)
RetCode=false;
#else
#ifdef _APPLE
UtfToWide(Src,Dest,DestSize);
#else
#ifdef MBFUNCTIONS
mbstowcs(Dest,Src,DestSize);
if (mbstowcs(Dest,Src,DestSize)==-1)
RetCode=false;
#else
for (int I=0;I<DestSize;I++)
if (UnicodeEnabled())
{
Dest[I]=(wchar_t)Src[I];
if (Src[I]==0)
break;
#if defined(_EMX) && !defined(_DJGPP)
int len=Min(strlen(Src)+1,DestSize-1);
if (uni_toucs((char*)Src,len,(UniChar*)Dest,(size_t*)&DestSize)==-1 ||
DestSize>len)
DestSize=0;
RetCode=false;
#endif
}
else
for (int I=0;I<DestSize;I++)
{
Dest[I]=(wchar_t)Src[I];
if (Src[I]==0)
break;
}
#endif
#endif
#endif
return(RetCode);
}
@@ -69,7 +102,6 @@ wchar* RawToWide(const byte *Src,wchar *Dest,int DestSize)
}
#ifdef _APPLE
void WideToUtf(const wchar *Src,char *Dest,int DestSize)
{
DestSize--;
@@ -91,13 +123,19 @@ void WideToUtf(const wchar *Src,char *Dest,int DestSize)
*(Dest++)=(0x80|((c>>6)&0x3f));
*(Dest++)=(0x80|(c&0x3f));
}
else
if (c < 0x200000 && (DestSize-=3)>=0)
{
*(Dest++)=(0xf0|(c>>18));
*(Dest++)=(0x80|((c>>12)&0x3f));
*(Dest++)=(0x80|((c>>6)&0x3f));
*(Dest++)=(0x80|(c&0x3f));
}
}
*Dest=0;
}
#endif
#ifdef _APPLE
void UtfToWide(const char *Src,wchar *Dest,int DestSize)
{
DestSize--;
@@ -123,14 +161,43 @@ void UtfToWide(const char *Src,wchar *Dest,int DestSize)
Src+=2;
}
else
break;
if ((c>>3)==30)
{
if ((Src[0]&0xc0)!=0x80 || (Src[1]&0xc0)!=0x80 || (Src[2]&0xc0)!=0x80)
break;
d=((c&7)<<18)|((Src[0]&0x3f)<<12)|((Src[1]&0x3f)<<6)|(Src[2]&0x3f);
Src+=3;
}
else
break;
if (--DestSize<0)
break;
*(Dest++)=d;
if (d>0xffff)
{
if (--DestSize<0 || d>0x10ffff)
break;
*(Dest++)=((d-0x10000)>>10)+0xd800;
*(Dest++)=(d&0x3ff)+0xdc00;
}
else
*(Dest++)=d;
}
*Dest=0;
}
bool UnicodeEnabled()
{
#ifdef UNICODE_SUPPORTED
#ifdef _EMX
return(uni_ready);
#else
return(true);
#endif
#else
return(false);
#endif
}
int strlenw(const wchar *str)
@@ -349,6 +416,21 @@ char* SupportDBCS::charnext(const char *s)
}
uint SupportDBCS::strlend(const char *s)
{
uint Length=0;
while (*s!=0)
{
if (IsLeadByte[*s])
s+=2;
else
s++;
Length++;
}
return(Length);
}
char* SupportDBCS::strchrd(const char *s, int c)
{
while (*s!=0)

View File

@@ -5,7 +5,7 @@
#define MBFUNCTIONS
#endif
#if defined(MBFUNCTIONS) || defined(_WIN_32)
#if defined(MBFUNCTIONS) || defined(_WIN_32) || defined(_EMX) && !defined(_DJGPP)
#define UNICODE_SUPPORTED
#endif
@@ -13,12 +13,18 @@
#define DBCS_SUPPORTED
#endif
void WideToChar(const wchar *Src,char *Dest,int DestSize=0x10000000);
void CharToWide(const char *Src,wchar *Dest,int DestSize=0x10000000);
#ifdef _EMX
int uni_init(int codepage);
int uni_done();
#endif
bool WideToChar(const wchar *Src,char *Dest,int DestSize=0x10000000);
bool CharToWide(const char *Src,wchar *Dest,int DestSize=0x10000000);
byte* WideToRaw(const wchar *Src,byte *Dest,int DestSize=0x10000000);
wchar* RawToWide(const byte *Src,wchar *Dest,int DestSize=0x10000000);
void WideToUtf(const wchar *Src,char *Dest,int DestSize);
void UtfToWide(const char *Src,wchar *Dest,int DestSize);
bool UnicodeEnabled();
int strlenw(const wchar *str);
wchar* strcpyw(wchar *dest,const wchar *src);
@@ -45,6 +51,7 @@ class SupportDBCS
void Init();
char* charnext(const char *s);
uint strlend(const char *s);
char *strchrd(const char *s, int c);
char *strrchrd(const char *s, int c);
void copychrd(char *dest,const char *src);
@@ -56,6 +63,7 @@ class SupportDBCS
extern SupportDBCS gdbcs;
inline char* charnext(const char *s) {return (char *)(gdbcs.DBCSMode ? gdbcs.charnext(s):s+1);}
inline uint strlend(const char *s) {return (uint)(gdbcs.DBCSMode ? gdbcs.strlend(s):strlen(s));}
inline char* strchrd(const char *s, int c) {return (char *)(gdbcs.DBCSMode ? gdbcs.strchrd(s,c):strchr(s,c));}
inline char* strrchrd(const char *s, int c) {return (char *)(gdbcs.DBCSMode ? gdbcs.strrchrd(s,c):strrchr(s,c));}
inline void copychrd(char *dest,const char *src) {if (gdbcs.DBCSMode) gdbcs.copychrd(dest,src); else *dest=*src;}
@@ -64,6 +72,7 @@ inline void InitDBCS() {gdbcs.Init();}
#else
#define charnext(s) ((s)+1)
#define strlend strlen
#define strchrd strchr
#define strrchrd strrchr
#define IsDBCSMode() (true)

View File

@@ -51,15 +51,16 @@ void Unpack::DoUnpack(int Method,bool Solid)
switch(Method)
{
#ifndef SFX_MODULE
case 15:
case 15: // rar 1.5 compression
Unpack15(Solid);
break;
case 20:
case 26:
case 20: // rar 2.x compression
case 26: // files larger than 2GB
Unpack20(Solid);
break;
#endif
case 29:
case 29: // rar 3.x compression
case 36: // alternative hash
Unpack29(Solid);
break;
}
@@ -441,12 +442,27 @@ bool Unpack::ReadVMCode()
bool Unpack::ReadVMCodePPM()
{
unsigned int FirstByte=PPM.DecodeChar();
if ((int)FirstByte==-1)
return(false);
int Length=(FirstByte & 7)+1;
if (Length==7)
Length=PPM.DecodeChar()+7;
{
int B1=PPM.DecodeChar();
if (B1==-1)
return(false);
Length=B1+7;
}
else
if (Length==8)
Length=PPM.DecodeChar()*256+PPM.DecodeChar();
{
int B1=PPM.DecodeChar();
if (B1==-1)
return(false);
int B2=PPM.DecodeChar();
if (B2==-1)
return(false);
Length=B1*256+B2;
}
Array<byte> VMCode(Length);
for (int I=0;I<Length;I++)
{
@@ -666,7 +682,7 @@ void Unpack::UnpWriteBuf()
{
UnpackFilter *NextFilter=PrgStack[I+1];
if (NextFilter==NULL || NextFilter->BlockStart!=BlockStart ||
NextFilter->BlockLength!=FilteredDataSize)
NextFilter->BlockLength!=FilteredDataSize || NextFilter->NextWindow)
break;
VM.SetMemory(0,FilteredData,FilteredDataSize);
VM_PreparedProgram *NextPrg=&PrgStack[I+1]->Prg;

View File

@@ -81,7 +81,7 @@ struct AudioVariables
/***************************** Unpack v 2.0 *********************************/
class Unpack:BitInput
class Unpack:private BitInput
{
private:
friend class Pack;

View File

@@ -25,12 +25,18 @@ void ExtractUnixOwner(Archive &Arc,char *FileName)
ErrHandler.SetErrorCode(RAR_CRC_ERROR);
return;
}
uint Attr=GetFileAttr(FileName,NULL);
gid_t GroupID=gr->gr_gid;
#if defined(SAVE_LINKS) && !defined(_APPLE)
if (lchown(FileName,OwnerID,GroupID)!=0)
#else
if (chown(FileName,OwnerID,GroupID)!=0)
#endif
{
Log(Arc.FileName,St(MSetOwnersError),FileName);
ErrHandler.SetErrorCode(RAR_CRC_ERROR);
}
SetFileAttr(FileName,NULL,Attr);
}
@@ -59,10 +65,16 @@ void ExtractUnixOwnerNew(Archive &Arc,char *FileName)
ErrHandler.SetErrorCode(RAR_CRC_ERROR);
return;
}
uint Attr=GetFileAttr(FileName,NULL);
gid_t GroupID=gr->gr_gid;
#if defined(SAVE_LINKS) && !defined(_APPLE)
if (lchown(FileName,OwnerID,GroupID)!=0)
#else
if (chown(FileName,OwnerID,GroupID)!=0)
#endif
{
Log(Arc.FileName,St(MSetOwnersError),FileName);
ErrHandler.SetErrorCode(RAR_CRC_ERROR);
}
SetFileAttr(FileName,NULL,Attr);
}

View File

@@ -1,6 +1,6 @@
#define RARVER_MAJOR 3
#define RARVER_MINOR 30
#define RARVER_BETA 0
#define RARVER_DAY 30
#define RARVER_MONTH 1
#define RARVER_YEAR 2004
#define RARVER_MINOR 60
#define RARVER_BETA 2
#define RARVER_DAY 18
#define RARVER_MONTH 4
#define RARVER_YEAR 2006

View File

@@ -1,7 +1,5 @@
#include "rar.hpp"
static void GetFirstNewVolName(const char *ArcName,char *VolName,
Int64 VolSize,Int64 TotalSize);
@@ -56,7 +54,13 @@ bool MergeArchive(Archive &Arc,ComprDataIO *DataIO,bool ShowFileName,char Comman
}
if (Cmd->ChangeVolProc!=NULL)
{
#if defined(_WIN_32) && !defined(_MSC_VER) && !defined(__MINGW32__)
_EBX=_ESP;
#endif
int RetCode=Cmd->ChangeVolProc(NextName,RAR_VOL_ASK);
#if defined(_WIN_32) && !defined(_MSC_VER) && !defined(__MINGW32__)
_ESP=_EBX;
#endif
if (RetCode==0)
{
Cmd->DllError=ERAR_EOPEN;
@@ -79,7 +83,6 @@ bool MergeArchive(Archive &Arc,ComprDataIO *DataIO,bool ShowFileName,char Comman
#ifndef GUI
if (!Cmd->VolumePause && !IsRemovable(NextName))
{
Log(Arc.FileName,St(MAbsNextVol),NextName);
FailedOpen=true;
break;
}
@@ -95,6 +98,9 @@ bool MergeArchive(Archive &Arc,ComprDataIO *DataIO,bool ShowFileName,char Comman
}
if (FailedOpen)
{
#if !defined(SILENT) && !defined(_WIN_CE)
Log(Arc.FileName,St(MAbsNextVol),NextName);
#endif
Arc.Open(Arc.FileName,Arc.FileNameW);
Arc.Seek(PosBeforeClose,SEEK_SET);
return(false);
@@ -106,14 +112,22 @@ bool MergeArchive(Archive &Arc,ComprDataIO *DataIO,bool ShowFileName,char Comman
return(false);
if (Cmd->ChangeVolProc!=NULL)
{
#if defined(_WIN_32) && !defined(_MSC_VER) && !defined(__MINGW32__)
_EBX=_ESP;
#endif
int RetCode=Cmd->ChangeVolProc(NextName,RAR_VOL_NOTIFY);
#if defined(_WIN_32) && !defined(_MSC_VER) && !defined(__MINGW32__)
_ESP=_EBX;
#endif
if (RetCode==0)
return(false);
}
#endif
#ifndef GUI
if (Command=='T' || Command=='X' || Command=='E')
mprintf(St(Command=='T' ? MTestVol:MExtrVol),Arc.FileName);
#endif
if (SplitHeader)
Arc.SearchBlock(HeaderType);
else
@@ -126,7 +140,20 @@ bool MergeArchive(Archive &Arc,ComprDataIO *DataIO,bool ShowFileName,char Comman
#ifndef GUI
if (ShowFileName)
{
mprintf(St(MExtrPoints),IntNameToExt(Arc.NewLhd.FileName));
char OutName[NM];
IntToExt(Arc.NewLhd.FileName,OutName);
#ifdef UNICODE_SUPPORTED
bool WideName=(Arc.NewLhd.Flags & LHD_UNICODE) && UnicodeEnabled();
if (WideName)
{
wchar NameW[NM];
ConvertPath(Arc.NewLhd.FileNameW,NameW);
char Name[NM];
if (WideToChar(NameW,Name) && IsNameUsable(Name))
strcpy(OutName,Name);
}
#endif
mprintf(St(MExtrPoints),OutName);
if (!Cmd->DisablePercentage)
mprintf(" ");
}
@@ -140,6 +167,10 @@ bool MergeArchive(Archive &Arc,ComprDataIO *DataIO,bool ShowFileName,char Comman
DataIO->UnpVolume=(hd->Flags & LHD_SPLIT_AFTER);
DataIO->SetPackedSizeToRead(hd->FullPackSize);
}
#ifdef SFX_MODULE
DataIO->UnpArcSize=Arc.FileLength();
DataIO->CurUnpRead=0;
#endif
DataIO->PackedCRC=0xffffffff;
// DataIO->SetFiles(&Arc,NULL);
}