Adding initial files which contains the unrar.3.9.6 sources and a patch for the Makefile
This commit is contained in:
commit
9929851140
|
@ -0,0 +1,2 @@
|
|||
/* Localized versions of Info.plist keys */
|
||||
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,281 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||
<plist version="1.0">
|
||||
<dict>
|
||||
<key>CFBundleDevelopmentRegion</key>
|
||||
<string>English</string>
|
||||
<key>CFBundleDocumentTypes</key>
|
||||
<array>
|
||||
<dict>
|
||||
<key>CFBundleTypeExtensions</key>
|
||||
<array>
|
||||
<string>rar</string>
|
||||
<string>r00</string>
|
||||
<string>r01</string>
|
||||
<string>r02</string>
|
||||
<string>r03</string>
|
||||
<string>r04</string>
|
||||
<string>r05</string>
|
||||
<string>r06</string>
|
||||
<string>r07</string>
|
||||
<string>r08</string>
|
||||
<string>r09</string>
|
||||
<string>r10</string>
|
||||
<string>r11</string>
|
||||
<string>r12</string>
|
||||
<string>r13</string>
|
||||
<string>r14</string>
|
||||
<string>r15</string>
|
||||
<string>r16</string>
|
||||
<string>r17</string>
|
||||
<string>r18</string>
|
||||
<string>r19</string>
|
||||
<string>r20</string>
|
||||
<string>r21</string>
|
||||
<string>r22</string>
|
||||
<string>r23</string>
|
||||
<string>r24</string>
|
||||
<string>r25</string>
|
||||
<string>r26</string>
|
||||
<string>r27</string>
|
||||
<string>r28</string>
|
||||
<string>r29</string>
|
||||
<string>r30</string>
|
||||
<string>r31</string>
|
||||
<string>r32</string>
|
||||
<string>r33</string>
|
||||
<string>r34</string>
|
||||
<string>r35</string>
|
||||
<string>r36</string>
|
||||
<string>r37</string>
|
||||
<string>r38</string>
|
||||
<string>r39</string>
|
||||
<string>r40</string>
|
||||
<string>r41</string>
|
||||
<string>r42</string>
|
||||
<string>r43</string>
|
||||
<string>r44</string>
|
||||
<string>r45</string>
|
||||
<string>r46</string>
|
||||
<string>r47</string>
|
||||
<string>r48</string>
|
||||
<string>r49</string>
|
||||
<string>r50</string>
|
||||
<string>r51</string>
|
||||
<string>r52</string>
|
||||
<string>r53</string>
|
||||
<string>r54</string>
|
||||
<string>r55</string>
|
||||
<string>r56</string>
|
||||
<string>r57</string>
|
||||
<string>r58</string>
|
||||
<string>r59</string>
|
||||
<string>r60</string>
|
||||
<string>r61</string>
|
||||
<string>r62</string>
|
||||
<string>r63</string>
|
||||
<string>r64</string>
|
||||
<string>r65</string>
|
||||
<string>r66</string>
|
||||
<string>r67</string>
|
||||
<string>r68</string>
|
||||
<string>r69</string>
|
||||
<string>r70</string>
|
||||
<string>r71</string>
|
||||
<string>r72</string>
|
||||
<string>r73</string>
|
||||
<string>r74</string>
|
||||
<string>r75</string>
|
||||
<string>r76</string>
|
||||
<string>r77</string>
|
||||
<string>r78</string>
|
||||
<string>r79</string>
|
||||
<string>r80</string>
|
||||
<string>r81</string>
|
||||
<string>r82</string>
|
||||
<string>r83</string>
|
||||
<string>r84</string>
|
||||
<string>r85</string>
|
||||
<string>r86</string>
|
||||
<string>r87</string>
|
||||
<string>r88</string>
|
||||
<string>r89</string>
|
||||
<string>r90</string>
|
||||
<string>r91</string>
|
||||
<string>r92</string>
|
||||
<string>r93</string>
|
||||
<string>r94</string>
|
||||
<string>r95</string>
|
||||
<string>r96</string>
|
||||
<string>r97</string>
|
||||
<string>r98</string>
|
||||
<string>r99</string>
|
||||
</array>
|
||||
<key>CFBundleTypeIconFile</key>
|
||||
<string></string>
|
||||
<key>CFBundleTypeName</key>
|
||||
<string>RAR Archive</string>
|
||||
<key>CFBundleTypeRole</key>
|
||||
<string>Viewer</string>
|
||||
<key>LSItemContentTypes</key>
|
||||
<array>
|
||||
<string>com.rarlab.rar-archive</string>
|
||||
</array>
|
||||
<key>NSDocumentClass</key>
|
||||
<string>ZipDocument</string>
|
||||
</dict>
|
||||
</array>
|
||||
<key>CFBundleExecutable</key>
|
||||
<string>${EXECUTABLE_NAME}</string>
|
||||
<key>CFBundleIconFile</key>
|
||||
<string></string>
|
||||
<key>CFBundleIdentifier</key>
|
||||
<string>com.yourcompany.${PRODUCT_NAME:rfc1034identifier}</string>
|
||||
<key>CFBundleInfoDictionaryVersion</key>
|
||||
<string>6.0</string>
|
||||
<key>CFBundleName</key>
|
||||
<string>${PRODUCT_NAME}</string>
|
||||
<key>CFBundlePackageType</key>
|
||||
<string>APPL</string>
|
||||
<key>CFBundleShortVersionString</key>
|
||||
<string>1.0</string>
|
||||
<key>CFBundleSignature</key>
|
||||
<string>????</string>
|
||||
<key>CFBundleVersion</key>
|
||||
<string>1</string>
|
||||
<key>LSMinimumSystemVersion</key>
|
||||
<string>${MACOSX_DEPLOYMENT_TARGET}</string>
|
||||
<key>NSMainNibFile</key>
|
||||
<string>MainMenu</string>
|
||||
<key>NSPrincipalClass</key>
|
||||
<string>NSApplication</string>
|
||||
<key>UTImportedTypeDeclarations</key>
|
||||
<array>
|
||||
<dict>
|
||||
<key>UTTypeConformsTo</key>
|
||||
<array>
|
||||
<string>public.data</string>
|
||||
<string>public.archive</string>
|
||||
</array>
|
||||
<key>UTTypeDescription</key>
|
||||
<string>RAR Archive</string>
|
||||
<key>UTTypeIconFile</key>
|
||||
<string>RAR</string>
|
||||
<key>UTTypeIdentifier</key>
|
||||
<string>com.rarlab.rar-archive</string>
|
||||
<key>UTTypeTagSpecification</key>
|
||||
<dict>
|
||||
<key>public.filename-extension</key>
|
||||
<array>
|
||||
<string>rar</string>
|
||||
<string>r00</string>
|
||||
<string>r01</string>
|
||||
<string>r02</string>
|
||||
<string>r03</string>
|
||||
<string>r04</string>
|
||||
<string>r05</string>
|
||||
<string>r06</string>
|
||||
<string>r07</string>
|
||||
<string>r08</string>
|
||||
<string>r09</string>
|
||||
<string>r10</string>
|
||||
<string>r11</string>
|
||||
<string>r12</string>
|
||||
<string>r13</string>
|
||||
<string>r14</string>
|
||||
<string>r15</string>
|
||||
<string>r16</string>
|
||||
<string>r17</string>
|
||||
<string>r18</string>
|
||||
<string>r19</string>
|
||||
<string>r20</string>
|
||||
<string>r21</string>
|
||||
<string>r22</string>
|
||||
<string>r23</string>
|
||||
<string>r24</string>
|
||||
<string>r25</string>
|
||||
<string>r26</string>
|
||||
<string>r27</string>
|
||||
<string>r28</string>
|
||||
<string>r29</string>
|
||||
<string>r30</string>
|
||||
<string>r31</string>
|
||||
<string>r32</string>
|
||||
<string>r33</string>
|
||||
<string>r34</string>
|
||||
<string>r35</string>
|
||||
<string>r36</string>
|
||||
<string>r37</string>
|
||||
<string>r38</string>
|
||||
<string>r39</string>
|
||||
<string>r40</string>
|
||||
<string>r41</string>
|
||||
<string>r42</string>
|
||||
<string>r43</string>
|
||||
<string>r44</string>
|
||||
<string>r45</string>
|
||||
<string>r46</string>
|
||||
<string>r47</string>
|
||||
<string>r48</string>
|
||||
<string>r49</string>
|
||||
<string>r50</string>
|
||||
<string>r51</string>
|
||||
<string>r52</string>
|
||||
<string>r53</string>
|
||||
<string>r54</string>
|
||||
<string>r55</string>
|
||||
<string>r56</string>
|
||||
<string>r57</string>
|
||||
<string>r58</string>
|
||||
<string>r59</string>
|
||||
<string>r60</string>
|
||||
<string>r61</string>
|
||||
<string>r62</string>
|
||||
<string>r63</string>
|
||||
<string>r64</string>
|
||||
<string>r65</string>
|
||||
<string>r66</string>
|
||||
<string>r67</string>
|
||||
<string>r68</string>
|
||||
<string>r69</string>
|
||||
<string>r70</string>
|
||||
<string>r71</string>
|
||||
<string>r72</string>
|
||||
<string>r73</string>
|
||||
<string>r74</string>
|
||||
<string>r75</string>
|
||||
<string>r76</string>
|
||||
<string>r77</string>
|
||||
<string>r78</string>
|
||||
<string>r79</string>
|
||||
<string>r80</string>
|
||||
<string>r81</string>
|
||||
<string>r82</string>
|
||||
<string>r83</string>
|
||||
<string>r84</string>
|
||||
<string>r85</string>
|
||||
<string>r86</string>
|
||||
<string>r87</string>
|
||||
<string>r88</string>
|
||||
<string>r89</string>
|
||||
<string>r90</string>
|
||||
<string>r91</string>
|
||||
<string>r92</string>
|
||||
<string>r93</string>
|
||||
<string>r94</string>
|
||||
<string>r95</string>
|
||||
<string>r96</string>
|
||||
<string>r97</string>
|
||||
<string>r98</string>
|
||||
<string>r99</string>
|
||||
</array>
|
||||
<key>public.mime-type</key>
|
||||
<array>
|
||||
<string>application/x-rar</string>
|
||||
<string>application/x-rar-compressed</string>
|
||||
</array>
|
||||
</dict>
|
||||
</dict>
|
||||
</array>
|
||||
</dict>
|
||||
</plist>
|
|
@ -0,0 +1,610 @@
|
|||
// !$*UTF8*$!
|
||||
{
|
||||
archiveVersion = 1;
|
||||
classes = {
|
||||
};
|
||||
objectVersion = 46;
|
||||
objects = {
|
||||
|
||||
/* Begin PBXBuildFile section */
|
||||
256AC3DA0F4B6AC300CF3369 /* QuietUnrarAppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 256AC3D90F4B6AC300CF3369 /* QuietUnrarAppDelegate.m */; };
|
||||
8D11072D0486CEB800E47090 /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 29B97316FDCFA39411CA2CEA /* main.m */; settings = {ATTRIBUTES = (); }; };
|
||||
8D11072F0486CEB800E47090 /* Cocoa.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1058C7A1FEA54F0111CA2CBB /* Cocoa.framework */; };
|
||||
D4A49691105435BE00BE38AE /* InfoPlist.strings in Resources */ = {isa = PBXBuildFile; fileRef = 089C165CFE840E0CC02AAC07 /* InfoPlist.strings */; };
|
||||
D4A49692105435C100BE38AE /* MainMenu.xib in Resources */ = {isa = PBXBuildFile; fileRef = 1DDD58140DA1D0A300B32029 /* MainMenu.xib */; };
|
||||
D4A96E2110545E9A0091ECB4 /* Carbon.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = D4A96E2010545E9A0091ECB4 /* Carbon.framework */; };
|
||||
/* End PBXBuildFile section */
|
||||
|
||||
/* Begin PBXContainerItemProxy section */
|
||||
D4A4964C10541CFF00BE38AE /* PBXContainerItemProxy */ = {
|
||||
isa = PBXContainerItemProxy;
|
||||
containerPortal = 29B97313FDCFA39411CA2CEA /* Project object */;
|
||||
proxyType = 1;
|
||||
remoteGlobalIDString = D4A4962A105419AA00BE38AE;
|
||||
remoteInfo = libunrar;
|
||||
};
|
||||
/* End PBXContainerItemProxy section */
|
||||
|
||||
/* Begin PBXCopyFilesBuildPhase section */
|
||||
D4A4965210541D2600BE38AE /* CopyFiles */ = {
|
||||
isa = PBXCopyFilesBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
dstPath = "";
|
||||
dstSubfolderSpec = 7;
|
||||
files = (
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
/* End PBXCopyFilesBuildPhase section */
|
||||
|
||||
/* Begin PBXFileReference section */
|
||||
089C165DFE840E0CC02AAC07 /* English */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.strings; name = English; path = English.lproj/InfoPlist.strings; sourceTree = "<group>"; };
|
||||
1058C7A1FEA54F0111CA2CBB /* Cocoa.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Cocoa.framework; path = /System/Library/Frameworks/Cocoa.framework; sourceTree = "<absolute>"; };
|
||||
13E42FB307B3F0F600E4EEF1 /* CoreData.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreData.framework; path = /System/Library/Frameworks/CoreData.framework; sourceTree = "<absolute>"; };
|
||||
1DDD58150DA1D0A300B32029 /* English */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = English; path = English.lproj/MainMenu.xib; sourceTree = "<group>"; };
|
||||
256AC3D80F4B6AC300CF3369 /* QuietUnrarAppDelegate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = QuietUnrarAppDelegate.h; sourceTree = "<group>"; };
|
||||
256AC3D90F4B6AC300CF3369 /* QuietUnrarAppDelegate.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = QuietUnrarAppDelegate.m; sourceTree = "<group>"; };
|
||||
256AC3F00F4B6AF500CF3369 /* QuietUnrar_Prefix.pch */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = QuietUnrar_Prefix.pch; sourceTree = "<group>"; };
|
||||
29B97316FDCFA39411CA2CEA /* main.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = "<group>"; };
|
||||
29B97324FDCFA39411CA2CEA /* AppKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = AppKit.framework; path = /System/Library/Frameworks/AppKit.framework; sourceTree = "<absolute>"; };
|
||||
29B97325FDCFA39411CA2CEA /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = /System/Library/Frameworks/Foundation.framework; sourceTree = "<absolute>"; };
|
||||
8D1107310486CEB800E47090 /* QuietUnrar-Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = "QuietUnrar-Info.plist"; sourceTree = "<group>"; };
|
||||
8D1107320486CEB800E47090 /* QuietUnrar.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = QuietUnrar.app; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||
D4A495741054177300BE38AE /* arccmt.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = arccmt.cpp; path = libunrar/arccmt.cpp; sourceTree = "<group>"; };
|
||||
D4A495751054177300BE38AE /* archive.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = archive.cpp; path = libunrar/archive.cpp; sourceTree = "<group>"; };
|
||||
D4A495761054177300BE38AE /* archive.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; name = archive.hpp; path = libunrar/archive.hpp; sourceTree = "<group>"; };
|
||||
D4A495771054177300BE38AE /* arcread.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = arcread.cpp; path = libunrar/arcread.cpp; sourceTree = "<group>"; };
|
||||
D4A495781054177300BE38AE /* array.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; name = array.hpp; path = libunrar/array.hpp; sourceTree = "<group>"; };
|
||||
D4A495791054177300BE38AE /* beosea.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = beosea.cpp; path = libunrar/beosea.cpp; sourceTree = "<group>"; };
|
||||
D4A4957A1054177300BE38AE /* cmddata.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = cmddata.cpp; path = libunrar/cmddata.cpp; sourceTree = "<group>"; };
|
||||
D4A4957B1054177300BE38AE /* cmddata.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; name = cmddata.hpp; path = libunrar/cmddata.hpp; sourceTree = "<group>"; };
|
||||
D4A4957C1054177300BE38AE /* coder.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = coder.cpp; path = libunrar/coder.cpp; sourceTree = "<group>"; };
|
||||
D4A4957D1054177300BE38AE /* coder.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; name = coder.hpp; path = libunrar/coder.hpp; sourceTree = "<group>"; };
|
||||
D4A4957E1054177300BE38AE /* compress.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; name = compress.hpp; path = libunrar/compress.hpp; sourceTree = "<group>"; };
|
||||
D4A4957F1054177300BE38AE /* consio.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = consio.cpp; path = libunrar/consio.cpp; sourceTree = "<group>"; };
|
||||
D4A495801054177300BE38AE /* consio.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; name = consio.hpp; path = libunrar/consio.hpp; sourceTree = "<group>"; };
|
||||
D4A495811054177300BE38AE /* crc.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = crc.cpp; path = libunrar/crc.cpp; sourceTree = "<group>"; };
|
||||
D4A495821054177300BE38AE /* crc.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; name = crc.hpp; path = libunrar/crc.hpp; sourceTree = "<group>"; };
|
||||
D4A495831054177300BE38AE /* crypt.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = crypt.cpp; path = libunrar/crypt.cpp; sourceTree = "<group>"; };
|
||||
D4A495841054177300BE38AE /* crypt.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; name = crypt.hpp; path = libunrar/crypt.hpp; sourceTree = "<group>"; };
|
||||
D4A495851054177300BE38AE /* dll.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = dll.cpp; path = libunrar/dll.cpp; sourceTree = "<group>"; };
|
||||
D4A495861054177300BE38AE /* dll.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; name = dll.hpp; path = libunrar/dll.hpp; sourceTree = "<group>"; };
|
||||
D4A495871054177300BE38AE /* encname.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = encname.cpp; path = libunrar/encname.cpp; sourceTree = "<group>"; };
|
||||
D4A495881054177300BE38AE /* encname.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; name = encname.hpp; path = libunrar/encname.hpp; sourceTree = "<group>"; };
|
||||
D4A495891054177300BE38AE /* errhnd.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = errhnd.cpp; path = libunrar/errhnd.cpp; sourceTree = "<group>"; };
|
||||
D4A4958A1054177300BE38AE /* errhnd.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; name = errhnd.hpp; path = libunrar/errhnd.hpp; sourceTree = "<group>"; };
|
||||
D4A4958B1054177300BE38AE /* extinfo.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = extinfo.cpp; path = libunrar/extinfo.cpp; sourceTree = "<group>"; };
|
||||
D4A4958C1054177300BE38AE /* extinfo.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; name = extinfo.hpp; path = libunrar/extinfo.hpp; sourceTree = "<group>"; };
|
||||
D4A4958D1054177300BE38AE /* extract.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = extract.cpp; path = libunrar/extract.cpp; sourceTree = "<group>"; };
|
||||
D4A4958E1054177300BE38AE /* extract.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; name = extract.hpp; path = libunrar/extract.hpp; sourceTree = "<group>"; };
|
||||
D4A4958F1054177300BE38AE /* filcreat.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = filcreat.cpp; path = libunrar/filcreat.cpp; sourceTree = "<group>"; };
|
||||
D4A495901054177300BE38AE /* filcreat.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; name = filcreat.hpp; path = libunrar/filcreat.hpp; sourceTree = "<group>"; };
|
||||
D4A495911054177300BE38AE /* file.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = file.cpp; path = libunrar/file.cpp; sourceTree = "<group>"; };
|
||||
D4A495921054177300BE38AE /* file.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; name = file.hpp; path = libunrar/file.hpp; sourceTree = "<group>"; };
|
||||
D4A495931054177300BE38AE /* filefn.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = filefn.cpp; path = libunrar/filefn.cpp; sourceTree = "<group>"; };
|
||||
D4A495941054177300BE38AE /* filefn.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; name = filefn.hpp; path = libunrar/filefn.hpp; sourceTree = "<group>"; };
|
||||
D4A495951054177300BE38AE /* filestr.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = filestr.cpp; path = libunrar/filestr.cpp; sourceTree = "<group>"; };
|
||||
D4A495961054177300BE38AE /* filestr.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; name = filestr.hpp; path = libunrar/filestr.hpp; sourceTree = "<group>"; };
|
||||
D4A495971054177300BE38AE /* find.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = find.cpp; path = libunrar/find.cpp; sourceTree = "<group>"; };
|
||||
D4A495981054177300BE38AE /* find.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; name = find.hpp; path = libunrar/find.hpp; sourceTree = "<group>"; };
|
||||
D4A495991054177300BE38AE /* getbits.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = getbits.cpp; path = libunrar/getbits.cpp; sourceTree = "<group>"; };
|
||||
D4A4959A1054177300BE38AE /* getbits.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; name = getbits.hpp; path = libunrar/getbits.hpp; sourceTree = "<group>"; };
|
||||
D4A4959B1054177300BE38AE /* global.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = global.cpp; path = libunrar/global.cpp; sourceTree = "<group>"; };
|
||||
D4A4959C1054177300BE38AE /* global.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; name = global.hpp; path = libunrar/global.hpp; sourceTree = "<group>"; };
|
||||
D4A4959D1054177300BE38AE /* headers.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; name = headers.hpp; path = libunrar/headers.hpp; sourceTree = "<group>"; };
|
||||
D4A4959E1054177300BE38AE /* isnt.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = isnt.cpp; path = libunrar/isnt.cpp; sourceTree = "<group>"; };
|
||||
D4A4959F1054177300BE38AE /* isnt.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; name = isnt.hpp; path = libunrar/isnt.hpp; sourceTree = "<group>"; };
|
||||
D4A495A01054177300BE38AE /* list.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = list.cpp; path = libunrar/list.cpp; sourceTree = "<group>"; };
|
||||
D4A495A11054177300BE38AE /* list.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; name = list.hpp; path = libunrar/list.hpp; sourceTree = "<group>"; };
|
||||
D4A495A21054177300BE38AE /* loclang.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; name = loclang.hpp; path = libunrar/loclang.hpp; sourceTree = "<group>"; };
|
||||
D4A495A31054177300BE38AE /* log.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = log.cpp; path = libunrar/log.cpp; sourceTree = "<group>"; };
|
||||
D4A495A41054177300BE38AE /* log.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; name = log.hpp; path = libunrar/log.hpp; sourceTree = "<group>"; };
|
||||
D4A495A51054177300BE38AE /* makefile.unix */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; name = makefile.unix; path = libunrar/makefile.unix; sourceTree = "<group>"; };
|
||||
D4A495A61054177300BE38AE /* match.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = match.cpp; path = libunrar/match.cpp; sourceTree = "<group>"; };
|
||||
D4A495A71054177300BE38AE /* match.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; name = match.hpp; path = libunrar/match.hpp; sourceTree = "<group>"; };
|
||||
D4A495A81054177300BE38AE /* model.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = model.cpp; path = libunrar/model.cpp; sourceTree = "<group>"; };
|
||||
D4A495A91054177300BE38AE /* model.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; name = model.hpp; path = libunrar/model.hpp; sourceTree = "<group>"; };
|
||||
D4A495AA1054177300BE38AE /* options.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = options.cpp; path = libunrar/options.cpp; sourceTree = "<group>"; };
|
||||
D4A495AB1054177300BE38AE /* options.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; name = options.hpp; path = libunrar/options.hpp; sourceTree = "<group>"; };
|
||||
D4A495AC1054177300BE38AE /* os.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; name = os.hpp; path = libunrar/os.hpp; sourceTree = "<group>"; };
|
||||
D4A495AD1054177300BE38AE /* os2ea.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = os2ea.cpp; path = libunrar/os2ea.cpp; sourceTree = "<group>"; };
|
||||
D4A495AE1054177300BE38AE /* pathfn.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = pathfn.cpp; path = libunrar/pathfn.cpp; sourceTree = "<group>"; };
|
||||
D4A495AF1054177300BE38AE /* pathfn.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; name = pathfn.hpp; path = libunrar/pathfn.hpp; sourceTree = "<group>"; };
|
||||
D4A495B01054177300BE38AE /* rar.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = rar.cpp; path = libunrar/rar.cpp; sourceTree = "<group>"; };
|
||||
D4A495B11054177300BE38AE /* rar.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; name = rar.hpp; path = libunrar/rar.hpp; sourceTree = "<group>"; };
|
||||
D4A495B21054177300BE38AE /* rardefs.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; name = rardefs.hpp; path = libunrar/rardefs.hpp; sourceTree = "<group>"; };
|
||||
D4A495B31054177300BE38AE /* rarlang.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; name = rarlang.hpp; path = libunrar/rarlang.hpp; sourceTree = "<group>"; };
|
||||
D4A495B41054177300BE38AE /* raros.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; name = raros.hpp; path = libunrar/raros.hpp; sourceTree = "<group>"; };
|
||||
D4A495B51054177300BE38AE /* rartypes.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; name = rartypes.hpp; path = libunrar/rartypes.hpp; sourceTree = "<group>"; };
|
||||
D4A495B61054177300BE38AE /* rarvm.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = rarvm.cpp; path = libunrar/rarvm.cpp; sourceTree = "<group>"; };
|
||||
D4A495B71054177300BE38AE /* rarvm.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; name = rarvm.hpp; path = libunrar/rarvm.hpp; sourceTree = "<group>"; };
|
||||
D4A495B81054177300BE38AE /* rarvmtbl.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = rarvmtbl.cpp; path = libunrar/rarvmtbl.cpp; sourceTree = "<group>"; };
|
||||
D4A495B91054177300BE38AE /* rawread.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = rawread.cpp; path = libunrar/rawread.cpp; sourceTree = "<group>"; };
|
||||
D4A495BA1054177300BE38AE /* rawread.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; name = rawread.hpp; path = libunrar/rawread.hpp; sourceTree = "<group>"; };
|
||||
D4A495BB1054177300BE38AE /* rdwrfn.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = rdwrfn.cpp; path = libunrar/rdwrfn.cpp; sourceTree = "<group>"; };
|
||||
D4A495BC1054177300BE38AE /* rdwrfn.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; name = rdwrfn.hpp; path = libunrar/rdwrfn.hpp; sourceTree = "<group>"; };
|
||||
D4A495BD1054177300BE38AE /* recvol.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = recvol.cpp; path = libunrar/recvol.cpp; sourceTree = "<group>"; };
|
||||
D4A495BE1054177300BE38AE /* recvol.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; name = recvol.hpp; path = libunrar/recvol.hpp; sourceTree = "<group>"; };
|
||||
D4A495BF1054177300BE38AE /* resource.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = resource.cpp; path = libunrar/resource.cpp; sourceTree = "<group>"; };
|
||||
D4A495C01054177300BE38AE /* resource.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; name = resource.hpp; path = libunrar/resource.hpp; sourceTree = "<group>"; };
|
||||
D4A495C11054177300BE38AE /* rijndael.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = rijndael.cpp; path = libunrar/rijndael.cpp; sourceTree = "<group>"; };
|
||||
D4A495C21054177300BE38AE /* rijndael.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; name = rijndael.hpp; path = libunrar/rijndael.hpp; sourceTree = "<group>"; };
|
||||
D4A495C31054177300BE38AE /* rs.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = rs.cpp; path = libunrar/rs.cpp; sourceTree = "<group>"; };
|
||||
D4A495C41054177300BE38AE /* rs.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; name = rs.hpp; path = libunrar/rs.hpp; sourceTree = "<group>"; };
|
||||
D4A495C51054177300BE38AE /* savepos.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = savepos.cpp; path = libunrar/savepos.cpp; sourceTree = "<group>"; };
|
||||
D4A495C61054177300BE38AE /* savepos.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; name = savepos.hpp; path = libunrar/savepos.hpp; sourceTree = "<group>"; };
|
||||
D4A495C71054177300BE38AE /* scantree.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = scantree.cpp; path = libunrar/scantree.cpp; sourceTree = "<group>"; };
|
||||
D4A495C81054177300BE38AE /* scantree.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; name = scantree.hpp; path = libunrar/scantree.hpp; sourceTree = "<group>"; };
|
||||
D4A495C91054177300BE38AE /* sha1.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = sha1.cpp; path = libunrar/sha1.cpp; sourceTree = "<group>"; };
|
||||
D4A495CA1054177300BE38AE /* sha1.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; name = sha1.hpp; path = libunrar/sha1.hpp; sourceTree = "<group>"; };
|
||||
D4A495CB1054177300BE38AE /* smallfn.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = smallfn.cpp; path = libunrar/smallfn.cpp; sourceTree = "<group>"; };
|
||||
D4A495CC1054177300BE38AE /* smallfn.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; name = smallfn.hpp; path = libunrar/smallfn.hpp; sourceTree = "<group>"; };
|
||||
D4A495CD1054177300BE38AE /* strfn.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = strfn.cpp; path = libunrar/strfn.cpp; sourceTree = "<group>"; };
|
||||
D4A495CE1054177300BE38AE /* strfn.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; name = strfn.hpp; path = libunrar/strfn.hpp; sourceTree = "<group>"; };
|
||||
D4A495CF1054177300BE38AE /* strlist.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = strlist.cpp; path = libunrar/strlist.cpp; sourceTree = "<group>"; };
|
||||
D4A495D01054177300BE38AE /* strlist.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; name = strlist.hpp; path = libunrar/strlist.hpp; sourceTree = "<group>"; };
|
||||
D4A495D11054177300BE38AE /* suballoc.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = suballoc.cpp; path = libunrar/suballoc.cpp; sourceTree = "<group>"; };
|
||||
D4A495D21054177300BE38AE /* suballoc.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; name = suballoc.hpp; path = libunrar/suballoc.hpp; sourceTree = "<group>"; };
|
||||
D4A495D31054177300BE38AE /* system.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = system.cpp; path = libunrar/system.cpp; sourceTree = "<group>"; };
|
||||
D4A495D41054177300BE38AE /* system.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; name = system.hpp; path = libunrar/system.hpp; sourceTree = "<group>"; };
|
||||
D4A495D51054177300BE38AE /* timefn.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = timefn.cpp; path = libunrar/timefn.cpp; sourceTree = "<group>"; };
|
||||
D4A495D61054177300BE38AE /* timefn.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; name = timefn.hpp; path = libunrar/timefn.hpp; sourceTree = "<group>"; };
|
||||
D4A495D71054177300BE38AE /* ulinks.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = ulinks.cpp; path = libunrar/ulinks.cpp; sourceTree = "<group>"; };
|
||||
D4A495D81054177300BE38AE /* ulinks.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; name = ulinks.hpp; path = libunrar/ulinks.hpp; sourceTree = "<group>"; };
|
||||
D4A495D91054177300BE38AE /* unicode.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = unicode.cpp; path = libunrar/unicode.cpp; sourceTree = "<group>"; };
|
||||
D4A495DA1054177300BE38AE /* unicode.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; name = unicode.hpp; path = libunrar/unicode.hpp; sourceTree = "<group>"; };
|
||||
D4A495DB1054177300BE38AE /* unios2.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = unios2.cpp; path = libunrar/unios2.cpp; sourceTree = "<group>"; };
|
||||
D4A495DC1054177300BE38AE /* unpack.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = unpack.cpp; path = libunrar/unpack.cpp; sourceTree = "<group>"; };
|
||||
D4A495DD1054177300BE38AE /* unpack.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; name = unpack.hpp; path = libunrar/unpack.hpp; sourceTree = "<group>"; };
|
||||
D4A495DE1054177300BE38AE /* unpack15.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = unpack15.cpp; path = libunrar/unpack15.cpp; sourceTree = "<group>"; };
|
||||
D4A495DF1054177300BE38AE /* unpack20.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = unpack20.cpp; path = libunrar/unpack20.cpp; sourceTree = "<group>"; };
|
||||
D4A495E01054177300BE38AE /* uowners.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = uowners.cpp; path = libunrar/uowners.cpp; sourceTree = "<group>"; };
|
||||
D4A495E11054177300BE38AE /* version.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; name = version.hpp; path = libunrar/version.hpp; sourceTree = "<group>"; };
|
||||
D4A495E21054177300BE38AE /* volume.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = volume.cpp; path = libunrar/volume.cpp; sourceTree = "<group>"; };
|
||||
D4A495E31054177300BE38AE /* volume.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; name = volume.hpp; path = libunrar/volume.hpp; sourceTree = "<group>"; };
|
||||
D4A495E41054177300BE38AE /* win32acl.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = win32acl.cpp; path = libunrar/win32acl.cpp; sourceTree = "<group>"; };
|
||||
D4A495E51054177300BE38AE /* win32stm.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = win32stm.cpp; path = libunrar/win32stm.cpp; sourceTree = "<group>"; };
|
||||
D4A96E2010545E9A0091ECB4 /* Carbon.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Carbon.framework; path = System/Library/Frameworks/Carbon.framework; sourceTree = SDKROOT; };
|
||||
/* End PBXFileReference section */
|
||||
|
||||
/* Begin PBXFrameworksBuildPhase section */
|
||||
8D11072E0486CEB800E47090 /* Frameworks */ = {
|
||||
isa = PBXFrameworksBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
8D11072F0486CEB800E47090 /* Cocoa.framework in Frameworks */,
|
||||
D4A96E2110545E9A0091ECB4 /* Carbon.framework in Frameworks */,
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
/* End PBXFrameworksBuildPhase section */
|
||||
|
||||
/* Begin PBXGroup section */
|
||||
080E96DDFE201D6D7F000001 /* Classes */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
256AC3D80F4B6AC300CF3369 /* QuietUnrarAppDelegate.h */,
|
||||
256AC3D90F4B6AC300CF3369 /* QuietUnrarAppDelegate.m */,
|
||||
);
|
||||
name = Classes;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
1058C7A0FEA54F0111CA2CBB /* Linked Frameworks */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
1058C7A1FEA54F0111CA2CBB /* Cocoa.framework */,
|
||||
);
|
||||
name = "Linked Frameworks";
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
1058C7A2FEA54F0111CA2CBB /* Other Frameworks */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
29B97324FDCFA39411CA2CEA /* AppKit.framework */,
|
||||
13E42FB307B3F0F600E4EEF1 /* CoreData.framework */,
|
||||
29B97325FDCFA39411CA2CEA /* Foundation.framework */,
|
||||
);
|
||||
name = "Other Frameworks";
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
19C28FACFE9D520D11CA2CBB /* Products */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
8D1107320486CEB800E47090 /* QuietUnrar.app */,
|
||||
);
|
||||
name = Products;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
29B97314FDCFA39411CA2CEA /* QuietUnrar */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
080E96DDFE201D6D7F000001 /* Classes */,
|
||||
29B97315FDCFA39411CA2CEA /* Other Sources */,
|
||||
29B97317FDCFA39411CA2CEA /* Resources */,
|
||||
29B97323FDCFA39411CA2CEA /* Frameworks */,
|
||||
19C28FACFE9D520D11CA2CBB /* Products */,
|
||||
D4A96E2010545E9A0091ECB4 /* Carbon.framework */,
|
||||
);
|
||||
name = QuietUnrar;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
29B97315FDCFA39411CA2CEA /* Other Sources */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
D4A494191054167B00BE38AE /* libunrar */,
|
||||
256AC3F00F4B6AF500CF3369 /* QuietUnrar_Prefix.pch */,
|
||||
29B97316FDCFA39411CA2CEA /* main.m */,
|
||||
);
|
||||
name = "Other Sources";
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
29B97317FDCFA39411CA2CEA /* Resources */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
8D1107310486CEB800E47090 /* QuietUnrar-Info.plist */,
|
||||
089C165CFE840E0CC02AAC07 /* InfoPlist.strings */,
|
||||
1DDD58140DA1D0A300B32029 /* MainMenu.xib */,
|
||||
);
|
||||
name = Resources;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
29B97323FDCFA39411CA2CEA /* Frameworks */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
1058C7A0FEA54F0111CA2CBB /* Linked Frameworks */,
|
||||
1058C7A2FEA54F0111CA2CBB /* Other Frameworks */,
|
||||
);
|
||||
name = Frameworks;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
D4A494191054167B00BE38AE /* libunrar */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
D4A495741054177300BE38AE /* arccmt.cpp */,
|
||||
D4A495751054177300BE38AE /* archive.cpp */,
|
||||
D4A495761054177300BE38AE /* archive.hpp */,
|
||||
D4A495771054177300BE38AE /* arcread.cpp */,
|
||||
D4A495781054177300BE38AE /* array.hpp */,
|
||||
D4A495791054177300BE38AE /* beosea.cpp */,
|
||||
D4A4957A1054177300BE38AE /* cmddata.cpp */,
|
||||
D4A4957B1054177300BE38AE /* cmddata.hpp */,
|
||||
D4A4957C1054177300BE38AE /* coder.cpp */,
|
||||
D4A4957D1054177300BE38AE /* coder.hpp */,
|
||||
D4A4957E1054177300BE38AE /* compress.hpp */,
|
||||
D4A4957F1054177300BE38AE /* consio.cpp */,
|
||||
D4A495801054177300BE38AE /* consio.hpp */,
|
||||
D4A495811054177300BE38AE /* crc.cpp */,
|
||||
D4A495821054177300BE38AE /* crc.hpp */,
|
||||
D4A495831054177300BE38AE /* crypt.cpp */,
|
||||
D4A495841054177300BE38AE /* crypt.hpp */,
|
||||
D4A495851054177300BE38AE /* dll.cpp */,
|
||||
D4A495861054177300BE38AE /* dll.hpp */,
|
||||
D4A495871054177300BE38AE /* encname.cpp */,
|
||||
D4A495881054177300BE38AE /* encname.hpp */,
|
||||
D4A495891054177300BE38AE /* errhnd.cpp */,
|
||||
D4A4958A1054177300BE38AE /* errhnd.hpp */,
|
||||
D4A4958B1054177300BE38AE /* extinfo.cpp */,
|
||||
D4A4958C1054177300BE38AE /* extinfo.hpp */,
|
||||
D4A4958D1054177300BE38AE /* extract.cpp */,
|
||||
D4A4958E1054177300BE38AE /* extract.hpp */,
|
||||
D4A4958F1054177300BE38AE /* filcreat.cpp */,
|
||||
D4A495901054177300BE38AE /* filcreat.hpp */,
|
||||
D4A495911054177300BE38AE /* file.cpp */,
|
||||
D4A495921054177300BE38AE /* file.hpp */,
|
||||
D4A495931054177300BE38AE /* filefn.cpp */,
|
||||
D4A495941054177300BE38AE /* filefn.hpp */,
|
||||
D4A495951054177300BE38AE /* filestr.cpp */,
|
||||
D4A495961054177300BE38AE /* filestr.hpp */,
|
||||
D4A495971054177300BE38AE /* find.cpp */,
|
||||
D4A495981054177300BE38AE /* find.hpp */,
|
||||
D4A495991054177300BE38AE /* getbits.cpp */,
|
||||
D4A4959A1054177300BE38AE /* getbits.hpp */,
|
||||
D4A4959B1054177300BE38AE /* global.cpp */,
|
||||
D4A4959C1054177300BE38AE /* global.hpp */,
|
||||
D4A4959D1054177300BE38AE /* headers.hpp */,
|
||||
D4A4959E1054177300BE38AE /* isnt.cpp */,
|
||||
D4A4959F1054177300BE38AE /* isnt.hpp */,
|
||||
D4A495A01054177300BE38AE /* list.cpp */,
|
||||
D4A495A11054177300BE38AE /* list.hpp */,
|
||||
D4A495A21054177300BE38AE /* loclang.hpp */,
|
||||
D4A495A31054177300BE38AE /* log.cpp */,
|
||||
D4A495A41054177300BE38AE /* log.hpp */,
|
||||
D4A495A51054177300BE38AE /* makefile.unix */,
|
||||
D4A495A61054177300BE38AE /* match.cpp */,
|
||||
D4A495A71054177300BE38AE /* match.hpp */,
|
||||
D4A495A81054177300BE38AE /* model.cpp */,
|
||||
D4A495A91054177300BE38AE /* model.hpp */,
|
||||
D4A495AA1054177300BE38AE /* options.cpp */,
|
||||
D4A495AB1054177300BE38AE /* options.hpp */,
|
||||
D4A495AC1054177300BE38AE /* os.hpp */,
|
||||
D4A495AD1054177300BE38AE /* os2ea.cpp */,
|
||||
D4A495AE1054177300BE38AE /* pathfn.cpp */,
|
||||
D4A495AF1054177300BE38AE /* pathfn.hpp */,
|
||||
D4A495B01054177300BE38AE /* rar.cpp */,
|
||||
D4A495B11054177300BE38AE /* rar.hpp */,
|
||||
D4A495B21054177300BE38AE /* rardefs.hpp */,
|
||||
D4A495B31054177300BE38AE /* rarlang.hpp */,
|
||||
D4A495B41054177300BE38AE /* raros.hpp */,
|
||||
D4A495B51054177300BE38AE /* rartypes.hpp */,
|
||||
D4A495B61054177300BE38AE /* rarvm.cpp */,
|
||||
D4A495B71054177300BE38AE /* rarvm.hpp */,
|
||||
D4A495B81054177300BE38AE /* rarvmtbl.cpp */,
|
||||
D4A495B91054177300BE38AE /* rawread.cpp */,
|
||||
D4A495BA1054177300BE38AE /* rawread.hpp */,
|
||||
D4A495BB1054177300BE38AE /* rdwrfn.cpp */,
|
||||
D4A495BC1054177300BE38AE /* rdwrfn.hpp */,
|
||||
D4A495BD1054177300BE38AE /* recvol.cpp */,
|
||||
D4A495BE1054177300BE38AE /* recvol.hpp */,
|
||||
D4A495BF1054177300BE38AE /* resource.cpp */,
|
||||
D4A495C01054177300BE38AE /* resource.hpp */,
|
||||
D4A495C11054177300BE38AE /* rijndael.cpp */,
|
||||
D4A495C21054177300BE38AE /* rijndael.hpp */,
|
||||
D4A495C31054177300BE38AE /* rs.cpp */,
|
||||
D4A495C41054177300BE38AE /* rs.hpp */,
|
||||
D4A495C51054177300BE38AE /* savepos.cpp */,
|
||||
D4A495C61054177300BE38AE /* savepos.hpp */,
|
||||
D4A495C71054177300BE38AE /* scantree.cpp */,
|
||||
D4A495C81054177300BE38AE /* scantree.hpp */,
|
||||
D4A495C91054177300BE38AE /* sha1.cpp */,
|
||||
D4A495CA1054177300BE38AE /* sha1.hpp */,
|
||||
D4A495CB1054177300BE38AE /* smallfn.cpp */,
|
||||
D4A495CC1054177300BE38AE /* smallfn.hpp */,
|
||||
D4A495CD1054177300BE38AE /* strfn.cpp */,
|
||||
D4A495CE1054177300BE38AE /* strfn.hpp */,
|
||||
D4A495CF1054177300BE38AE /* strlist.cpp */,
|
||||
D4A495D01054177300BE38AE /* strlist.hpp */,
|
||||
D4A495D11054177300BE38AE /* suballoc.cpp */,
|
||||
D4A495D21054177300BE38AE /* suballoc.hpp */,
|
||||
D4A495D31054177300BE38AE /* system.cpp */,
|
||||
D4A495D41054177300BE38AE /* system.hpp */,
|
||||
D4A495D51054177300BE38AE /* timefn.cpp */,
|
||||
D4A495D61054177300BE38AE /* timefn.hpp */,
|
||||
D4A495D71054177300BE38AE /* ulinks.cpp */,
|
||||
D4A495D81054177300BE38AE /* ulinks.hpp */,
|
||||
D4A495D91054177300BE38AE /* unicode.cpp */,
|
||||
D4A495DA1054177300BE38AE /* unicode.hpp */,
|
||||
D4A495DB1054177300BE38AE /* unios2.cpp */,
|
||||
D4A495DC1054177300BE38AE /* unpack.cpp */,
|
||||
D4A495DD1054177300BE38AE /* unpack.hpp */,
|
||||
D4A495DE1054177300BE38AE /* unpack15.cpp */,
|
||||
D4A495DF1054177300BE38AE /* unpack20.cpp */,
|
||||
D4A495E01054177300BE38AE /* uowners.cpp */,
|
||||
D4A495E11054177300BE38AE /* version.hpp */,
|
||||
D4A495E21054177300BE38AE /* volume.cpp */,
|
||||
D4A495E31054177300BE38AE /* volume.hpp */,
|
||||
D4A495E41054177300BE38AE /* win32acl.cpp */,
|
||||
D4A495E51054177300BE38AE /* win32stm.cpp */,
|
||||
);
|
||||
name = libunrar;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
/* End PBXGroup section */
|
||||
|
||||
/* Begin PBXLegacyTarget section */
|
||||
D4A4962A105419AA00BE38AE /* libunrar */ = {
|
||||
isa = PBXLegacyTarget;
|
||||
buildArgumentsString = "-f makefile.unix lib $(ACTION)";
|
||||
buildConfigurationList = D4A4962D105419C800BE38AE /* Build configuration list for PBXLegacyTarget "libunrar" */;
|
||||
buildPhases = (
|
||||
);
|
||||
buildToolPath = /usr/bin/make;
|
||||
buildWorkingDirectory = ./libunrar/;
|
||||
dependencies = (
|
||||
);
|
||||
name = libunrar;
|
||||
passBuildSettingsInEnvironment = 1;
|
||||
productName = libunrar;
|
||||
};
|
||||
/* End PBXLegacyTarget section */
|
||||
|
||||
/* Begin PBXNativeTarget section */
|
||||
8D1107260486CEB800E47090 /* QuietUnrar */ = {
|
||||
isa = PBXNativeTarget;
|
||||
buildConfigurationList = C01FCF4A08A954540054247B /* Build configuration list for PBXNativeTarget "QuietUnrar" */;
|
||||
buildPhases = (
|
||||
8D11072C0486CEB800E47090 /* Sources */,
|
||||
8D11072E0486CEB800E47090 /* Frameworks */,
|
||||
D4A4965210541D2600BE38AE /* CopyFiles */,
|
||||
D4A49697105435C700BE38AE /* Resources */,
|
||||
);
|
||||
buildRules = (
|
||||
);
|
||||
dependencies = (
|
||||
D4A4964D10541CFF00BE38AE /* PBXTargetDependency */,
|
||||
);
|
||||
name = QuietUnrar;
|
||||
productInstallPath = "$(HOME)/Applications";
|
||||
productName = QuietUnrar;
|
||||
productReference = 8D1107320486CEB800E47090 /* QuietUnrar.app */;
|
||||
productType = "com.apple.product-type.application";
|
||||
};
|
||||
/* End PBXNativeTarget section */
|
||||
|
||||
/* Begin PBXProject section */
|
||||
29B97313FDCFA39411CA2CEA /* Project object */ = {
|
||||
isa = PBXProject;
|
||||
buildConfigurationList = C01FCF4E08A954540054247B /* Build configuration list for PBXProject "QuietUnrar" */;
|
||||
compatibilityVersion = "Xcode 3.2";
|
||||
hasScannedForEncodings = 1;
|
||||
mainGroup = 29B97314FDCFA39411CA2CEA /* QuietUnrar */;
|
||||
projectDirPath = "";
|
||||
projectRoot = "";
|
||||
targets = (
|
||||
8D1107260486CEB800E47090 /* QuietUnrar */,
|
||||
D4A4962A105419AA00BE38AE /* libunrar */,
|
||||
);
|
||||
};
|
||||
/* End PBXProject section */
|
||||
|
||||
/* Begin PBXResourcesBuildPhase section */
|
||||
D4A49697105435C700BE38AE /* Resources */ = {
|
||||
isa = PBXResourcesBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
D4A49692105435C100BE38AE /* MainMenu.xib in Resources */,
|
||||
D4A49691105435BE00BE38AE /* InfoPlist.strings in Resources */,
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
/* End PBXResourcesBuildPhase section */
|
||||
|
||||
/* Begin PBXSourcesBuildPhase section */
|
||||
8D11072C0486CEB800E47090 /* Sources */ = {
|
||||
isa = PBXSourcesBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
8D11072D0486CEB800E47090 /* main.m in Sources */,
|
||||
256AC3DA0F4B6AC300CF3369 /* QuietUnrarAppDelegate.m in Sources */,
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
/* End PBXSourcesBuildPhase section */
|
||||
|
||||
/* Begin PBXTargetDependency section */
|
||||
D4A4964D10541CFF00BE38AE /* PBXTargetDependency */ = {
|
||||
isa = PBXTargetDependency;
|
||||
target = D4A4962A105419AA00BE38AE /* libunrar */;
|
||||
targetProxy = D4A4964C10541CFF00BE38AE /* PBXContainerItemProxy */;
|
||||
};
|
||||
/* End PBXTargetDependency section */
|
||||
|
||||
/* Begin PBXVariantGroup section */
|
||||
089C165CFE840E0CC02AAC07 /* InfoPlist.strings */ = {
|
||||
isa = PBXVariantGroup;
|
||||
children = (
|
||||
089C165DFE840E0CC02AAC07 /* English */,
|
||||
);
|
||||
name = InfoPlist.strings;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
1DDD58140DA1D0A300B32029 /* MainMenu.xib */ = {
|
||||
isa = PBXVariantGroup;
|
||||
children = (
|
||||
1DDD58150DA1D0A300B32029 /* English */,
|
||||
);
|
||||
name = MainMenu.xib;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
/* End PBXVariantGroup section */
|
||||
|
||||
/* Begin XCBuildConfiguration section */
|
||||
C01FCF4B08A954540054247B /* Debug */ = {
|
||||
isa = XCBuildConfiguration;
|
||||
buildSettings = {
|
||||
ALWAYS_SEARCH_USER_PATHS = NO;
|
||||
COPY_PHASE_STRIP = NO;
|
||||
GCC_DYNAMIC_NO_PIC = NO;
|
||||
GCC_ENABLE_FIX_AND_CONTINUE = YES;
|
||||
GCC_MODEL_TUNING = G5;
|
||||
GCC_OPTIMIZATION_LEVEL = 0;
|
||||
GCC_PRECOMPILE_PREFIX_HEADER = YES;
|
||||
GCC_PREFIX_HEADER = QuietUnrar_Prefix.pch;
|
||||
GCC_PREPROCESSOR_DEFINITIONS = _UNIX;
|
||||
INFOPLIST_FILE = "QuietUnrar-Info.plist";
|
||||
INSTALL_PATH = "$(HOME)/Applications";
|
||||
PRODUCT_NAME = QuietUnrar;
|
||||
};
|
||||
name = Debug;
|
||||
};
|
||||
C01FCF4C08A954540054247B /* Release */ = {
|
||||
isa = XCBuildConfiguration;
|
||||
buildSettings = {
|
||||
ALWAYS_SEARCH_USER_PATHS = NO;
|
||||
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
|
||||
GCC_MODEL_TUNING = G5;
|
||||
GCC_PRECOMPILE_PREFIX_HEADER = YES;
|
||||
GCC_PREFIX_HEADER = QuietUnrar_Prefix.pch;
|
||||
GCC_PREPROCESSOR_DEFINITIONS = _UNIX;
|
||||
INFOPLIST_FILE = "QuietUnrar-Info.plist";
|
||||
INSTALL_PATH = "$(HOME)/Applications";
|
||||
PRODUCT_NAME = QuietUnrar;
|
||||
};
|
||||
name = Release;
|
||||
};
|
||||
C01FCF4F08A954540054247B /* Debug */ = {
|
||||
isa = XCBuildConfiguration;
|
||||
buildSettings = {
|
||||
ARCHS = "$(ARCHS_STANDARD_32_64_BIT)";
|
||||
GCC_C_LANGUAGE_STANDARD = gnu99;
|
||||
GCC_ENABLE_OBJC_GC = required;
|
||||
GCC_OPTIMIZATION_LEVEL = 0;
|
||||
GCC_VERSION = com.apple.compilers.llvm.clang.1_0;
|
||||
GCC_WARN_ABOUT_RETURN_TYPE = YES;
|
||||
GCC_WARN_UNUSED_VARIABLE = YES;
|
||||
ONLY_ACTIVE_ARCH = YES;
|
||||
PREBINDING = NO;
|
||||
SDKROOT = macosx10.6;
|
||||
VALID_ARCHS = "i386 x86_64";
|
||||
};
|
||||
name = Debug;
|
||||
};
|
||||
C01FCF5008A954540054247B /* Release */ = {
|
||||
isa = XCBuildConfiguration;
|
||||
buildSettings = {
|
||||
ARCHS = "$(ARCHS_STANDARD_32_64_BIT)";
|
||||
GCC_C_LANGUAGE_STANDARD = gnu99;
|
||||
GCC_ENABLE_OBJC_GC = required;
|
||||
GCC_VERSION = com.apple.compilers.llvm.clang.1_0;
|
||||
GCC_WARN_ABOUT_RETURN_TYPE = YES;
|
||||
GCC_WARN_UNUSED_VARIABLE = YES;
|
||||
PREBINDING = NO;
|
||||
SDKROOT = macosx10.6;
|
||||
VALID_ARCHS = "i386 x86_64";
|
||||
};
|
||||
name = Release;
|
||||
};
|
||||
D4A4962B105419AA00BE38AE /* Debug */ = {
|
||||
isa = XCBuildConfiguration;
|
||||
buildSettings = {
|
||||
COPY_PHASE_STRIP = NO;
|
||||
GCC_DYNAMIC_NO_PIC = NO;
|
||||
GCC_OPTIMIZATION_LEVEL = 0;
|
||||
PRODUCT_NAME = libunrar;
|
||||
};
|
||||
name = Debug;
|
||||
};
|
||||
D4A4962C105419AA00BE38AE /* Release */ = {
|
||||
isa = XCBuildConfiguration;
|
||||
buildSettings = {
|
||||
COPY_PHASE_STRIP = YES;
|
||||
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
|
||||
GCC_ENABLE_FIX_AND_CONTINUE = NO;
|
||||
PRODUCT_NAME = libunrar;
|
||||
ZERO_LINK = NO;
|
||||
};
|
||||
name = Release;
|
||||
};
|
||||
/* End XCBuildConfiguration section */
|
||||
|
||||
/* Begin XCConfigurationList section */
|
||||
C01FCF4A08A954540054247B /* Build configuration list for PBXNativeTarget "QuietUnrar" */ = {
|
||||
isa = XCConfigurationList;
|
||||
buildConfigurations = (
|
||||
C01FCF4B08A954540054247B /* Debug */,
|
||||
C01FCF4C08A954540054247B /* Release */,
|
||||
);
|
||||
defaultConfigurationIsVisible = 0;
|
||||
defaultConfigurationName = Release;
|
||||
};
|
||||
C01FCF4E08A954540054247B /* Build configuration list for PBXProject "QuietUnrar" */ = {
|
||||
isa = XCConfigurationList;
|
||||
buildConfigurations = (
|
||||
C01FCF4F08A954540054247B /* Debug */,
|
||||
C01FCF5008A954540054247B /* Release */,
|
||||
);
|
||||
defaultConfigurationIsVisible = 0;
|
||||
defaultConfigurationName = Release;
|
||||
};
|
||||
D4A4962D105419C800BE38AE /* Build configuration list for PBXLegacyTarget "libunrar" */ = {
|
||||
isa = XCConfigurationList;
|
||||
buildConfigurations = (
|
||||
D4A4962B105419AA00BE38AE /* Debug */,
|
||||
D4A4962C105419AA00BE38AE /* Release */,
|
||||
);
|
||||
defaultConfigurationIsVisible = 0;
|
||||
defaultConfigurationName = Release;
|
||||
};
|
||||
/* End XCConfigurationList section */
|
||||
};
|
||||
rootObject = 29B97313FDCFA39411CA2CEA /* Project object */;
|
||||
}
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,346 @@
|
|||
// !$*UTF8*$!
|
||||
{
|
||||
089C165DFE840E0CC02AAC07 /* English */ = {
|
||||
uiCtxt = {
|
||||
sepNavIntBoundsRect = "{{0, 0}, {703, 404}}";
|
||||
sepNavSelRange = "{0, 0}";
|
||||
sepNavVisRange = "{0, 45}";
|
||||
};
|
||||
};
|
||||
256AC3D80F4B6AC300CF3369 /* QuietUnrarAppDelegate.h */ = {
|
||||
uiCtxt = {
|
||||
sepNavIntBoundsRect = "{{0, 0}, {670, 403}}";
|
||||
sepNavSelRange = "{469, 0}";
|
||||
sepNavVisRange = "{180, 436}";
|
||||
};
|
||||
};
|
||||
256AC3D90F4B6AC300CF3369 /* QuietUnrarAppDelegate.m */ = {
|
||||
uiCtxt = {
|
||||
sepNavIntBoundsRect = "{{0, 0}, {740, 572}}";
|
||||
sepNavSelRange = "{720, 0}";
|
||||
sepNavVisRange = "{295, 827}";
|
||||
sepNavWindowFrame = "{{85, 21}, {877, 731}}";
|
||||
};
|
||||
};
|
||||
29B97313FDCFA39411CA2CEA /* Project object */ = {
|
||||
activeBuildConfigurationName = Debug;
|
||||
activeExecutable = D4A4940C1054167200BE38AE /* QuietUnrar */;
|
||||
activeTarget = 8D1107260486CEB800E47090 /* QuietUnrar */;
|
||||
addToTargets = (
|
||||
8D1107260486CEB800E47090 /* QuietUnrar */,
|
||||
);
|
||||
codeSenseManager = D4A4941B1054167B00BE38AE /* Code sense */;
|
||||
executables = (
|
||||
D4A4940C1054167200BE38AE /* QuietUnrar */,
|
||||
);
|
||||
perUserDictionary = {
|
||||
PBXConfiguration.PBXFileTableDataSource3.PBXExecutablesDataSource = {
|
||||
PBXFileTableDataSourceColumnSortingDirectionKey = "-1";
|
||||
PBXFileTableDataSourceColumnSortingKey = PBXExecutablesDataSource_NameID;
|
||||
PBXFileTableDataSourceColumnWidthsKey = (
|
||||
22,
|
||||
300,
|
||||
413,
|
||||
);
|
||||
PBXFileTableDataSourceColumnsKey = (
|
||||
PBXExecutablesDataSource_ActiveFlagID,
|
||||
PBXExecutablesDataSource_NameID,
|
||||
PBXExecutablesDataSource_CommentsID,
|
||||
);
|
||||
};
|
||||
PBXConfiguration.PBXFileTableDataSource3.PBXFileTableDataSource = {
|
||||
PBXFileTableDataSourceColumnSortingDirectionKey = "-1";
|
||||
PBXFileTableDataSourceColumnSortingKey = PBXFileDataSource_Filename_ColumnID;
|
||||
PBXFileTableDataSourceColumnWidthsKey = (
|
||||
20,
|
||||
525,
|
||||
20,
|
||||
48,
|
||||
43,
|
||||
43,
|
||||
20,
|
||||
);
|
||||
PBXFileTableDataSourceColumnsKey = (
|
||||
PBXFileDataSource_FiletypeID,
|
||||
PBXFileDataSource_Filename_ColumnID,
|
||||
PBXFileDataSource_Built_ColumnID,
|
||||
PBXFileDataSource_ObjectSize_ColumnID,
|
||||
PBXFileDataSource_Errors_ColumnID,
|
||||
PBXFileDataSource_Warnings_ColumnID,
|
||||
PBXFileDataSource_Target_ColumnID,
|
||||
);
|
||||
};
|
||||
PBXConfiguration.PBXTargetDataSource.PBXTargetDataSource = {
|
||||
PBXFileTableDataSourceColumnSortingDirectionKey = "-1";
|
||||
PBXFileTableDataSourceColumnSortingKey = PBXFileDataSource_Filename_ColumnID;
|
||||
PBXFileTableDataSourceColumnWidthsKey = (
|
||||
20,
|
||||
485,
|
||||
60,
|
||||
20,
|
||||
48,
|
||||
43,
|
||||
43,
|
||||
);
|
||||
PBXFileTableDataSourceColumnsKey = (
|
||||
PBXFileDataSource_FiletypeID,
|
||||
PBXFileDataSource_Filename_ColumnID,
|
||||
PBXTargetDataSource_PrimaryAttribute,
|
||||
PBXFileDataSource_Built_ColumnID,
|
||||
PBXFileDataSource_ObjectSize_ColumnID,
|
||||
PBXFileDataSource_Errors_ColumnID,
|
||||
PBXFileDataSource_Warnings_ColumnID,
|
||||
);
|
||||
};
|
||||
PBXPerProjectTemplateStateSaveDate = 279557910;
|
||||
PBXWorkspaceStateSaveDate = 279557910;
|
||||
};
|
||||
perUserProjectItems = {
|
||||
D40FFE1C105828A50070BCAF = D40FFE1C105828A50070BCAF /* PBXTextBookmark */;
|
||||
D40FFE1F105828A50070BCAF = D40FFE1F105828A50070BCAF /* PBXTextBookmark */;
|
||||
D40FFE21105828A50070BCAF = D40FFE21105828A50070BCAF /* PBXTextBookmark */;
|
||||
D4A4963610541A1C00BE38AE = D4A4963610541A1C00BE38AE /* PBXTextBookmark */;
|
||||
D4A4965D105433E000BE38AE = D4A4965D105433E000BE38AE /* PBXTargetBookmark */;
|
||||
D4A496731054350F00BE38AE = D4A496731054350F00BE38AE /* PBXTextBookmark */;
|
||||
D4A96E4C1054628D0091ECB4 = D4A96E4C1054628D0091ECB4 /* PBXTextBookmark */;
|
||||
D4A96E4D1054628D0091ECB4 = D4A96E4D1054628D0091ECB4 /* PBXTextBookmark */;
|
||||
D4A96E4E1054628D0091ECB4 = D4A96E4E1054628D0091ECB4 /* PBXTextBookmark */;
|
||||
D4A96E4F1054628D0091ECB4 = D4A96E4F1054628D0091ECB4 /* PBXTextBookmark */;
|
||||
D4A96E511054628D0091ECB4 = D4A96E511054628D0091ECB4 /* PBXTextBookmark */;
|
||||
D4C9D7E810A9B7A20005973D /* PBXTextBookmark */ = D4C9D7E810A9B7A20005973D /* PBXTextBookmark */;
|
||||
D4C9D7EB10A9B7A20005973D /* PBXTextBookmark */ = D4C9D7EB10A9B7A20005973D /* PBXTextBookmark */;
|
||||
};
|
||||
sourceControlManager = D4A4941A1054167B00BE38AE /* Source Control */;
|
||||
userBuildSettings = {
|
||||
};
|
||||
};
|
||||
29B97316FDCFA39411CA2CEA /* main.m */ = {
|
||||
uiCtxt = {
|
||||
sepNavIntBoundsRect = "{{0, 0}, {633, 195}}";
|
||||
sepNavSelRange = "{191, 0}";
|
||||
sepNavVisRange = "{29, 213}";
|
||||
};
|
||||
};
|
||||
8D1107260486CEB800E47090 /* QuietUnrar */ = {
|
||||
activeExec = 0;
|
||||
executables = (
|
||||
D4A4940C1054167200BE38AE /* QuietUnrar */,
|
||||
);
|
||||
};
|
||||
8D1107310486CEB800E47090 /* QuietUnrar-Info.plist */ = {
|
||||
uiCtxt = {
|
||||
sepNavWindowFrame = "{{53, 47}, {877, 731}}";
|
||||
};
|
||||
};
|
||||
D40FFE1C105828A50070BCAF /* PBXTextBookmark */ = {
|
||||
isa = PBXTextBookmark;
|
||||
fRef = 256AC3D90F4B6AC300CF3369 /* QuietUnrarAppDelegate.m */;
|
||||
name = "QuietUnrarAppDelegate.m: 29";
|
||||
rLen = 0;
|
||||
rLoc = 720;
|
||||
rType = 0;
|
||||
vrLen = 882;
|
||||
vrLoc = 235;
|
||||
};
|
||||
D40FFE1F105828A50070BCAF /* PBXTextBookmark */ = {
|
||||
isa = PBXTextBookmark;
|
||||
fRef = D40FFE20105828A50070BCAF /* NSApplication.h */;
|
||||
rLen = 1;
|
||||
rLoc = 85;
|
||||
rType = 1;
|
||||
};
|
||||
D40FFE20105828A50070BCAF /* NSApplication.h */ = {
|
||||
isa = PBXFileReference;
|
||||
lastKnownFileType = sourcecode.c.h;
|
||||
name = NSApplication.h;
|
||||
path = /Developer/SDKs/MacOSX10.6.sdk/System/Library/Frameworks/AppKit.framework/Versions/C/Headers/NSApplication.h;
|
||||
sourceTree = "<absolute>";
|
||||
uiCtxt = {
|
||||
sepNavIntBoundsRect = "{{0, 0}, {3652, 5811}}";
|
||||
sepNavSelRange = "{3400, 68}";
|
||||
sepNavVisRange = "{13091, 2293}";
|
||||
};
|
||||
};
|
||||
D40FFE21105828A50070BCAF /* PBXTextBookmark */ = {
|
||||
isa = PBXTextBookmark;
|
||||
fRef = D40FFE22105828A50070BCAF /* NSApplication.h */;
|
||||
name = "NSApplication.h: 86";
|
||||
rLen = 68;
|
||||
rLoc = 3400;
|
||||
rType = 0;
|
||||
vrLen = 2333;
|
||||
vrLoc = 13122;
|
||||
};
|
||||
D40FFE22105828A50070BCAF /* NSApplication.h */ = {
|
||||
isa = PBXFileReference;
|
||||
lastKnownFileType = sourcecode.c.h;
|
||||
name = NSApplication.h;
|
||||
path = /Developer/SDKs/MacOSX10.6.sdk/System/Library/Frameworks/AppKit.framework/Versions/C/Headers/NSApplication.h;
|
||||
sourceTree = "<absolute>";
|
||||
};
|
||||
D4A4940C1054167200BE38AE /* QuietUnrar */ = {
|
||||
isa = PBXExecutable;
|
||||
activeArgIndices = (
|
||||
);
|
||||
argumentStrings = (
|
||||
);
|
||||
autoAttachOnCrash = 1;
|
||||
breakpointsEnabled = 0;
|
||||
configStateDict = {
|
||||
};
|
||||
customDataFormattersEnabled = 1;
|
||||
dataTipCustomDataFormattersEnabled = 1;
|
||||
dataTipShowTypeColumn = 1;
|
||||
dataTipSortType = 0;
|
||||
debuggerPlugin = GDBDebugging;
|
||||
disassemblyDisplayState = 0;
|
||||
dylibVariantSuffix = "";
|
||||
enableDebugStr = 1;
|
||||
environmentEntries = (
|
||||
);
|
||||
executableSystemSymbolLevel = 0;
|
||||
executableUserSymbolLevel = 0;
|
||||
libgmallocEnabled = 0;
|
||||
name = QuietUnrar;
|
||||
savedGlobals = {
|
||||
};
|
||||
showTypeColumn = 0;
|
||||
sourceDirectories = (
|
||||
);
|
||||
startupPath = "<<ProjectDirectory>>";
|
||||
variableFormatDictionary = {
|
||||
};
|
||||
};
|
||||
D4A4941A1054167B00BE38AE /* Source Control */ = {
|
||||
isa = PBXSourceControlManager;
|
||||
fallbackIsa = XCSourceControlManager;
|
||||
isSCMEnabled = 0;
|
||||
scmConfiguration = {
|
||||
repositoryNamesForRoots = {
|
||||
"" = "";
|
||||
};
|
||||
};
|
||||
};
|
||||
D4A4941B1054167B00BE38AE /* Code sense */ = {
|
||||
isa = PBXCodeSenseManager;
|
||||
indexTemplatePath = "";
|
||||
};
|
||||
D4A495741054177300BE38AE /* arccmt.cpp */ = {
|
||||
uiCtxt = {
|
||||
sepNavIntBoundsRect = "{{0, 0}, {703, 2847}}";
|
||||
sepNavSelRange = "{386, 0}";
|
||||
sepNavVisRange = "{70, 690}";
|
||||
};
|
||||
};
|
||||
D4A4957F1054177300BE38AE /* consio.cpp */ = {
|
||||
uiCtxt = {
|
||||
sepNavIntBoundsRect = "{{0, 0}, {703, 3718}}";
|
||||
sepNavSelRange = "{3913, 14}";
|
||||
sepNavVisRange = "{3683, 678}";
|
||||
};
|
||||
};
|
||||
D4A495861054177300BE38AE /* dll.hpp */ = {
|
||||
uiCtxt = {
|
||||
sepNavIntBoundsRect = "{{0, 0}, {616, 1950}}";
|
||||
sepNavSelRange = "{2499, 0}";
|
||||
sepNavVisRange = "{2236, 490}";
|
||||
};
|
||||
};
|
||||
D4A4962A105419AA00BE38AE /* libunrar */ = {
|
||||
activeExec = 0;
|
||||
};
|
||||
D4A4963610541A1C00BE38AE /* PBXTextBookmark */ = {
|
||||
isa = PBXTextBookmark;
|
||||
fRef = D4A495741054177300BE38AE /* arccmt.cpp */;
|
||||
name = "arccmt.cpp: 20";
|
||||
rLen = 0;
|
||||
rLoc = 386;
|
||||
rType = 0;
|
||||
vrLen = 690;
|
||||
vrLoc = 70;
|
||||
};
|
||||
D4A4965D105433E000BE38AE /* PBXTargetBookmark */ = {
|
||||
isa = PBXTargetBookmark;
|
||||
trg = D4A4962A105419AA00BE38AE /* libunrar */;
|
||||
};
|
||||
D4A496731054350F00BE38AE /* PBXTextBookmark */ = {
|
||||
isa = PBXTextBookmark;
|
||||
fRef = D4A495861054177300BE38AE /* dll.hpp */;
|
||||
name = "dll.hpp: 12";
|
||||
rLen = 0;
|
||||
rLoc = 337;
|
||||
rType = 0;
|
||||
vrLen = 828;
|
||||
vrLoc = 0;
|
||||
};
|
||||
D4A96E4C1054628D0091ECB4 /* PBXTextBookmark */ = {
|
||||
isa = PBXTextBookmark;
|
||||
fRef = 089C165DFE840E0CC02AAC07 /* English */;
|
||||
name = "InfoPlist.strings: 1";
|
||||
rLen = 0;
|
||||
rLoc = 0;
|
||||
rType = 0;
|
||||
vrLen = 45;
|
||||
vrLoc = 0;
|
||||
};
|
||||
D4A96E4D1054628D0091ECB4 /* PBXTextBookmark */ = {
|
||||
isa = PBXTextBookmark;
|
||||
fRef = 29B97316FDCFA39411CA2CEA /* main.m */;
|
||||
name = "main.m: 1";
|
||||
rLen = 0;
|
||||
rLoc = 0;
|
||||
rType = 0;
|
||||
vrLen = 252;
|
||||
vrLoc = 0;
|
||||
};
|
||||
D4A96E4E1054628D0091ECB4 /* PBXTextBookmark */ = {
|
||||
isa = PBXTextBookmark;
|
||||
fRef = D4A4957F1054177300BE38AE /* consio.cpp */;
|
||||
name = "consio.cpp: 184";
|
||||
rLen = 14;
|
||||
rLoc = 3913;
|
||||
rType = 0;
|
||||
vrLen = 678;
|
||||
vrLoc = 3683;
|
||||
};
|
||||
D4A96E4F1054628D0091ECB4 /* PBXTextBookmark */ = {
|
||||
isa = PBXTextBookmark;
|
||||
fRef = 256AC3D80F4B6AC300CF3369 /* QuietUnrarAppDelegate.h */;
|
||||
name = "QuietUnrarAppDelegate.h: 20";
|
||||
rLen = 0;
|
||||
rLoc = 371;
|
||||
rType = 0;
|
||||
vrLen = 616;
|
||||
vrLoc = 0;
|
||||
};
|
||||
D4A96E511054628D0091ECB4 /* PBXTextBookmark */ = {
|
||||
isa = PBXTextBookmark;
|
||||
fRef = 256AC3D90F4B6AC300CF3369 /* QuietUnrarAppDelegate.m */;
|
||||
name = "QuietUnrarAppDelegate.m: 11";
|
||||
rLen = 0;
|
||||
rLoc = 230;
|
||||
rType = 0;
|
||||
vrLen = 863;
|
||||
vrLoc = 0;
|
||||
};
|
||||
D4C9D7E810A9B7A20005973D /* PBXTextBookmark */ = {
|
||||
isa = PBXTextBookmark;
|
||||
fRef = 256AC3D90F4B6AC300CF3369 /* QuietUnrarAppDelegate.m */;
|
||||
name = "QuietUnrarAppDelegate.m: 29";
|
||||
rLen = 0;
|
||||
rLoc = 720;
|
||||
rType = 0;
|
||||
vrLen = 827;
|
||||
vrLoc = 295;
|
||||
};
|
||||
D4C9D7EB10A9B7A20005973D /* PBXTextBookmark */ = {
|
||||
isa = PBXTextBookmark;
|
||||
fRef = D40FFE20105828A50070BCAF /* NSApplication.h */;
|
||||
name = "NSApplication.h: 86";
|
||||
rLen = 68;
|
||||
rLoc = 3400;
|
||||
rType = 0;
|
||||
vrLen = 2293;
|
||||
vrLoc = 13091;
|
||||
};
|
||||
}
|
|
@ -0,0 +1,30 @@
|
|||
//
|
||||
// QuietUnrarAppDelegate.h
|
||||
// QuietUnrar
|
||||
//
|
||||
// Created by Robert McGovern on 2009/09/06.
|
||||
// Copyright 2009 Tarasis. All rights reserved.
|
||||
//
|
||||
|
||||
#import <Cocoa/Cocoa.h>
|
||||
|
||||
enum
|
||||
{
|
||||
kVKC_Shift = 56,
|
||||
kVKC_Option = 58,
|
||||
kVKC_Control = 59,
|
||||
kVKC_rShift = 60, /* Right-hand modifiers; not implemented */
|
||||
kVKC_rOption = 61,
|
||||
kVKC_rControl = 62,
|
||||
kVKC_Command = 55,
|
||||
};
|
||||
|
||||
#define KEYMAP_GET(m, index) ((((uint8_t*)(m))[(index) >> 3] & (1L << ((index) & 7))) ? 1 : 0)
|
||||
|
||||
@interface QuietUnrarAppDelegate : NSObject <NSApplicationDelegate> {
|
||||
NSWindow *window;
|
||||
}
|
||||
|
||||
@property (assign) IBOutlet NSWindow *window;
|
||||
|
||||
@end
|
|
@ -0,0 +1,43 @@
|
|||
//
|
||||
// QuietUnrarAppDelegate.m
|
||||
// QuietUnrar
|
||||
//
|
||||
// Created by Robert McGovern on 2009/09/06.
|
||||
// Copyright 2009 Tarasis. All rights reserved.
|
||||
//
|
||||
|
||||
#import <Carbon/Carbon.h>
|
||||
#import "QuietUnrarAppDelegate.h"
|
||||
#import "libunrar/dll.hpp"
|
||||
|
||||
@implementation QuietUnrarAppDelegate
|
||||
|
||||
@synthesize window;
|
||||
|
||||
- (void)applicationDidFinishLaunching:(NSNotification *)aNotification {
|
||||
// Insert code here to initialize your application
|
||||
KeyMap map;
|
||||
GetKeys(map);
|
||||
NSLog(@"Shift or Right Shift: %d", KEYMAP_GET(map, kVKC_Shift) || KEYMAP_GET(map, kVKC_rShift));
|
||||
}
|
||||
|
||||
- (BOOL)application:(id)sender openFileWithoutUI:(NSString *)filename {
|
||||
NSLog(@"openFileWithoutUI with file: %@", filename);
|
||||
return YES;
|
||||
}
|
||||
|
||||
- (BOOL)application:(NSApplication *)theApplication openFile:(NSString *)filename {
|
||||
NSLog(@"openFile: %@", filename);
|
||||
return YES;
|
||||
}
|
||||
|
||||
//- (void)application:(NSApplication *)sender openFiles:(NSArray *)filenames {
|
||||
// for (NSString * filename in filenames) {
|
||||
// NSLog(@"openFiles: %@", filename);
|
||||
// }
|
||||
//
|
||||
// // If we get passed files don't open the UI
|
||||
// [sender replyToOpenOrPrint:NSApplicationDelegateReplySuccess];
|
||||
//}
|
||||
|
||||
@end
|
|
@ -0,0 +1,7 @@
|
|||
//
|
||||
// Prefix header for all source files of the 'QuietUnrar' target in the 'QuietUnrar' project
|
||||
//
|
||||
|
||||
#ifdef __OBJC__
|
||||
#import <Cocoa/Cocoa.h>
|
||||
#endif
|
Binary file not shown.
|
@ -0,0 +1,217 @@
|
|||
bool Archive::GetComment(Array<byte> *CmtData,Array<wchar> *CmtDataW)
|
||||
{
|
||||
if (!MainComment)
|
||||
return(false);
|
||||
SaveFilePos SavePos(*this);
|
||||
|
||||
#ifndef SFX_MODULE
|
||||
ushort CmtLength;
|
||||
if (OldFormat)
|
||||
{
|
||||
Seek(SFXSize+SIZEOF_OLDMHD,SEEK_SET);
|
||||
CmtLength=GetByte();
|
||||
CmtLength+=(GetByte()<<8);
|
||||
}
|
||||
else
|
||||
#endif
|
||||
{
|
||||
if (NewMhd.Flags & MHD_COMMENT)
|
||||
{
|
||||
Seek(SFXSize+SIZEOF_MARKHEAD+SIZEOF_NEWMHD,SEEK_SET);
|
||||
ReadHeader();
|
||||
}
|
||||
else
|
||||
{
|
||||
Seek(SFXSize+SIZEOF_MARKHEAD+NewMhd.HeadSize,SEEK_SET);
|
||||
return(SearchSubBlock(SUBHEAD_TYPE_CMT)!=0 && ReadCommentData(CmtData,CmtDataW)!=0);
|
||||
}
|
||||
#ifndef SFX_MODULE
|
||||
if (CommHead.HeadCRC!=HeaderCRC)
|
||||
{
|
||||
Log(FileName,St(MLogCommHead));
|
||||
Alarm();
|
||||
return(false);
|
||||
}
|
||||
CmtLength=CommHead.HeadSize-SIZEOF_COMMHEAD;
|
||||
#endif
|
||||
}
|
||||
#ifndef SFX_MODULE
|
||||
if (OldFormat && (OldMhd.Flags & MHD_PACK_COMMENT) || !OldFormat && CommHead.Method!=0x30)
|
||||
{
|
||||
if (!OldFormat && (CommHead.UnpVer < 15 || CommHead.UnpVer > UNP_VER || CommHead.Method > 0x35))
|
||||
return(false);
|
||||
ComprDataIO DataIO;
|
||||
Unpack Unpack(&DataIO);
|
||||
Unpack.Init();
|
||||
DataIO.SetTestMode(true);
|
||||
uint UnpCmtLength;
|
||||
if (OldFormat)
|
||||
{
|
||||
#ifdef NOCRYPT
|
||||
return(false);
|
||||
#else
|
||||
UnpCmtLength=GetByte();
|
||||
UnpCmtLength+=(GetByte()<<8);
|
||||
CmtLength-=2;
|
||||
DataIO.SetCmt13Encryption();
|
||||
#endif
|
||||
}
|
||||
else
|
||||
UnpCmtLength=CommHead.UnpSize;
|
||||
DataIO.SetFiles(this,NULL);
|
||||
DataIO.EnableShowProgress(false);
|
||||
DataIO.SetPackedSizeToRead(CmtLength);
|
||||
Unpack.SetDestSize(UnpCmtLength);
|
||||
Unpack.DoUnpack(CommHead.UnpVer,false);
|
||||
|
||||
if (!OldFormat && ((~DataIO.UnpFileCRC)&0xffff)!=CommHead.CommCRC)
|
||||
{
|
||||
Log(FileName,St(MLogCommBrk));
|
||||
Alarm();
|
||||
return(false);
|
||||
}
|
||||
else
|
||||
{
|
||||
byte *UnpData;
|
||||
size_t UnpDataSize;
|
||||
DataIO.GetUnpackedData(&UnpData,&UnpDataSize);
|
||||
CmtData->Alloc(UnpDataSize);
|
||||
memcpy(&((*CmtData)[0]),UnpData,UnpDataSize);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
CmtData->Alloc(CmtLength);
|
||||
|
||||
Read(&((*CmtData)[0]),CmtLength);
|
||||
if (!OldFormat && CommHead.CommCRC!=(~CRC(0xffffffff,&((*CmtData)[0]),CmtLength)&0xffff))
|
||||
{
|
||||
Log(FileName,St(MLogCommBrk));
|
||||
Alarm();
|
||||
CmtData->Reset();
|
||||
return(false);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
#if defined(_WIN_32) && !defined(_WIN_CE)
|
||||
if (CmtData->Size()>0)
|
||||
{
|
||||
size_t CmtSize=CmtData->Size();
|
||||
OemToCharBuff((char *)CmtData->Addr(),(char *)CmtData->Addr(),(DWORD)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);
|
||||
}
|
||||
|
||||
|
||||
size_t Archive::ReadCommentData(Array<byte> *CmtData,Array<wchar> *CmtDataW)
|
||||
{
|
||||
bool Unicode=SubHead.SubFlags & SUBHEAD_FLAGS_CMT_UNICODE;
|
||||
if (!ReadSubData(CmtData,NULL))
|
||||
return(0);
|
||||
size_t CmtSize=CmtData->Size();
|
||||
if (Unicode)
|
||||
{
|
||||
CmtSize/=2;
|
||||
Array<wchar> DataW(CmtSize+1);
|
||||
RawToWide(CmtData->Addr(),DataW.Addr(),CmtSize);
|
||||
DataW[CmtSize]=0;
|
||||
size_t 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);
|
||||
}
|
||||
|
||||
|
||||
void Archive::ViewComment()
|
||||
{
|
||||
#ifndef GUI
|
||||
if (Cmd->DisableComment)
|
||||
return;
|
||||
Array<byte> CmtBuf;
|
||||
if (GetComment(&CmtBuf,NULL))
|
||||
{
|
||||
size_t CmtSize=CmtBuf.Size();
|
||||
char *ChPtr=(char *)memchr(&CmtBuf[0],0x1A,CmtSize);
|
||||
if (ChPtr!=NULL)
|
||||
CmtSize=ChPtr-(char *)&CmtBuf[0];
|
||||
mprintf("\n");
|
||||
OutComment((char *)&CmtBuf[0],CmtSize);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
#ifndef SFX_MODULE
|
||||
void Archive::ViewFileComment()
|
||||
{
|
||||
if (!(NewLhd.Flags & LHD_COMMENT) || Cmd->DisableComment || OldFormat)
|
||||
return;
|
||||
#ifndef GUI
|
||||
mprintf(St(MFileComment));
|
||||
#endif
|
||||
const int MaxSize=0x8000;
|
||||
Array<char> CmtBuf(MaxSize);
|
||||
SaveFilePos SavePos(*this);
|
||||
Seek(CurBlockPos+SIZEOF_NEWLHD+NewLhd.NameSize,SEEK_SET);
|
||||
int64 SaveCurBlockPos=CurBlockPos;
|
||||
int64 SaveNextBlockPos=NextBlockPos;
|
||||
|
||||
size_t Size=ReadHeader();
|
||||
|
||||
CurBlockPos=SaveCurBlockPos;
|
||||
NextBlockPos=SaveNextBlockPos;
|
||||
|
||||
if (Size<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 || 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
|
||||
}
|
||||
}
|
||||
#endif
|
|
@ -0,0 +1,267 @@
|
|||
#include "rar.hpp"
|
||||
|
||||
#ifndef SHELL_EXT
|
||||
#include "arccmt.cpp"
|
||||
#endif
|
||||
|
||||
|
||||
Archive::Archive(RAROptions *InitCmd)
|
||||
{
|
||||
Cmd=InitCmd==NULL ? &DummyCmd:InitCmd;
|
||||
OpenShared=Cmd->OpenShared;
|
||||
OldFormat=false;
|
||||
Solid=false;
|
||||
Volume=false;
|
||||
MainComment=false;
|
||||
Locked=false;
|
||||
Signed=false;
|
||||
NotFirstVolume=false;
|
||||
SFXSize=0;
|
||||
LatestTime.Reset();
|
||||
Protected=false;
|
||||
Encrypted=false;
|
||||
BrokenFileHeader=false;
|
||||
LastReadBlock=0;
|
||||
|
||||
CurBlockPos=0;
|
||||
NextBlockPos=0;
|
||||
|
||||
RecoveryPos=SIZEOF_MARKHEAD;
|
||||
RecoverySectors=-1;
|
||||
|
||||
memset(&NewMhd,0,sizeof(NewMhd));
|
||||
NewMhd.HeadType=MAIN_HEAD;
|
||||
NewMhd.HeadSize=SIZEOF_NEWMHD;
|
||||
HeaderCRC=0;
|
||||
VolWrite=0;
|
||||
AddingFilesSize=0;
|
||||
AddingHeadersSize=0;
|
||||
#if !defined(SHELL_EXT) && !defined(NOCRYPT)
|
||||
*HeadersSalt=0;
|
||||
*SubDataSalt=0;
|
||||
#endif
|
||||
*FirstVolumeName=0;
|
||||
*FirstVolumeNameW=0;
|
||||
|
||||
Splitting=false;
|
||||
NewArchive=false;
|
||||
|
||||
SilentOpen=false;
|
||||
|
||||
}
|
||||
|
||||
|
||||
#ifndef SHELL_EXT
|
||||
void Archive::CheckArc(bool EnableBroken)
|
||||
{
|
||||
if (!IsArchive(EnableBroken))
|
||||
{
|
||||
Log(FileName,St(MBadArc),FileName);
|
||||
ErrHandler.Exit(FATAL_ERROR);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
#if !defined(SHELL_EXT) && !defined(SFX_MODULE)
|
||||
void Archive::CheckOpen(char *Name,wchar *NameW)
|
||||
{
|
||||
TOpen(Name,NameW);
|
||||
CheckArc(false);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
bool Archive::WCheckOpen(char *Name,wchar *NameW)
|
||||
{
|
||||
if (!WOpen(Name,NameW))
|
||||
return(false);
|
||||
if (!IsArchive(false))
|
||||
{
|
||||
#ifndef SHELL_EXT
|
||||
Log(FileName,St(MNotRAR),FileName);
|
||||
#endif
|
||||
Close();
|
||||
return(false);
|
||||
}
|
||||
return(true);
|
||||
}
|
||||
|
||||
|
||||
bool Archive::IsSignature(byte *D)
|
||||
{
|
||||
bool Valid=false;
|
||||
if (D[0]==0x52)
|
||||
#ifndef SFX_MODULE
|
||||
if (D[1]==0x45 && D[2]==0x7e && D[3]==0x5e)
|
||||
{
|
||||
OldFormat=true;
|
||||
Valid=true;
|
||||
}
|
||||
else
|
||||
#endif
|
||||
if (D[1]==0x61 && D[2]==0x72 && D[3]==0x21 && D[4]==0x1a && D[5]==0x07 && D[6]==0x00)
|
||||
{
|
||||
OldFormat=false;
|
||||
Valid=true;
|
||||
}
|
||||
return(Valid);
|
||||
}
|
||||
|
||||
|
||||
bool Archive::IsArchive(bool EnableBroken)
|
||||
{
|
||||
Encrypted=false;
|
||||
#ifndef SFX_MODULE
|
||||
if (IsDevice())
|
||||
{
|
||||
#ifndef SHELL_EXT
|
||||
Log(FileName,St(MInvalidName),FileName);
|
||||
#endif
|
||||
return(false);
|
||||
}
|
||||
#endif
|
||||
if (Read(MarkHead.Mark,SIZEOF_MARKHEAD)!=SIZEOF_MARKHEAD)
|
||||
return(false);
|
||||
SFXSize=0;
|
||||
if (IsSignature(MarkHead.Mark))
|
||||
{
|
||||
if (OldFormat)
|
||||
Seek(0,SEEK_SET);
|
||||
}
|
||||
else
|
||||
{
|
||||
Array<char> Buffer(MAXSFXSIZE);
|
||||
long CurPos=(long)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)
|
||||
Read(MarkHead.Mark,SIZEOF_MARKHEAD);
|
||||
break;
|
||||
}
|
||||
if (SFXSize==0)
|
||||
return(false);
|
||||
}
|
||||
ReadHeader();
|
||||
SeekToNext();
|
||||
#ifndef SFX_MODULE
|
||||
if (OldFormat)
|
||||
{
|
||||
NewMhd.Flags=OldMhd.Flags & 0x3f;
|
||||
NewMhd.HeadSize=OldMhd.HeadSize;
|
||||
}
|
||||
else
|
||||
#endif
|
||||
{
|
||||
if (HeaderCRC!=NewMhd.HeadCRC)
|
||||
{
|
||||
#ifndef SHELL_EXT
|
||||
Log(FileName,St(MLogMainHead));
|
||||
#endif
|
||||
Alarm();
|
||||
if (!EnableBroken)
|
||||
return(false);
|
||||
}
|
||||
}
|
||||
Volume=(NewMhd.Flags & MHD_VOLUME);
|
||||
Solid=(NewMhd.Flags & MHD_SOLID)!=0;
|
||||
MainComment=(NewMhd.Flags & MHD_COMMENT)!=0;
|
||||
Locked=(NewMhd.Flags & MHD_LOCK)!=0;
|
||||
Signed=(NewMhd.PosAV!=0);
|
||||
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(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
|
||||
|
||||
//if not encrypted, we'll check it below
|
||||
NotFirstVolume=Encrypted && (NewMhd.Flags & MHD_FIRSTVOLUME)==0;
|
||||
|
||||
if (!SilentOpen || !Encrypted)
|
||||
{
|
||||
SaveFilePos SavePos(*this);
|
||||
int64 SaveCurBlockPos=CurBlockPos,SaveNextBlockPos=NextBlockPos;
|
||||
|
||||
NotFirstVolume=false;
|
||||
while (ReadHeader()!=0)
|
||||
{
|
||||
int HeaderType=GetHeaderType();
|
||||
if (HeaderType==NEWSUB_HEAD)
|
||||
{
|
||||
if (SubHead.CmpName(SUBHEAD_TYPE_CMT))
|
||||
MainComment=true;
|
||||
if ((SubHead.Flags & LHD_SPLIT_BEFORE) ||
|
||||
Volume && (NewMhd.Flags & MHD_FIRSTVOLUME)==0)
|
||||
NotFirstVolume=true;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (HeaderType==FILE_HEAD && ((NewLhd.Flags & LHD_SPLIT_BEFORE)!=0 ||
|
||||
Volume && NewLhd.UnpVer>=29 && (NewMhd.Flags & MHD_FIRSTVOLUME)==0))
|
||||
NotFirstVolume=true;
|
||||
break;
|
||||
}
|
||||
SeekToNext();
|
||||
}
|
||||
CurBlockPos=SaveCurBlockPos;
|
||||
NextBlockPos=SaveNextBlockPos;
|
||||
}
|
||||
if (!Volume || !NotFirstVolume)
|
||||
{
|
||||
strcpy(FirstVolumeName,FileName);
|
||||
strcpyw(FirstVolumeNameW,FileNameW);
|
||||
}
|
||||
|
||||
return(true);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
void Archive::SeekToNext()
|
||||
{
|
||||
Seek(NextBlockPos,SEEK_SET);
|
||||
}
|
||||
|
||||
|
||||
#ifndef SFX_MODULE
|
||||
int Archive::GetRecoverySize(bool Required)
|
||||
{
|
||||
if (!Protected)
|
||||
return(0);
|
||||
if (RecoverySectors!=-1 || !Required)
|
||||
return(RecoverySectors);
|
||||
SaveFilePos SavePos(*this);
|
||||
Seek(SFXSize,SEEK_SET);
|
||||
SearchSubBlock(SUBHEAD_TYPE_RR);
|
||||
return(RecoverySectors);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
|
|
@ -0,0 +1,126 @@
|
|||
#ifndef _RAR_ARCHIVE_
|
||||
#define _RAR_ARCHIVE_
|
||||
|
||||
class Pack;
|
||||
|
||||
enum {EN_LOCK=1,EN_VOL=2,EN_FIRSTVOL=4};
|
||||
|
||||
class Archive:public File
|
||||
{
|
||||
private:
|
||||
bool IsSignature(byte *D);
|
||||
void UpdateLatestTime(FileHeader *CurBlock);
|
||||
void ConvertNameCase(char *Name);
|
||||
void ConvertNameCase(wchar *Name);
|
||||
void ConvertUnknownHeader();
|
||||
size_t ReadOldHeader();
|
||||
void UnexpEndArcMsg();
|
||||
|
||||
#if !defined(SHELL_EXT) && !defined(NOCRYPT)
|
||||
CryptData HeadersCrypt;
|
||||
byte HeadersSalt[SALT_SIZE];
|
||||
#endif
|
||||
#ifndef SHELL_EXT
|
||||
ComprDataIO SubDataIO;
|
||||
byte SubDataSalt[SALT_SIZE];
|
||||
#endif
|
||||
RAROptions *Cmd,DummyCmd;
|
||||
|
||||
MarkHeader MarkHead;
|
||||
OldMainHeader OldMhd;
|
||||
|
||||
int RecoverySectors;
|
||||
int64 RecoveryPos;
|
||||
|
||||
RarTime LatestTime;
|
||||
int LastReadBlock;
|
||||
int CurHeaderType;
|
||||
|
||||
bool SilentOpen;
|
||||
public:
|
||||
Archive(RAROptions *InitCmd=NULL);
|
||||
bool IsArchive(bool EnableBroken);
|
||||
size_t SearchBlock(int BlockType);
|
||||
size_t SearchSubBlock(const char *Type);
|
||||
int ReadBlock(int BlockType);
|
||||
void WriteBlock(int BlockType,BaseBlock *wb=NULL);
|
||||
int PrepareNamesToWrite(char *Name,wchar *NameW,char *DestName,byte *DestNameW);
|
||||
void SetLhdSize();
|
||||
size_t ReadHeader();
|
||||
void CheckArc(bool EnableBroken);
|
||||
void CheckOpen(char *Name,wchar *NameW=NULL);
|
||||
bool WCheckOpen(char *Name,wchar *NameW=NULL);
|
||||
bool TestLock(int Mode);
|
||||
void MakeTemp();
|
||||
void CopyMainHeader(Archive &Src,bool CopySFX=true,char *NameToDisplay=NULL);
|
||||
bool ProcessToFileHead(Archive &Src,bool LastBlockAdded,
|
||||
Pack *Pack=NULL,const char *SkipName=NULL);
|
||||
void TmpToArc(Archive &Src);
|
||||
void CloseNew(int AdjustRecovery,bool CloseVolume);
|
||||
void WriteEndBlock(bool CloseVolume);
|
||||
void CopyFileRecord(Archive &Src);
|
||||
void CopyArchiveData(Archive &Src);
|
||||
bool GetComment(Array<byte> *CmtData,Array<wchar> *CmtDataW);
|
||||
void ViewComment();
|
||||
void ViewFileComment();
|
||||
void SetLatestTime(RarTime *NewTime);
|
||||
void SeekToNext();
|
||||
bool CheckAccess();
|
||||
bool IsArcDir();
|
||||
bool IsArcLabel();
|
||||
void ConvertAttributes();
|
||||
int GetRecoverySize(bool Required);
|
||||
void VolSubtractHeaderSize(size_t SubSize);
|
||||
void AddSubData(byte *SrcData,size_t DataSize,File *SrcFile,const char *Name,bool AllowSplit);
|
||||
bool ReadSubData(Array<byte> *UnpData,File *DestFile);
|
||||
int GetHeaderType() {return(CurHeaderType);};
|
||||
size_t ReadCommentData(Array<byte> *CmtData,Array<wchar> *CmtDataW);
|
||||
void WriteCommentData(byte *Data,size_t DataSize,bool FileComment);
|
||||
RAROptions* GetRAROptions() {return(Cmd);}
|
||||
void SetSilentOpen(bool Mode) {SilentOpen=Mode;}
|
||||
|
||||
BaseBlock ShortBlock;
|
||||
MainHeader NewMhd;
|
||||
FileHeader NewLhd;
|
||||
EndArcHeader EndArcHead;
|
||||
SubBlockHeader SubBlockHead;
|
||||
FileHeader SubHead;
|
||||
CommentHeader CommHead;
|
||||
ProtectHeader ProtectHead;
|
||||
AVHeader AVHead;
|
||||
SignHeader SignHead;
|
||||
UnixOwnersHeader UOHead;
|
||||
MacFInfoHeader MACHead;
|
||||
EAHeader EAHead;
|
||||
StreamHeader StreamHead;
|
||||
|
||||
int64 CurBlockPos;
|
||||
int64 NextBlockPos;
|
||||
|
||||
bool OldFormat;
|
||||
bool Solid;
|
||||
bool Volume;
|
||||
bool MainComment;
|
||||
bool Locked;
|
||||
bool Signed;
|
||||
bool NotFirstVolume;
|
||||
bool Protected;
|
||||
bool Encrypted;
|
||||
size_t SFXSize;
|
||||
bool BrokenFileHeader;
|
||||
|
||||
bool Splitting;
|
||||
|
||||
ushort HeaderCRC;
|
||||
|
||||
int64 VolWrite;
|
||||
int64 AddingFilesSize;
|
||||
size_t AddingHeadersSize;
|
||||
|
||||
bool NewArchive;
|
||||
|
||||
char FirstVolumeName[NM];
|
||||
wchar FirstVolumeNameW[NM];
|
||||
};
|
||||
|
||||
#endif
|
|
@ -0,0 +1,712 @@
|
|||
#include "rar.hpp"
|
||||
|
||||
size_t Archive::SearchBlock(int BlockType)
|
||||
{
|
||||
size_t Size,Count=0;
|
||||
while ((Size=ReadHeader())!=0 &&
|
||||
(BlockType==ENDARC_HEAD || GetHeaderType()!=ENDARC_HEAD))
|
||||
{
|
||||
if ((++Count & 127)==0)
|
||||
Wait();
|
||||
if (GetHeaderType()==BlockType)
|
||||
return(Size);
|
||||
SeekToNext();
|
||||
}
|
||||
return(0);
|
||||
}
|
||||
|
||||
|
||||
size_t Archive::SearchSubBlock(const char *Type)
|
||||
{
|
||||
size_t Size;
|
||||
while ((Size=ReadHeader())!=0 && GetHeaderType()!=ENDARC_HEAD)
|
||||
{
|
||||
if (GetHeaderType()==NEWSUB_HEAD && SubHead.CmpName(Type))
|
||||
return(Size);
|
||||
SeekToNext();
|
||||
}
|
||||
return(0);
|
||||
}
|
||||
|
||||
|
||||
void Archive::UnexpEndArcMsg()
|
||||
{
|
||||
int64 ArcSize=FileLength();
|
||||
if (CurBlockPos>ArcSize || NextBlockPos>ArcSize)
|
||||
{
|
||||
#ifndef SHELL_EXT
|
||||
Log(FileName,St(MLogUnexpEOF));
|
||||
#endif
|
||||
ErrHandler.SetErrorCode(WARNING);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
size_t Archive::ReadHeader()
|
||||
{
|
||||
CurBlockPos=Tell();
|
||||
|
||||
#ifndef SFX_MODULE
|
||||
if (OldFormat)
|
||||
return(ReadOldHeader());
|
||||
#endif
|
||||
|
||||
RawRead Raw(this);
|
||||
|
||||
bool Decrypt=Encrypted && CurBlockPos>=(int64)SFXSize+SIZEOF_MARKHEAD+SIZEOF_NEWMHD;
|
||||
|
||||
if (Decrypt)
|
||||
{
|
||||
#if defined(SHELL_EXT) || defined(NOCRYPT)
|
||||
return(0);
|
||||
#else
|
||||
if (Read(HeadersSalt,SALT_SIZE)!=SALT_SIZE)
|
||||
{
|
||||
UnexpEndArcMsg();
|
||||
return(0);
|
||||
}
|
||||
if (*Cmd->Password==0)
|
||||
#ifdef RARDLL
|
||||
if (Cmd->Callback==NULL ||
|
||||
Cmd->Callback(UCM_NEEDPASSWORD,Cmd->UserData,(LPARAM)Cmd->Password,sizeof(Cmd->Password))==-1)
|
||||
{
|
||||
Close();
|
||||
ErrHandler.Exit(USER_BREAK);
|
||||
}
|
||||
|
||||
#else
|
||||
if (!GetPassword(PASSWORD_ARCHIVE,FileName,Cmd->Password,sizeof(Cmd->Password)))
|
||||
{
|
||||
Close();
|
||||
ErrHandler.Exit(USER_BREAK);
|
||||
}
|
||||
#endif
|
||||
HeadersCrypt.SetCryptKeys(Cmd->Password,HeadersSalt,false,false,NewMhd.EncryptVer>=36);
|
||||
Raw.SetCrypt(&HeadersCrypt);
|
||||
#endif
|
||||
}
|
||||
|
||||
Raw.Read(SIZEOF_SHORTBLOCKHEAD);
|
||||
if (Raw.Size()==0)
|
||||
{
|
||||
UnexpEndArcMsg();
|
||||
return(0);
|
||||
}
|
||||
|
||||
Raw.Get(ShortBlock.HeadCRC);
|
||||
byte HeadType;
|
||||
Raw.Get(HeadType);
|
||||
ShortBlock.HeadType=(HEADER_TYPE)HeadType;
|
||||
Raw.Get(ShortBlock.Flags);
|
||||
Raw.Get(ShortBlock.HeadSize);
|
||||
if (ShortBlock.HeadSize<SIZEOF_SHORTBLOCKHEAD)
|
||||
{
|
||||
#ifndef SHELL_EXT
|
||||
Log(FileName,St(MLogFileHead),"???");
|
||||
#endif
|
||||
BrokenFileHeader=true;
|
||||
ErrHandler.SetErrorCode(CRC_ERROR);
|
||||
return(0);
|
||||
}
|
||||
|
||||
if (ShortBlock.HeadType==COMM_HEAD)
|
||||
Raw.Read(SIZEOF_COMMHEAD-SIZEOF_SHORTBLOCKHEAD);
|
||||
else
|
||||
if (ShortBlock.HeadType==MAIN_HEAD && (ShortBlock.Flags & MHD_COMMENT)!=0)
|
||||
Raw.Read(SIZEOF_NEWMHD-SIZEOF_SHORTBLOCKHEAD);
|
||||
else
|
||||
Raw.Read(ShortBlock.HeadSize-SIZEOF_SHORTBLOCKHEAD);
|
||||
|
||||
NextBlockPos=CurBlockPos+ShortBlock.HeadSize;
|
||||
|
||||
switch(ShortBlock.HeadType)
|
||||
{
|
||||
case MAIN_HEAD:
|
||||
*(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:
|
||||
{
|
||||
FileHeader *hd=ShortBlock.HeadType==FILE_HEAD ? &NewLhd:&SubHead;
|
||||
*(BaseBlock *)hd=ShortBlock;
|
||||
Raw.Get(hd->PackSize);
|
||||
Raw.Get(hd->UnpSize);
|
||||
Raw.Get(hd->HostOS);
|
||||
Raw.Get(hd->FileCRC);
|
||||
Raw.Get(hd->FileTime);
|
||||
Raw.Get(hd->UnpVer);
|
||||
Raw.Get(hd->Method);
|
||||
Raw.Get(hd->NameSize);
|
||||
Raw.Get(hd->FileAttr);
|
||||
if (hd->Flags & LHD_LARGE)
|
||||
{
|
||||
Raw.Get(hd->HighPackSize);
|
||||
Raw.Get(hd->HighUnpSize);
|
||||
}
|
||||
else
|
||||
{
|
||||
hd->HighPackSize=hd->HighUnpSize=0;
|
||||
if (hd->UnpSize==0xffffffff)
|
||||
{
|
||||
// UnpSize equal to 0xffffffff without LHD_LARGE flag indicates
|
||||
// that we do not know the unpacked file size and must unpack it
|
||||
// until we find the end of file marker in compressed data.
|
||||
hd->UnpSize=(uint)(INT64NDF);
|
||||
hd->HighUnpSize=(uint)(INT64NDF>>32);
|
||||
}
|
||||
}
|
||||
hd->FullPackSize=INT32TO64(hd->HighPackSize,hd->PackSize);
|
||||
hd->FullUnpSize=INT32TO64(hd->HighUnpSize,hd->UnpSize);
|
||||
|
||||
char FileName[NM*4];
|
||||
int NameSize=Min(hd->NameSize,sizeof(FileName)-1);
|
||||
Raw.Get((byte *)FileName,NameSize);
|
||||
FileName[NameSize]=0;
|
||||
|
||||
strncpyz(hd->FileName,FileName,ASIZE(hd->FileName));
|
||||
|
||||
if (hd->HeadType==NEWSUB_HEAD)
|
||||
{
|
||||
int DataSize=hd->HeadSize-hd->NameSize-SIZEOF_NEWLHD;
|
||||
if (hd->Flags & LHD_SALT)
|
||||
DataSize-=SALT_SIZE;
|
||||
if (DataSize>0)
|
||||
{
|
||||
hd->SubData.Alloc(DataSize);
|
||||
Raw.Get(&hd->SubData[0],DataSize);
|
||||
if (hd->CmpName(SUBHEAD_TYPE_RR))
|
||||
{
|
||||
byte *D=&hd->SubData[8];
|
||||
RecoverySectors=D[0]+((uint)D[1]<<8)+((uint)D[2]<<16)+((uint)D[3]<<24);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
if (hd->HeadType==FILE_HEAD)
|
||||
{
|
||||
if (hd->Flags & LHD_UNICODE)
|
||||
{
|
||||
EncodeFileName NameCoder;
|
||||
size_t 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;
|
||||
}
|
||||
else
|
||||
*hd->FileNameW=0;
|
||||
#ifndef SFX_MODULE
|
||||
ConvertNameCase(hd->FileName);
|
||||
ConvertNameCase(hd->FileNameW);
|
||||
#endif
|
||||
ConvertUnknownHeader();
|
||||
}
|
||||
if (hd->Flags & LHD_SALT)
|
||||
Raw.Get(hd->Salt,SALT_SIZE);
|
||||
hd->mtime.SetDos(hd->FileTime);
|
||||
hd->ctime.Reset();
|
||||
hd->atime.Reset();
|
||||
hd->arctime.Reset();
|
||||
if (hd->Flags & LHD_EXTTIME)
|
||||
{
|
||||
ushort Flags;
|
||||
Raw.Get(Flags);
|
||||
RarTime *tbl[4];
|
||||
tbl[0]=&NewLhd.mtime;
|
||||
tbl[1]=&NewLhd.ctime;
|
||||
tbl[2]=&NewLhd.atime;
|
||||
tbl[3]=&NewLhd.arctime;
|
||||
for (int I=0;I<4;I++)
|
||||
{
|
||||
RarTime *CurTime=tbl[I];
|
||||
uint rmode=Flags>>(3-I)*4;
|
||||
if ((rmode & 8)==0)
|
||||
continue;
|
||||
if (I!=0)
|
||||
{
|
||||
uint DosTime;
|
||||
Raw.Get(DosTime);
|
||||
CurTime->SetDos(DosTime);
|
||||
}
|
||||
RarLocalTime rlt;
|
||||
CurTime->GetLocal(&rlt);
|
||||
if (rmode & 4)
|
||||
rlt.Second++;
|
||||
rlt.Reminder=0;
|
||||
int count=rmode&3;
|
||||
for (int J=0;J<count;J++)
|
||||
{
|
||||
byte CurByte;
|
||||
Raw.Get(CurByte);
|
||||
rlt.Reminder|=(((uint)CurByte)<<((J+3-count)*8));
|
||||
}
|
||||
CurTime->SetLocal(&rlt);
|
||||
}
|
||||
}
|
||||
NextBlockPos+=hd->FullPackSize;
|
||||
bool CRCProcessedOnly=(hd->Flags & LHD_COMMENT)!=0;
|
||||
HeaderCRC=~Raw.GetCRC(CRCProcessedOnly)&0xffff;
|
||||
if (hd->HeadCRC!=HeaderCRC)
|
||||
{
|
||||
if (hd->HeadType==NEWSUB_HEAD)
|
||||
strcat(hd->FileName,"- ???");
|
||||
BrokenFileHeader=true;
|
||||
ErrHandler.SetErrorCode(WARNING);
|
||||
#ifndef SHELL_EXT
|
||||
Log(Archive::FileName,St(MLogFileHead),IntNameToExt(hd->FileName));
|
||||
Alarm();
|
||||
#endif
|
||||
}
|
||||
}
|
||||
break;
|
||||
#ifndef SFX_MODULE
|
||||
case COMM_HEAD:
|
||||
*(BaseBlock *)&CommHead=ShortBlock;
|
||||
Raw.Get(CommHead.UnpSize);
|
||||
Raw.Get(CommHead.UnpVer);
|
||||
Raw.Get(CommHead.Method);
|
||||
Raw.Get(CommHead.CommCRC);
|
||||
break;
|
||||
case SIGN_HEAD:
|
||||
*(BaseBlock *)&SignHead=ShortBlock;
|
||||
Raw.Get(SignHead.CreationTime);
|
||||
Raw.Get(SignHead.ArcNameSize);
|
||||
Raw.Get(SignHead.UserNameSize);
|
||||
break;
|
||||
case AV_HEAD:
|
||||
*(BaseBlock *)&AVHead=ShortBlock;
|
||||
Raw.Get(AVHead.UnpVer);
|
||||
Raw.Get(AVHead.Method);
|
||||
Raw.Get(AVHead.AVVer);
|
||||
Raw.Get(AVHead.AVInfoCRC);
|
||||
break;
|
||||
case PROTECT_HEAD:
|
||||
*(BaseBlock *)&ProtectHead=ShortBlock;
|
||||
Raw.Get(ProtectHead.DataSize);
|
||||
Raw.Get(ProtectHead.Version);
|
||||
Raw.Get(ProtectHead.RecSectors);
|
||||
Raw.Get(ProtectHead.TotalBlocks);
|
||||
Raw.Get(ProtectHead.Mark,8);
|
||||
NextBlockPos+=ProtectHead.DataSize;
|
||||
RecoverySectors=ProtectHead.RecSectors;
|
||||
break;
|
||||
case SUB_HEAD:
|
||||
*(BaseBlock *)&SubBlockHead=ShortBlock;
|
||||
Raw.Get(SubBlockHead.DataSize);
|
||||
NextBlockPos+=SubBlockHead.DataSize;
|
||||
Raw.Get(SubBlockHead.SubType);
|
||||
Raw.Get(SubBlockHead.Level);
|
||||
switch(SubBlockHead.SubType)
|
||||
{
|
||||
case UO_HEAD:
|
||||
*(SubBlockHeader *)&UOHead=SubBlockHead;
|
||||
Raw.Get(UOHead.OwnerNameSize);
|
||||
Raw.Get(UOHead.GroupNameSize);
|
||||
if (UOHead.OwnerNameSize>NM-1)
|
||||
UOHead.OwnerNameSize=NM-1;
|
||||
if (UOHead.GroupNameSize>NM-1)
|
||||
UOHead.GroupNameSize=NM-1;
|
||||
Raw.Get((byte *)UOHead.OwnerName,UOHead.OwnerNameSize);
|
||||
Raw.Get((byte *)UOHead.GroupName,UOHead.GroupNameSize);
|
||||
UOHead.OwnerName[UOHead.OwnerNameSize]=0;
|
||||
UOHead.GroupName[UOHead.GroupNameSize]=0;
|
||||
break;
|
||||
case MAC_HEAD:
|
||||
*(SubBlockHeader *)&MACHead=SubBlockHead;
|
||||
Raw.Get(MACHead.fileType);
|
||||
Raw.Get(MACHead.fileCreator);
|
||||
break;
|
||||
case EA_HEAD:
|
||||
case BEEA_HEAD:
|
||||
case NTACL_HEAD:
|
||||
*(SubBlockHeader *)&EAHead=SubBlockHead;
|
||||
Raw.Get(EAHead.UnpSize);
|
||||
Raw.Get(EAHead.UnpVer);
|
||||
Raw.Get(EAHead.Method);
|
||||
Raw.Get(EAHead.EACRC);
|
||||
break;
|
||||
case STREAM_HEAD:
|
||||
*(SubBlockHeader *)&StreamHead=SubBlockHead;
|
||||
Raw.Get(StreamHead.UnpSize);
|
||||
Raw.Get(StreamHead.UnpVer);
|
||||
Raw.Get(StreamHead.Method);
|
||||
Raw.Get(StreamHead.StreamCRC);
|
||||
Raw.Get(StreamHead.StreamNameSize);
|
||||
if (StreamHead.StreamNameSize>NM-1)
|
||||
StreamHead.StreamNameSize=NM-1;
|
||||
Raw.Get((byte *)StreamHead.StreamName,StreamHead.StreamNameSize);
|
||||
StreamHead.StreamName[StreamHead.StreamNameSize]=0;
|
||||
break;
|
||||
}
|
||||
break;
|
||||
#endif
|
||||
default:
|
||||
if (ShortBlock.Flags & LONG_BLOCK)
|
||||
{
|
||||
uint DataSize;
|
||||
Raw.Get(DataSize);
|
||||
NextBlockPos+=DataSize;
|
||||
}
|
||||
break;
|
||||
}
|
||||
HeaderCRC=~Raw.GetCRC(false)&0xffff;
|
||||
CurHeaderType=ShortBlock.HeadType;
|
||||
if (Decrypt)
|
||||
{
|
||||
NextBlockPos+=Raw.PaddedSize()+SALT_SIZE;
|
||||
|
||||
if (ShortBlock.HeadCRC!=HeaderCRC)
|
||||
{
|
||||
bool Recovered=false;
|
||||
if (ShortBlock.HeadType==ENDARC_HEAD && (EndArcHead.Flags & EARC_REVSPACE)!=0)
|
||||
{
|
||||
// Last 7 bytes of recovered volume can contain zeroes, because
|
||||
// REV files store its own information (volume number, etc.) here.
|
||||
SaveFilePos SavePos(*this);
|
||||
int64 Length=Tell();
|
||||
Seek(Length-7,SEEK_SET);
|
||||
Recovered=true;
|
||||
for (int J=0;J<7;J++)
|
||||
if (GetByte()!=0)
|
||||
Recovered=false;
|
||||
}
|
||||
if (!Recovered)
|
||||
{
|
||||
#ifndef SILENT
|
||||
Log(FileName,St(MEncrBadCRC),FileName);
|
||||
#endif
|
||||
Close();
|
||||
|
||||
BrokenFileHeader=true;
|
||||
ErrHandler.SetErrorCode(CRC_ERROR);
|
||||
return(0);
|
||||
// ErrHandler.Exit(CRC_ERROR);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (NextBlockPos<=CurBlockPos)
|
||||
{
|
||||
#ifndef SHELL_EXT
|
||||
Log(FileName,St(MLogFileHead),"???");
|
||||
#endif
|
||||
BrokenFileHeader=true;
|
||||
ErrHandler.SetErrorCode(CRC_ERROR);
|
||||
return(0);
|
||||
}
|
||||
return(Raw.Size());
|
||||
}
|
||||
|
||||
|
||||
#ifndef SFX_MODULE
|
||||
size_t Archive::ReadOldHeader()
|
||||
{
|
||||
RawRead Raw(this);
|
||||
if (CurBlockPos<=(int64)SFXSize)
|
||||
{
|
||||
Raw.Read(SIZEOF_OLDMHD);
|
||||
Raw.Get(OldMhd.Mark,4);
|
||||
Raw.Get(OldMhd.HeadSize);
|
||||
Raw.Get(OldMhd.Flags);
|
||||
NextBlockPos=CurBlockPos+OldMhd.HeadSize;
|
||||
CurHeaderType=MAIN_HEAD;
|
||||
}
|
||||
else
|
||||
{
|
||||
OldFileHeader OldLhd;
|
||||
Raw.Read(SIZEOF_OLDLHD);
|
||||
NewLhd.HeadType=FILE_HEAD;
|
||||
Raw.Get(NewLhd.PackSize);
|
||||
Raw.Get(NewLhd.UnpSize);
|
||||
Raw.Get(OldLhd.FileCRC);
|
||||
Raw.Get(NewLhd.HeadSize);
|
||||
Raw.Get(NewLhd.FileTime);
|
||||
Raw.Get(OldLhd.FileAttr);
|
||||
Raw.Get(OldLhd.Flags);
|
||||
Raw.Get(OldLhd.UnpVer);
|
||||
Raw.Get(OldLhd.NameSize);
|
||||
Raw.Get(OldLhd.Method);
|
||||
|
||||
NewLhd.Flags=OldLhd.Flags|LONG_BLOCK;
|
||||
NewLhd.UnpVer=(OldLhd.UnpVer==2) ? 13 : 10;
|
||||
NewLhd.Method=OldLhd.Method+0x30;
|
||||
NewLhd.NameSize=OldLhd.NameSize;
|
||||
NewLhd.FileAttr=OldLhd.FileAttr;
|
||||
NewLhd.FileCRC=OldLhd.FileCRC;
|
||||
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;
|
||||
ConvertNameCase(NewLhd.FileName);
|
||||
*NewLhd.FileNameW=0;
|
||||
|
||||
if (Raw.Size()!=0)
|
||||
NextBlockPos=CurBlockPos+NewLhd.HeadSize+NewLhd.PackSize;
|
||||
CurHeaderType=FILE_HEAD;
|
||||
}
|
||||
return(NextBlockPos>CurBlockPos ? Raw.Size():0);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
void Archive::ConvertNameCase(char *Name)
|
||||
{
|
||||
if (Cmd->ConvertNames==NAMES_UPPERCASE)
|
||||
{
|
||||
IntToExt(Name,Name);
|
||||
strupper(Name);
|
||||
ExtToInt(Name,Name);
|
||||
}
|
||||
if (Cmd->ConvertNames==NAMES_LOWERCASE)
|
||||
{
|
||||
IntToExt(Name,Name);
|
||||
strlower(Name);
|
||||
ExtToInt(Name,Name);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#ifndef SFX_MODULE
|
||||
void Archive::ConvertNameCase(wchar *Name)
|
||||
{
|
||||
if (Cmd->ConvertNames==NAMES_UPPERCASE)
|
||||
strupperw(Name);
|
||||
if (Cmd->ConvertNames==NAMES_LOWERCASE)
|
||||
strlowerw(Name);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
bool Archive::IsArcDir()
|
||||
{
|
||||
return((NewLhd.Flags & LHD_WINDOWMASK)==LHD_DIRECTORY);
|
||||
}
|
||||
|
||||
|
||||
bool Archive::IsArcLabel()
|
||||
{
|
||||
return(NewLhd.HostOS<=HOST_WIN32 && (NewLhd.FileAttr & 8));
|
||||
}
|
||||
|
||||
|
||||
void Archive::ConvertAttributes()
|
||||
{
|
||||
#if defined(_WIN_32) || defined(_EMX)
|
||||
switch(NewLhd.HostOS)
|
||||
{
|
||||
case HOST_MSDOS:
|
||||
case HOST_OS2:
|
||||
case HOST_WIN32:
|
||||
break;
|
||||
case HOST_UNIX:
|
||||
case HOST_BEOS:
|
||||
if ((NewLhd.Flags & LHD_WINDOWMASK)==LHD_DIRECTORY)
|
||||
NewLhd.FileAttr=0x10;
|
||||
else
|
||||
NewLhd.FileAttr=0x20;
|
||||
break;
|
||||
default:
|
||||
if ((NewLhd.Flags & LHD_WINDOWMASK)==LHD_DIRECTORY)
|
||||
NewLhd.FileAttr=0x10;
|
||||
else
|
||||
NewLhd.FileAttr=0x20;
|
||||
break;
|
||||
}
|
||||
#endif
|
||||
#ifdef _UNIX
|
||||
// umask defines which permission bits must not be set by default
|
||||
// when creating a file or directory.
|
||||
static mode_t mask = (mode_t) -1;
|
||||
|
||||
if (mask == (mode_t) -1)
|
||||
{
|
||||
// umask call returns the current umask value. Argument (022) is not
|
||||
// important here.
|
||||
mask = umask(022);
|
||||
|
||||
// Restore the original umask value, which was changed to 022 above.
|
||||
umask(mask);
|
||||
}
|
||||
|
||||
switch(NewLhd.HostOS)
|
||||
{
|
||||
case HOST_MSDOS:
|
||||
case HOST_OS2:
|
||||
case HOST_WIN32:
|
||||
{
|
||||
// Mapping MSDOS, OS/2 and Windows file attributes to Unix.
|
||||
|
||||
if (NewLhd.FileAttr & 0x10) // FILE_ATTRIBUTE_DIRECTORY
|
||||
{
|
||||
// For directories we use 0777 mask.
|
||||
NewLhd.FileAttr=0777 & ~mask;
|
||||
}
|
||||
else
|
||||
if (NewLhd.FileAttr & 1) // FILE_ATTRIBUTE_READONLY
|
||||
{
|
||||
// For read only files we use 0444 mask with 'w' bits turned off.
|
||||
NewLhd.FileAttr=0444 & ~mask;
|
||||
}
|
||||
else
|
||||
{
|
||||
// umask does not set +x for regular files, so we use 0666
|
||||
// instead of 0777 as for directories.
|
||||
NewLhd.FileAttr=0666 & ~mask;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case HOST_UNIX:
|
||||
case HOST_BEOS:
|
||||
break;
|
||||
default:
|
||||
if ((NewLhd.Flags & LHD_WINDOWMASK)==LHD_DIRECTORY)
|
||||
NewLhd.FileAttr=0x41ff & ~mask;
|
||||
else
|
||||
NewLhd.FileAttr=0x81b6 & ~mask;
|
||||
break;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
void Archive::ConvertUnknownHeader()
|
||||
{
|
||||
if (NewLhd.UnpVer<20 && (NewLhd.FileAttr & 0x10))
|
||||
NewLhd.Flags|=LHD_DIRECTORY;
|
||||
if (NewLhd.HostOS>=HOST_MAX)
|
||||
{
|
||||
if ((NewLhd.Flags & LHD_WINDOWMASK)==LHD_DIRECTORY)
|
||||
NewLhd.FileAttr=0x10;
|
||||
else
|
||||
NewLhd.FileAttr=0x20;
|
||||
}
|
||||
for (char *s=NewLhd.FileName;*s!=0;s=charnext(s))
|
||||
{
|
||||
if (*s=='/' || *s=='\\')
|
||||
*s=CPATHDIVIDER;
|
||||
#if defined(_APPLE) && !defined(UNICODE_SUPPORTED)
|
||||
if ((byte)*s<32 || (byte)*s>127)
|
||||
*s='_';
|
||||
#endif
|
||||
|
||||
#if defined(_WIN_32) || defined(_EMX)
|
||||
// ':' in file names is allowed in Unix, but not in Windows.
|
||||
// Even worse, file data will be written to NTFS stream on NTFS,
|
||||
// so automatic name correction on file create error in extraction
|
||||
// routine does not work. In Windows and DOS versions we better
|
||||
// replace ':' now.
|
||||
if (*s==':')
|
||||
*s='_';
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
for (wchar *s=NewLhd.FileNameW;*s!=0;s++)
|
||||
{
|
||||
if (*s=='/' || *s=='\\')
|
||||
*s=CPATHDIVIDER;
|
||||
|
||||
#if defined(_WIN_32) || defined(_EMX)
|
||||
// ':' in file names is allowed in Unix, but not in Windows.
|
||||
// Even worse, file data will be written to NTFS stream on NTFS,
|
||||
// so automatic name correction on file create error in extraction
|
||||
// routine does not work. In Windows and DOS versions we better
|
||||
// replace ':' now.
|
||||
if (*s==':')
|
||||
*s='_';
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#ifndef SHELL_EXT
|
||||
bool Archive::ReadSubData(Array<byte> *UnpData,File *DestFile)
|
||||
{
|
||||
if (HeaderCRC!=SubHead.HeadCRC)
|
||||
{
|
||||
#ifndef SHELL_EXT
|
||||
Log(FileName,St(MSubHeadCorrupt));
|
||||
#endif
|
||||
ErrHandler.SetErrorCode(CRC_ERROR);
|
||||
return(false);
|
||||
}
|
||||
if (SubHead.Method<0x30 || SubHead.Method>0x35 || SubHead.UnpVer>/*PACK_VER*/36)
|
||||
{
|
||||
#ifndef SHELL_EXT
|
||||
Log(FileName,St(MSubHeadUnknown));
|
||||
#endif
|
||||
return(false);
|
||||
}
|
||||
|
||||
if (SubHead.PackSize==0 && (SubHead.Flags & LHD_SPLIT_AFTER)==0)
|
||||
return(true);
|
||||
|
||||
SubDataIO.Init();
|
||||
Unpack Unpack(&SubDataIO);
|
||||
Unpack.Init();
|
||||
|
||||
if (DestFile==NULL)
|
||||
{
|
||||
UnpData->Alloc(SubHead.UnpSize);
|
||||
SubDataIO.SetUnpackToMemory(&(*UnpData)[0],SubHead.UnpSize);
|
||||
}
|
||||
if (SubHead.Flags & LHD_PASSWORD)
|
||||
if (*Cmd->Password)
|
||||
SubDataIO.SetEncryption(SubHead.UnpVer,Cmd->Password,
|
||||
(SubHead.Flags & LHD_SALT) ? SubHead.Salt:NULL,false,
|
||||
SubHead.UnpVer>=36);
|
||||
else
|
||||
return(false);
|
||||
SubDataIO.SetPackedSizeToRead(SubHead.PackSize);
|
||||
SubDataIO.EnableShowProgress(false);
|
||||
SubDataIO.SetFiles(this,DestFile);
|
||||
SubDataIO.UnpVolume=(SubHead.Flags & LHD_SPLIT_AFTER)!=0;
|
||||
SubDataIO.SetSubHeader(&SubHead,NULL);
|
||||
Unpack.SetDestSize(SubHead.UnpSize);
|
||||
if (SubHead.Method==0x30)
|
||||
CmdExtract::UnstoreFile(SubDataIO,SubHead.UnpSize);
|
||||
else
|
||||
Unpack.DoUnpack(SubHead.UnpVer,false);
|
||||
|
||||
if (SubHead.FileCRC!=~SubDataIO.UnpFileCRC)
|
||||
{
|
||||
#ifndef SHELL_EXT
|
||||
Log(FileName,St(MSubHeadDataCRC),SubHead.FileName);
|
||||
#endif
|
||||
ErrHandler.SetErrorCode(CRC_ERROR);
|
||||
if (UnpData!=NULL)
|
||||
UnpData->Reset();
|
||||
return(false);
|
||||
}
|
||||
return(true);
|
||||
}
|
||||
#endif
|
|
@ -0,0 +1,122 @@
|
|||
#ifndef _RAR_ARRAY_
|
||||
#define _RAR_ARRAY_
|
||||
|
||||
extern ErrorHandler ErrHandler;
|
||||
|
||||
template <class T> class Array
|
||||
{
|
||||
private:
|
||||
T *Buffer;
|
||||
size_t BufSize;
|
||||
size_t AllocSize;
|
||||
public:
|
||||
Array();
|
||||
Array(size_t Size);
|
||||
~Array();
|
||||
inline void CleanData();
|
||||
inline T& operator [](size_t Item);
|
||||
inline size_t Size();
|
||||
void Add(size_t Items);
|
||||
void Alloc(size_t Items);
|
||||
void Reset();
|
||||
void operator = (Array<T> &Src);
|
||||
void Push(T Item);
|
||||
T* Addr() {return(Buffer);}
|
||||
};
|
||||
|
||||
template <class T> void Array<T>::CleanData()
|
||||
{
|
||||
Buffer=NULL;
|
||||
BufSize=0;
|
||||
AllocSize=0;
|
||||
}
|
||||
|
||||
|
||||
template <class T> Array<T>::Array()
|
||||
{
|
||||
CleanData();
|
||||
}
|
||||
|
||||
|
||||
template <class T> Array<T>::Array(size_t Size)
|
||||
{
|
||||
Buffer=(T *)rarmalloc(sizeof(T)*Size);
|
||||
if (Buffer==NULL && Size!=0)
|
||||
ErrHandler.MemoryError();
|
||||
|
||||
AllocSize=BufSize=Size;
|
||||
}
|
||||
|
||||
|
||||
template <class T> Array<T>::~Array()
|
||||
{
|
||||
if (Buffer!=NULL)
|
||||
rarfree(Buffer);
|
||||
}
|
||||
|
||||
|
||||
template <class T> inline T& Array<T>::operator [](size_t Item)
|
||||
{
|
||||
return(Buffer[Item]);
|
||||
}
|
||||
|
||||
|
||||
template <class T> inline size_t Array<T>::Size()
|
||||
{
|
||||
return(BufSize);
|
||||
}
|
||||
|
||||
|
||||
template <class T> void Array<T>::Add(size_t Items)
|
||||
{
|
||||
BufSize+=Items;
|
||||
if (BufSize>AllocSize)
|
||||
{
|
||||
size_t Suggested=AllocSize+AllocSize/4+32;
|
||||
size_t NewSize=Max(BufSize,Suggested);
|
||||
|
||||
Buffer=(T *)rarrealloc(Buffer,NewSize*sizeof(T));
|
||||
if (Buffer==NULL)
|
||||
ErrHandler.MemoryError();
|
||||
AllocSize=NewSize;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
template <class T> void Array<T>::Alloc(size_t Items)
|
||||
{
|
||||
if (Items>AllocSize)
|
||||
Add(Items-BufSize);
|
||||
else
|
||||
BufSize=Items;
|
||||
}
|
||||
|
||||
|
||||
template <class T> void Array<T>::Reset()
|
||||
{
|
||||
if (Buffer!=NULL)
|
||||
{
|
||||
rarfree(Buffer);
|
||||
Buffer=NULL;
|
||||
}
|
||||
BufSize=0;
|
||||
AllocSize=0;
|
||||
}
|
||||
|
||||
|
||||
template <class T> void Array<T>::operator =(Array<T> &Src)
|
||||
{
|
||||
Reset();
|
||||
Alloc(Src.BufSize);
|
||||
if (Src.BufSize!=0)
|
||||
memcpy((void *)Buffer,(void *)Src.Buffer,Src.BufSize*sizeof(T));
|
||||
}
|
||||
|
||||
|
||||
template <class T> void Array<T>::Push(T Item)
|
||||
{
|
||||
Add(1);
|
||||
(*this)[Size()-1]=Item;
|
||||
}
|
||||
|
||||
#endif
|
|
@ -0,0 +1,113 @@
|
|||
|
||||
|
||||
void ExtractBeEA(Archive &Arc,char *FileName)
|
||||
{
|
||||
if (Arc.HeaderCRC!=Arc.EAHead.HeadCRC)
|
||||
{
|
||||
Log(Arc.FileName,St(MEABroken),FileName);
|
||||
ErrHandler.SetErrorCode(CRC_ERROR);
|
||||
return;
|
||||
}
|
||||
if (Arc.EAHead.Method<0x31 || Arc.EAHead.Method>0x35 || Arc.EAHead.UnpVer>PACK_VER)
|
||||
{
|
||||
Log(Arc.FileName,St(MEAUnknHeader),FileName);
|
||||
return;
|
||||
}
|
||||
|
||||
ComprDataIO DataIO;
|
||||
Unpack Unpack(&DataIO);
|
||||
Unpack.Init();
|
||||
|
||||
Array<byte> UnpData(Arc.EAHead.UnpSize);
|
||||
DataIO.SetUnpackToMemory(&UnpData[0],Arc.EAHead.UnpSize);
|
||||
DataIO.SetPackedSizeToRead(Arc.EAHead.DataSize);
|
||||
DataIO.EnableShowProgress(false);
|
||||
DataIO.SetFiles(&Arc,NULL);
|
||||
Unpack.SetDestSize(Arc.EAHead.UnpSize);
|
||||
Unpack.DoUnpack(Arc.EAHead.UnpVer,false);
|
||||
|
||||
if (Arc.EAHead.EACRC!=~DataIO.UnpFileCRC)
|
||||
{
|
||||
Log(Arc.FileName,St(MEABroken),FileName);
|
||||
ErrHandler.SetErrorCode(CRC_ERROR);
|
||||
return;
|
||||
}
|
||||
int fd = open(FileName,O_WRONLY);
|
||||
if (fd==-1)
|
||||
{
|
||||
Log(Arc.FileName,St(MCannotSetEA),FileName);
|
||||
ErrHandler.SetErrorCode(WARNING);
|
||||
return;
|
||||
}
|
||||
|
||||
int AttrPos=0;
|
||||
while (AttrPos<Arc.EAHead.UnpSize)
|
||||
{
|
||||
unsigned char *CurItem=&UnpData[AttrPos];
|
||||
int NameSize=CurItem[0]+((int)CurItem[1]<<8);
|
||||
int Type=CurItem[2]+((int)CurItem[3]<<8)+((int)CurItem[4]<<16)+((int)CurItem[5]<<24);
|
||||
int Size=CurItem[6]+((int)CurItem[7]<<8)+((int)CurItem[8]<<16)+((int)CurItem[9]<<24);
|
||||
char Name[1024];
|
||||
if (NameSize>=sizeof(Name))
|
||||
{
|
||||
Log(Arc.FileName,St(MCannotSetEA),FileName);
|
||||
ErrHandler.SetErrorCode(WARNING);
|
||||
break;
|
||||
}
|
||||
memcpy(Name,CurItem+10,NameSize);
|
||||
Name[NameSize]=0;
|
||||
if (fs_write_attr(fd,Name,Type,0,CurItem+10+NameSize,Size)==-1)
|
||||
{
|
||||
Log(Arc.FileName,St(MCannotSetEA),FileName);
|
||||
ErrHandler.SetErrorCode(WARNING);
|
||||
break;
|
||||
}
|
||||
AttrPos+=10+NameSize+Size;
|
||||
}
|
||||
close(fd);
|
||||
mprintf(St(MShowEA));
|
||||
}
|
||||
|
||||
|
||||
void ExtractBeEANew(Archive &Arc,char *FileName)
|
||||
{
|
||||
Array<byte> SubData;
|
||||
if (!Arc.ReadSubData(&SubData,NULL))
|
||||
return;
|
||||
|
||||
int fd = open(FileName,O_WRONLY);
|
||||
if (fd==-1)
|
||||
{
|
||||
Log(Arc.FileName,St(MCannotSetEA),FileName);
|
||||
ErrHandler.SetErrorCode(WARNING);
|
||||
return;
|
||||
}
|
||||
|
||||
int AttrPos=0;
|
||||
while (AttrPos<Arc.EAHead.UnpSize)
|
||||
{
|
||||
unsigned char *CurItem=&SubData[AttrPos];
|
||||
int NameSize=CurItem[0]+((int)CurItem[1]<<8);
|
||||
int Type=CurItem[2]+((int)CurItem[3]<<8)+((int)CurItem[4]<<16)+((int)CurItem[5]<<24);
|
||||
int Size=CurItem[6]+((int)CurItem[7]<<8)+((int)CurItem[8]<<16)+((int)CurItem[9]<<24);
|
||||
char Name[1024];
|
||||
if (NameSize>=sizeof(Name))
|
||||
{
|
||||
Log(Arc.FileName,St(MCannotSetEA),FileName);
|
||||
ErrHandler.SetErrorCode(WARNING);
|
||||
break;
|
||||
}
|
||||
memcpy(Name,CurItem+10,NameSize);
|
||||
Name[NameSize]=0;
|
||||
if (fs_write_attr(fd,Name,Type,0,CurItem+10+NameSize,Size)==-1)
|
||||
{
|
||||
Log(Arc.FileName,St(MCannotSetEA),FileName);
|
||||
ErrHandler.SetErrorCode(WARNING);
|
||||
break;
|
||||
}
|
||||
AttrPos+=10+NameSize+Size;
|
||||
}
|
||||
close(fd);
|
||||
mprintf(St(MShowEA));
|
||||
}
|
||||
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,57 @@
|
|||
#ifndef _RAR_CMDDATA_
|
||||
#define _RAR_CMDDATA_
|
||||
|
||||
#define DefaultStoreList "7z;ace;arj;bz2;cab;gz;jpeg;jpg;lha;lzh;mp3;rar;taz;tgz;z;zip"
|
||||
|
||||
class CommandData:public RAROptions
|
||||
{
|
||||
private:
|
||||
void ProcessSwitchesString(char *Str);
|
||||
void ProcessSwitch(char *Switch,wchar *SwitchW=NULL);
|
||||
void BadSwitch(char *Switch);
|
||||
bool ExclCheckArgs(StringList *Args,char *CheckName,bool CheckFullPath,int MatchMode);
|
||||
uint GetExclAttr(char *Str);
|
||||
|
||||
bool FileLists;
|
||||
bool NoMoreSwitches;
|
||||
bool BareOutput;
|
||||
public:
|
||||
CommandData();
|
||||
~CommandData();
|
||||
void Init();
|
||||
void Close();
|
||||
void ParseArg(char *Arg,wchar *ArgW);
|
||||
void ParseDone();
|
||||
void ParseEnvVar();
|
||||
void ReadConfig(int argc,char *argv[]);
|
||||
bool IsConfigEnabled(int argc,char *argv[]);
|
||||
void OutTitle();
|
||||
void OutHelp();
|
||||
bool IsSwitch(int Ch);
|
||||
bool ExclCheck(char *CheckName,bool CheckFullPath,bool CheckInclList);
|
||||
bool StoreCheck(char *CheckName);
|
||||
bool TimeCheck(RarTime &ft);
|
||||
bool SizeCheck(int64 Size);
|
||||
bool AnyFiltersActive();
|
||||
int IsProcessFile(FileHeader &NewLhd,bool *ExactMatch=NULL,int MatchType=MATCH_WILDSUBPATH);
|
||||
void ProcessCommand();
|
||||
void AddArcName(char *Name,wchar *NameW);
|
||||
bool GetArcName(char *Name,wchar *NameW,int MaxSize);
|
||||
bool CheckWinSize();
|
||||
|
||||
int GetRecoverySize(char *Str,int DefSize);
|
||||
|
||||
char Command[NM+16];
|
||||
wchar CommandW[NM+16];
|
||||
|
||||
char ArcName[NM];
|
||||
wchar ArcNameW[NM];
|
||||
|
||||
StringList *FileArgs;
|
||||
StringList *ExclArgs;
|
||||
StringList *InclArgs;
|
||||
StringList *ArcNames;
|
||||
StringList *StoreArgs;
|
||||
};
|
||||
|
||||
#endif
|
|
@ -0,0 +1,48 @@
|
|||
|
||||
|
||||
inline unsigned int RangeCoder::GetChar()
|
||||
{
|
||||
return(UnpackRead->GetChar());
|
||||
}
|
||||
|
||||
|
||||
void RangeCoder::InitDecoder(Unpack *UnpackRead)
|
||||
{
|
||||
RangeCoder::UnpackRead=UnpackRead;
|
||||
|
||||
low=code=0;
|
||||
range=uint(-1);
|
||||
for (int i=0;i < 4;i++)
|
||||
code=(code << 8) | GetChar();
|
||||
}
|
||||
|
||||
|
||||
// (int) cast before "low" added only to suppress compiler warnings.
|
||||
#define ARI_DEC_NORMALIZE(code,low,range,read) \
|
||||
{ \
|
||||
while ((low^(low+range))<TOP || range<BOT && ((range=-(int)low&(BOT-1)),1)) \
|
||||
{ \
|
||||
code=(code << 8) | read->GetChar(); \
|
||||
range <<= 8; \
|
||||
low <<= 8; \
|
||||
} \
|
||||
}
|
||||
|
||||
|
||||
inline int RangeCoder::GetCurrentCount()
|
||||
{
|
||||
return (code-low)/(range /= SubRange.scale);
|
||||
}
|
||||
|
||||
|
||||
inline uint RangeCoder::GetCurrentShiftCount(uint SHIFT)
|
||||
{
|
||||
return (code-low)/(range >>= SHIFT);
|
||||
}
|
||||
|
||||
|
||||
inline void RangeCoder::Decode()
|
||||
{
|
||||
low += range*SubRange.LowCount;
|
||||
range *= SubRange.HighCount-SubRange.LowCount;
|
||||
}
|
|
@ -0,0 +1,24 @@
|
|||
/****************************************************************************
|
||||
* Contents: 'Carryless rangecoder' by Dmitry Subbotin *
|
||||
****************************************************************************/
|
||||
|
||||
const uint TOP=1 << 24, BOT=1 << 15;
|
||||
|
||||
class RangeCoder
|
||||
{
|
||||
public:
|
||||
void InitDecoder(Unpack *UnpackRead);
|
||||
inline int GetCurrentCount();
|
||||
inline uint GetCurrentShiftCount(uint SHIFT);
|
||||
inline void Decode();
|
||||
inline void PutChar(unsigned int c);
|
||||
inline unsigned int GetChar();
|
||||
|
||||
uint low, code, range;
|
||||
struct SUBRANGE
|
||||
{
|
||||
uint LowCount, HighCount, scale;
|
||||
} SubRange;
|
||||
|
||||
Unpack *UnpackRead;
|
||||
};
|
|
@ -0,0 +1,36 @@
|
|||
#ifndef _RAR_COMPRESS_
|
||||
#define _RAR_COMPRESS_
|
||||
|
||||
class ComprDataIO;
|
||||
class PackingFileTable;
|
||||
|
||||
#define CODEBUFSIZE 0x4000
|
||||
#define MAXWINSIZE 0x400000
|
||||
#define MAXWINMASK (MAXWINSIZE-1)
|
||||
|
||||
#define LOW_DIST_REP_COUNT 16
|
||||
|
||||
#define NC 299 /* alphabet = {0, 1, 2, ..., NC - 1} */
|
||||
#define DC 60
|
||||
#define LDC 17
|
||||
#define RC 28
|
||||
#define HUFF_TABLE_SIZE (NC+DC+RC+LDC)
|
||||
#define BC 20
|
||||
|
||||
#define NC20 298 /* alphabet = {0, 1, 2, ..., NC - 1} */
|
||||
#define DC20 48
|
||||
#define RC20 28
|
||||
#define BC20 19
|
||||
#define MC20 257
|
||||
|
||||
enum {CODE_HUFFMAN,CODE_LZ,CODE_LZ2,CODE_REPEATLZ,CODE_CACHELZ,
|
||||
CODE_STARTFILE,CODE_ENDFILE,CODE_VM,CODE_VMDATA};
|
||||
|
||||
|
||||
enum FilterType {
|
||||
FILTER_NONE, FILTER_PPM /*dummy*/, FILTER_E8, FILTER_E8E9,
|
||||
FILTER_UPCASETOLOW, FILTER_AUDIO, FILTER_RGB, FILTER_DELTA,
|
||||
FILTER_ITANIUM, FILTER_E8E9V2
|
||||
};
|
||||
|
||||
#endif
|
|
@ -0,0 +1,294 @@
|
|||
#include "rar.hpp"
|
||||
|
||||
#ifndef GUI
|
||||
#include "log.cpp"
|
||||
#endif
|
||||
|
||||
static int KbdAnsi(char *Addr,int Size);
|
||||
|
||||
#if !defined(GUI) && !defined(SILENT)
|
||||
static void RawPrint(char *Msg,MESSAGE_TYPE MessageType);
|
||||
static uint GetKey();
|
||||
#endif
|
||||
|
||||
static MESSAGE_TYPE MsgStream=MSG_STDOUT;
|
||||
static bool Sound=false;
|
||||
const int MaxMsgSize=2*NM+2048;
|
||||
|
||||
void InitConsoleOptions(MESSAGE_TYPE MsgStream,bool Sound)
|
||||
{
|
||||
::MsgStream=MsgStream;
|
||||
::Sound=Sound;
|
||||
}
|
||||
|
||||
#if !defined(GUI) && !defined(SILENT)
|
||||
void mprintf(const char *fmt,...)
|
||||
{
|
||||
if (MsgStream==MSG_NULL || MsgStream==MSG_ERRONLY)
|
||||
return;
|
||||
safebuf char Msg[MaxMsgSize];
|
||||
va_list argptr;
|
||||
va_start(argptr,fmt);
|
||||
vsprintf(Msg,fmt,argptr);
|
||||
RawPrint(Msg,MsgStream);
|
||||
va_end(argptr);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
#if !defined(GUI) && !defined(SILENT)
|
||||
void eprintf(const char *fmt,...)
|
||||
{
|
||||
if (MsgStream==MSG_NULL)
|
||||
return;
|
||||
safebuf char Msg[MaxMsgSize];
|
||||
va_list argptr;
|
||||
va_start(argptr,fmt);
|
||||
vsprintf(Msg,fmt,argptr);
|
||||
RawPrint(Msg,MSG_STDERR);
|
||||
va_end(argptr);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
#if !defined(GUI) && !defined(SILENT)
|
||||
void RawPrint(char *Msg,MESSAGE_TYPE MessageType)
|
||||
{
|
||||
File OutFile;
|
||||
switch(MessageType)
|
||||
{
|
||||
case MSG_STDOUT:
|
||||
OutFile.SetHandleType(FILE_HANDLESTD);
|
||||
break;
|
||||
case MSG_STDERR:
|
||||
case MSG_ERRONLY:
|
||||
OutFile.SetHandleType(FILE_HANDLEERR);
|
||||
break;
|
||||
default:
|
||||
return;
|
||||
}
|
||||
#ifdef _WIN_32
|
||||
CharToOem(Msg,Msg);
|
||||
|
||||
char OutMsg[MaxMsgSize],*OutPos=OutMsg;
|
||||
for (int I=0;Msg[I]!=0;I++)
|
||||
{
|
||||
if (Msg[I]=='\n' && (I==0 || Msg[I-1]!='\r'))
|
||||
*(OutPos++)='\r';
|
||||
*(OutPos++)=Msg[I];
|
||||
}
|
||||
*OutPos=0;
|
||||
strcpy(Msg,OutMsg);
|
||||
#endif
|
||||
#if defined(_UNIX) || defined(_EMX)
|
||||
char OutMsg[MaxMsgSize],*OutPos=OutMsg;
|
||||
for (int I=0;Msg[I]!=0;I++)
|
||||
if (Msg[I]!='\r')
|
||||
*(OutPos++)=Msg[I];
|
||||
*OutPos=0;
|
||||
strcpy(Msg,OutMsg);
|
||||
#endif
|
||||
|
||||
OutFile.Write(Msg,strlen(Msg));
|
||||
// OutFile.Flush();
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
#ifndef SILENT
|
||||
void Alarm()
|
||||
{
|
||||
#ifndef SFX_MODULE
|
||||
if (Sound)
|
||||
putchar('\007');
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
#ifndef SILENT
|
||||
#ifndef GUI
|
||||
void GetPasswordText(char *Str,int MaxLength)
|
||||
{
|
||||
#ifdef _WIN_32
|
||||
HANDLE hConIn=GetStdHandle(STD_INPUT_HANDLE);
|
||||
HANDLE hConOut=GetStdHandle(STD_OUTPUT_HANDLE);
|
||||
DWORD ConInMode,ConOutMode;
|
||||
DWORD Read=0;
|
||||
GetConsoleMode(hConIn,&ConInMode);
|
||||
GetConsoleMode(hConOut,&ConOutMode);
|
||||
SetConsoleMode(hConIn,ENABLE_LINE_INPUT);
|
||||
SetConsoleMode(hConOut,ENABLE_PROCESSED_OUTPUT|ENABLE_WRAP_AT_EOL_OUTPUT);
|
||||
ReadConsole(hConIn,Str,MaxLength-1,&Read,NULL);
|
||||
Str[Read]=0;
|
||||
OemToChar(Str,Str);
|
||||
SetConsoleMode(hConIn,ConInMode);
|
||||
SetConsoleMode(hConOut,ConOutMode);
|
||||
#elif defined(_EMX) || defined(_BEOS) || defined(__sparc) || defined(sparc) || defined (__VMS)
|
||||
fgets(Str,MaxLength-1,stdin);
|
||||
#else
|
||||
strncpyz(Str,getpass(""),MaxLength);
|
||||
#endif
|
||||
Str[MaxLength-1]=0;
|
||||
RemoveLF(Str);
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
||||
#ifndef SILENT
|
||||
bool GetPassword(PASSWORD_TYPE Type,const char *FileName,char *Password,int MaxLength)
|
||||
{
|
||||
Alarm();
|
||||
while (true)
|
||||
{
|
||||
char PromptStr[NM+256];
|
||||
#if defined(_EMX) || defined(_BEOS)
|
||||
strcpy(PromptStr,St(MAskPswEcho));
|
||||
#else
|
||||
strcpy(PromptStr,St(MAskPsw));
|
||||
#endif
|
||||
if (Type!=PASSWORD_GLOBAL)
|
||||
{
|
||||
strcat(PromptStr,St(MFor));
|
||||
char *NameOnly=PointToName(FileName);
|
||||
if (strlen(PromptStr)+strlen(NameOnly)<ASIZE(PromptStr))
|
||||
strcat(PromptStr,NameOnly);
|
||||
}
|
||||
eprintf("\n%s: ",PromptStr);
|
||||
GetPasswordText(Password,MaxLength);
|
||||
if (*Password==0 && Type==PASSWORD_GLOBAL)
|
||||
return(false);
|
||||
if (Type==PASSWORD_GLOBAL)
|
||||
{
|
||||
eprintf(St(MReAskPsw));
|
||||
char CmpStr[MAXPASSWORD];
|
||||
GetPasswordText(CmpStr,ASIZE(CmpStr));
|
||||
if (*CmpStr==0 || strcmp(Password,CmpStr)!=0)
|
||||
{
|
||||
eprintf(St(MNotMatchPsw));
|
||||
memset(Password,0,MaxLength);
|
||||
memset(CmpStr,0,sizeof(CmpStr));
|
||||
continue;
|
||||
}
|
||||
memset(CmpStr,0,sizeof(CmpStr));
|
||||
}
|
||||
break;
|
||||
}
|
||||
return(true);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
#if !defined(GUI) && !defined(SILENT)
|
||||
uint GetKey()
|
||||
{
|
||||
char Str[80];
|
||||
bool EndOfFile;
|
||||
#if defined(__GNUC__) || defined(sun)
|
||||
EndOfFile=(fgets(Str,sizeof(Str),stdin)==NULL);
|
||||
#else
|
||||
File SrcFile;
|
||||
SrcFile.SetHandleType(FILE_HANDLESTD);
|
||||
EndOfFile=(SrcFile.Read(Str,sizeof(Str))==0);
|
||||
#endif
|
||||
if (EndOfFile)
|
||||
{
|
||||
// Looks like stdin is a null device. We can enter to infinite loop
|
||||
// calling Ask(), so let's better exit.
|
||||
ErrHandler.Exit(USER_BREAK);
|
||||
}
|
||||
return(Str[0]);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
#if !defined(GUI) && !defined(SILENT)
|
||||
int Ask(const char *AskStr)
|
||||
{
|
||||
const int MaxItems=10;
|
||||
char Item[MaxItems][40];
|
||||
int ItemKeyPos[MaxItems],NumItems=0;
|
||||
|
||||
for (const char *NextItem=AskStr;NextItem!=NULL;NextItem=strchr(NextItem+1,'_'))
|
||||
{
|
||||
char *CurItem=Item[NumItems];
|
||||
strncpyz(CurItem,NextItem+1,ASIZE(Item[0]));
|
||||
char *EndItem=strchr(CurItem,'_');
|
||||
if (EndItem!=NULL)
|
||||
*EndItem=0;
|
||||
int KeyPos=0,CurKey;
|
||||
while ((CurKey=CurItem[KeyPos])!=0)
|
||||
{
|
||||
bool Found=false;
|
||||
for (int I=0;I<NumItems && !Found;I++)
|
||||
if (loctoupper(Item[I][ItemKeyPos[I]])==loctoupper(CurKey))
|
||||
Found=true;
|
||||
if (!Found && CurKey!=' ')
|
||||
break;
|
||||
KeyPos++;
|
||||
}
|
||||
ItemKeyPos[NumItems]=KeyPos;
|
||||
NumItems++;
|
||||
}
|
||||
|
||||
for (int I=0;I<NumItems;I++)
|
||||
{
|
||||
eprintf(I==0 ? (NumItems>4 ? "\n":" "):", ");
|
||||
int KeyPos=ItemKeyPos[I];
|
||||
for (int J=0;J<KeyPos;J++)
|
||||
eprintf("%c",Item[I][J]);
|
||||
eprintf("[%c]%s",Item[I][KeyPos],&Item[I][KeyPos+1]);
|
||||
}
|
||||
eprintf(" ");
|
||||
int Ch=GetKey();
|
||||
#if defined(_WIN_32)
|
||||
OemToCharBuff((LPCSTR)&Ch,(LPTSTR)&Ch,1);
|
||||
#endif
|
||||
Ch=loctoupper(Ch);
|
||||
for (int I=0;I<NumItems;I++)
|
||||
if (Ch==Item[I][ItemKeyPos[I]])
|
||||
return(I+1);
|
||||
return(0);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
int KbdAnsi(char *Addr,size_t Size)
|
||||
{
|
||||
int RetCode=0;
|
||||
#ifndef GUI
|
||||
for (size_t I=0;I<Size;I++)
|
||||
if (Addr[I]==27 && Addr[I+1]=='[')
|
||||
{
|
||||
for (size_t J=I+2;J<Size;J++)
|
||||
{
|
||||
if (Addr[J]=='\"')
|
||||
return(2);
|
||||
if (!IsDigit(Addr[J]) && Addr[J]!=';')
|
||||
break;
|
||||
}
|
||||
RetCode=1;
|
||||
}
|
||||
#endif
|
||||
return(RetCode);
|
||||
}
|
||||
|
||||
|
||||
void OutComment(char *Comment,size_t Size)
|
||||
{
|
||||
#ifndef GUI
|
||||
if (KbdAnsi(Comment,Size)==2)
|
||||
return;
|
||||
const size_t MaxOutSize=0x400;
|
||||
for (size_t I=0;I<Size;I+=MaxOutSize)
|
||||
{
|
||||
char Msg[MaxOutSize+1];
|
||||
size_t CopySize=Min(MaxOutSize,Size-I);
|
||||
strncpy(Msg,Comment+I,CopySize);
|
||||
Msg[CopySize]=0;
|
||||
mprintf("%s",Msg);
|
||||
}
|
||||
mprintf("\n");
|
||||
#endif
|
||||
}
|
|
@ -0,0 +1,46 @@
|
|||
#ifndef _RAR_CONSIO_
|
||||
#define _RAR_CONSIO_
|
||||
|
||||
#if !defined(SILENT) && !defined(SFX_MODULE)
|
||||
enum {SOUND_OK,SOUND_ALARM,SOUND_ERROR,SOUND_QUESTION};
|
||||
#endif
|
||||
|
||||
enum PASSWORD_TYPE {PASSWORD_GLOBAL,PASSWORD_FILE,PASSWORD_ARCHIVE};
|
||||
|
||||
void InitConsoleOptions(MESSAGE_TYPE MsgStream,bool Sound);
|
||||
|
||||
#ifndef SILENT
|
||||
void mprintf(const char *fmt,...);
|
||||
void eprintf(const char *fmt,...);
|
||||
void Alarm();
|
||||
void GetPasswordText(char *Str,int MaxLength);
|
||||
bool GetPassword(PASSWORD_TYPE Type,const char *FileName,char *Password,int MaxLength);
|
||||
int Ask(const char *AskStr);
|
||||
#endif
|
||||
|
||||
void OutComment(char *Comment,size_t Size);
|
||||
|
||||
#ifdef SILENT
|
||||
#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);}
|
||||
inline bool GetPassword(PASSWORD_TYPE Type,const char *FileName,char *Password,int MaxLength) {return(false);}
|
||||
inline int Ask(const char *AskStr) {return(0);}
|
||||
#endif
|
||||
|
||||
#endif
|
|
@ -0,0 +1,63 @@
|
|||
#include "rar.hpp"
|
||||
|
||||
uint CRCTab[256];
|
||||
|
||||
void InitCRC()
|
||||
{
|
||||
for (int I=0;I<256;I++)
|
||||
{
|
||||
uint C=I;
|
||||
for (int J=0;J<8;J++)
|
||||
C=(C & 1) ? (C>>1)^0xEDB88320L : (C>>1);
|
||||
CRCTab[I]=C;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
uint CRC(uint StartCRC,const void *Addr,size_t Size)
|
||||
{
|
||||
if (CRCTab[1]==0)
|
||||
InitCRC();
|
||||
byte *Data=(byte *)Addr;
|
||||
|
||||
#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--;
|
||||
Data++;
|
||||
}
|
||||
while (Size>=8)
|
||||
{
|
||||
StartCRC^=*(uint32 *)Data;
|
||||
StartCRC=CRCTab[(byte)StartCRC]^(StartCRC>>8);
|
||||
StartCRC=CRCTab[(byte)StartCRC]^(StartCRC>>8);
|
||||
StartCRC=CRCTab[(byte)StartCRC]^(StartCRC>>8);
|
||||
StartCRC=CRCTab[(byte)StartCRC]^(StartCRC>>8);
|
||||
StartCRC^=*(uint32 *)(Data+4);
|
||||
StartCRC=CRCTab[(byte)StartCRC]^(StartCRC>>8);
|
||||
StartCRC=CRCTab[(byte)StartCRC]^(StartCRC>>8);
|
||||
StartCRC=CRCTab[(byte)StartCRC]^(StartCRC>>8);
|
||||
StartCRC=CRCTab[(byte)StartCRC]^(StartCRC>>8);
|
||||
Data+=8;
|
||||
Size-=8;
|
||||
}
|
||||
#endif
|
||||
|
||||
for (size_t I=0;I<Size;I++)
|
||||
StartCRC=CRCTab[(byte)(StartCRC^Data[I])]^(StartCRC>>8);
|
||||
return(StartCRC);
|
||||
}
|
||||
|
||||
#ifndef SFX_MODULE
|
||||
ushort OldCRC(ushort StartCRC,const void *Addr,size_t Size)
|
||||
{
|
||||
byte *Data=(byte *)Addr;
|
||||
for (size_t I=0;I<Size;I++)
|
||||
{
|
||||
StartCRC=(StartCRC+Data[I])&0xffff;
|
||||
StartCRC=((StartCRC<<1)|(StartCRC>>15))&0xffff;
|
||||
}
|
||||
return(StartCRC);
|
||||
}
|
||||
#endif
|
|
@ -0,0 +1,10 @@
|
|||
#ifndef _RAR_CRC_
|
||||
#define _RAR_CRC_
|
||||
|
||||
extern uint CRCTab[256];
|
||||
|
||||
void InitCRC();
|
||||
uint CRC(uint StartCRC,const void *Addr,size_t Size);
|
||||
ushort OldCRC(ushort StartCRC,const void *Addr,size_t Size);
|
||||
|
||||
#endif
|
|
@ -0,0 +1,381 @@
|
|||
#include "rar.hpp"
|
||||
|
||||
#ifndef SFX_MODULE
|
||||
extern uint CRCTab[256];
|
||||
#endif
|
||||
|
||||
#define NROUNDS 32
|
||||
|
||||
#define rol(x,n,xsize) (((x)<<(n)) | ((x)>>(xsize-(n))))
|
||||
#define ror(x,n,xsize) (((x)>>(n)) | ((x)<<(xsize-(n))))
|
||||
|
||||
#define substLong(t) ( (uint)SubstTable[(uint)t&255] | \
|
||||
((uint)SubstTable[(int)(t>> 8)&255]<< 8) | \
|
||||
((uint)SubstTable[(int)(t>>16)&255]<<16) | \
|
||||
((uint)SubstTable[(int)(t>>24)&255]<<24) )
|
||||
|
||||
CryptKeyCacheItem CryptData::Cache[4];
|
||||
int CryptData::CachePos=0;
|
||||
|
||||
|
||||
#ifndef SFX_MODULE
|
||||
static byte InitSubstTable[256]={
|
||||
215, 19,149, 35, 73,197,192,205,249, 28, 16,119, 48,221, 2, 42,
|
||||
232, 1,177,233, 14, 88,219, 25,223,195,244, 90, 87,239,153,137,
|
||||
255,199,147, 70, 92, 66,246, 13,216, 40, 62, 29,217,230, 86, 6,
|
||||
71, 24,171,196,101,113,218,123, 93, 91,163,178,202, 67, 44,235,
|
||||
107,250, 75,234, 49,167,125,211, 83,114,157,144, 32,193,143, 36,
|
||||
158,124,247,187, 89,214,141, 47,121,228, 61,130,213,194,174,251,
|
||||
97,110, 54,229,115, 57,152, 94,105,243,212, 55,209,245, 63, 11,
|
||||
164,200, 31,156, 81,176,227, 21, 76, 99,139,188,127, 17,248, 51,
|
||||
207,120,189,210, 8,226, 41, 72,183,203,135,165,166, 60, 98, 7,
|
||||
122, 38,155,170, 69,172,252,238, 39,134, 59,128,236, 27,240, 80,
|
||||
131, 3, 85,206,145, 79,154,142,159,220,201,133, 74, 64, 20,129,
|
||||
224,185,138,103,173,182, 43, 34,254, 82,198,151,231,180, 58, 10,
|
||||
118, 26,102, 12, 50,132, 22,191,136,111,162,179, 45, 4,148,108,
|
||||
161, 56, 78,126,242,222, 15,175,146, 23, 33,241,181,190, 77,225,
|
||||
0, 46,169,186, 68, 95,237, 65, 53,208,253,168, 9, 18,100, 52,
|
||||
116,184,160, 96,109, 37, 30,106,140,104,150, 5,204,117,112, 84
|
||||
};
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
void CryptData::DecryptBlock(byte *Buf,size_t Size)
|
||||
{
|
||||
rin.blockDecrypt(Buf,Size,Buf);
|
||||
}
|
||||
|
||||
|
||||
#ifndef SFX_MODULE
|
||||
void CryptData::EncryptBlock20(byte *Buf)
|
||||
{
|
||||
uint A,B,C,D,T,TA,TB;
|
||||
#if defined(BIG_ENDIAN) || !defined(PRESENT_INT32) || !defined(ALLOW_NOT_ALIGNED_INT)
|
||||
A=((uint)Buf[0]|((uint)Buf[1]<<8)|((uint)Buf[2]<<16)|((uint)Buf[3]<<24))^Key[0];
|
||||
B=((uint)Buf[4]|((uint)Buf[5]<<8)|((uint)Buf[6]<<16)|((uint)Buf[7]<<24))^Key[1];
|
||||
C=((uint)Buf[8]|((uint)Buf[9]<<8)|((uint)Buf[10]<<16)|((uint)Buf[11]<<24))^Key[2];
|
||||
D=((uint)Buf[12]|((uint)Buf[13]<<8)|((uint)Buf[14]<<16)|((uint)Buf[15]<<24))^Key[3];
|
||||
#else
|
||||
uint32 *BufPtr=(uint32 *)Buf;
|
||||
A=BufPtr[0]^Key[0];
|
||||
B=BufPtr[1]^Key[1];
|
||||
C=BufPtr[2]^Key[2];
|
||||
D=BufPtr[3]^Key[3];
|
||||
#endif
|
||||
for(int I=0;I<NROUNDS;I++)
|
||||
{
|
||||
T=((C+rol(D,11,32))^Key[I&3]);
|
||||
TA=A^substLong(T);
|
||||
T=((D^rol(C,17,32))+Key[I&3]);
|
||||
TB=B^substLong(T);
|
||||
A=C;
|
||||
B=D;
|
||||
C=TA;
|
||||
D=TB;
|
||||
}
|
||||
#if defined(BIG_ENDIAN) || !defined(PRESENT_INT32) || !defined(ALLOW_NOT_ALIGNED_INT)
|
||||
C^=Key[0];
|
||||
Buf[0]=(byte)C;
|
||||
Buf[1]=(byte)(C>>8);
|
||||
Buf[2]=(byte)(C>>16);
|
||||
Buf[3]=(byte)(C>>24);
|
||||
D^=Key[1];
|
||||
Buf[4]=(byte)D;
|
||||
Buf[5]=(byte)(D>>8);
|
||||
Buf[6]=(byte)(D>>16);
|
||||
Buf[7]=(byte)(D>>24);
|
||||
A^=Key[2];
|
||||
Buf[8]=(byte)A;
|
||||
Buf[9]=(byte)(A>>8);
|
||||
Buf[10]=(byte)(A>>16);
|
||||
Buf[11]=(byte)(A>>24);
|
||||
B^=Key[3];
|
||||
Buf[12]=(byte)B;
|
||||
Buf[13]=(byte)(B>>8);
|
||||
Buf[14]=(byte)(B>>16);
|
||||
Buf[15]=(byte)(B>>24);
|
||||
#else
|
||||
BufPtr[0]=C^Key[0];
|
||||
BufPtr[1]=D^Key[1];
|
||||
BufPtr[2]=A^Key[2];
|
||||
BufPtr[3]=B^Key[3];
|
||||
#endif
|
||||
UpdKeys(Buf);
|
||||
}
|
||||
|
||||
|
||||
void CryptData::DecryptBlock20(byte *Buf)
|
||||
{
|
||||
byte InBuf[16];
|
||||
uint A,B,C,D,T,TA,TB;
|
||||
#if defined(BIG_ENDIAN) || !defined(PRESENT_INT32) || !defined(ALLOW_NOT_ALIGNED_INT)
|
||||
A=((uint)Buf[0]|((uint)Buf[1]<<8)|((uint)Buf[2]<<16)|((uint)Buf[3]<<24))^Key[0];
|
||||
B=((uint)Buf[4]|((uint)Buf[5]<<8)|((uint)Buf[6]<<16)|((uint)Buf[7]<<24))^Key[1];
|
||||
C=((uint)Buf[8]|((uint)Buf[9]<<8)|((uint)Buf[10]<<16)|((uint)Buf[11]<<24))^Key[2];
|
||||
D=((uint)Buf[12]|((uint)Buf[13]<<8)|((uint)Buf[14]<<16)|((uint)Buf[15]<<24))^Key[3];
|
||||
#else
|
||||
uint32 *BufPtr=(uint32 *)Buf;
|
||||
A=BufPtr[0]^Key[0];
|
||||
B=BufPtr[1]^Key[1];
|
||||
C=BufPtr[2]^Key[2];
|
||||
D=BufPtr[3]^Key[3];
|
||||
#endif
|
||||
memcpy(InBuf,Buf,sizeof(InBuf));
|
||||
for(int I=NROUNDS-1;I>=0;I--)
|
||||
{
|
||||
T=((C+rol(D,11,32))^Key[I&3]);
|
||||
TA=A^substLong(T);
|
||||
T=((D^rol(C,17,32))+Key[I&3]);
|
||||
TB=B^substLong(T);
|
||||
A=C;
|
||||
B=D;
|
||||
C=TA;
|
||||
D=TB;
|
||||
}
|
||||
#if defined(BIG_ENDIAN) || !defined(PRESENT_INT32) || !defined(ALLOW_NOT_ALIGNED_INT)
|
||||
C^=Key[0];
|
||||
Buf[0]=(byte)C;
|
||||
Buf[1]=(byte)(C>>8);
|
||||
Buf[2]=(byte)(C>>16);
|
||||
Buf[3]=(byte)(C>>24);
|
||||
D^=Key[1];
|
||||
Buf[4]=(byte)D;
|
||||
Buf[5]=(byte)(D>>8);
|
||||
Buf[6]=(byte)(D>>16);
|
||||
Buf[7]=(byte)(D>>24);
|
||||
A^=Key[2];
|
||||
Buf[8]=(byte)A;
|
||||
Buf[9]=(byte)(A>>8);
|
||||
Buf[10]=(byte)(A>>16);
|
||||
Buf[11]=(byte)(A>>24);
|
||||
B^=Key[3];
|
||||
Buf[12]=(byte)B;
|
||||
Buf[13]=(byte)(B>>8);
|
||||
Buf[14]=(byte)(B>>16);
|
||||
Buf[15]=(byte)(B>>24);
|
||||
#else
|
||||
BufPtr[0]=C^Key[0];
|
||||
BufPtr[1]=D^Key[1];
|
||||
BufPtr[2]=A^Key[2];
|
||||
BufPtr[3]=B^Key[3];
|
||||
#endif
|
||||
UpdKeys(InBuf);
|
||||
}
|
||||
|
||||
|
||||
void CryptData::UpdKeys(byte *Buf)
|
||||
{
|
||||
for (int I=0;I<16;I+=4)
|
||||
{
|
||||
Key[0]^=CRCTab[Buf[I]];
|
||||
Key[1]^=CRCTab[Buf[I+1]];
|
||||
Key[2]^=CRCTab[Buf[I+2]];
|
||||
Key[3]^=CRCTab[Buf[I+3]];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void CryptData::Swap(byte *Ch1,byte *Ch2)
|
||||
{
|
||||
byte Ch=*Ch1;
|
||||
*Ch1=*Ch2;
|
||||
*Ch2=Ch;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
void CryptData::SetCryptKeys(const char *Password,const byte *Salt,bool Encrypt,bool OldOnly,bool HandsOffHash)
|
||||
{
|
||||
if (*Password==0)
|
||||
return;
|
||||
if (OldOnly)
|
||||
{
|
||||
#ifndef SFX_MODULE
|
||||
if (CRCTab[1]==0)
|
||||
InitCRC();
|
||||
byte Psw[MAXPASSWORD];
|
||||
SetOldKeys(Password);
|
||||
Key[0]=0xD3A3B879L;
|
||||
Key[1]=0x3F6D12F7L;
|
||||
Key[2]=0x7515A235L;
|
||||
Key[3]=0xA4E7F123L;
|
||||
memset(Psw,0,sizeof(Psw));
|
||||
#if defined(_WIN_32) && !defined(GUI)
|
||||
CharToOemBuff(Password,(char*)Psw,(DWORD)strlen(Password));
|
||||
#else
|
||||
strncpyz((char *)Psw,Password,ASIZE(Psw));
|
||||
#endif
|
||||
size_t PswLength=strlen(Password);
|
||||
memcpy(SubstTable,InitSubstTable,sizeof(SubstTable));
|
||||
for (int J=0;J<256;J++)
|
||||
for (size_t I=0;I<PswLength;I+=2)
|
||||
{
|
||||
uint N1=(byte)CRCTab[(Psw[I]-J)&0xff];
|
||||
uint N2=(byte)CRCTab[(Psw[I+1]+J)&0xff];
|
||||
for (int K=1;N1!=N2;N1=(N1+1)&0xff,K++)
|
||||
Swap(&SubstTable[N1],&SubstTable[(N1+I+K)&0xff]);
|
||||
}
|
||||
for (size_t I=0;I<PswLength;I+=16)
|
||||
EncryptBlock20(&Psw[I]);
|
||||
#endif
|
||||
return;
|
||||
}
|
||||
|
||||
bool Cached=false;
|
||||
for (int I=0;I<ASIZE(Cache);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].HandsOffHash==HandsOffHash)
|
||||
{
|
||||
memcpy(AESKey,Cache[I].AESKey,sizeof(AESKey));
|
||||
memcpy(AESInit,Cache[I].AESInit,sizeof(AESInit));
|
||||
Cached=true;
|
||||
break;
|
||||
}
|
||||
|
||||
if (!Cached)
|
||||
{
|
||||
wchar PswW[MAXPASSWORD];
|
||||
CharToWide(Password,PswW,MAXPASSWORD-1);
|
||||
PswW[MAXPASSWORD-1]=0;
|
||||
byte RawPsw[2*MAXPASSWORD+SALT_SIZE];
|
||||
WideToRaw(PswW,RawPsw);
|
||||
size_t RawLength=2*strlenw(PswW);
|
||||
if (Salt!=NULL)
|
||||
{
|
||||
memcpy(RawPsw+RawLength,Salt,SALT_SIZE);
|
||||
RawLength+=SALT_SIZE;
|
||||
}
|
||||
hash_context c;
|
||||
hash_initial(&c);
|
||||
|
||||
const int HashRounds=0x40000;
|
||||
for (int I=0;I<HashRounds;I++)
|
||||
{
|
||||
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, HandsOffHash);
|
||||
if (I%(HashRounds/16)==0)
|
||||
{
|
||||
hash_context tempc=c;
|
||||
uint32 digest[5];
|
||||
hash_final( &tempc, digest, HandsOffHash);
|
||||
AESInit[I/(HashRounds/16)]=(byte)digest[4];
|
||||
}
|
||||
}
|
||||
uint32 digest[5];
|
||||
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));
|
||||
|
||||
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]));
|
||||
}
|
||||
rin.init(Encrypt ? Rijndael::Encrypt : Rijndael::Decrypt,AESKey,AESInit);
|
||||
}
|
||||
|
||||
|
||||
#ifndef SFX_MODULE
|
||||
void CryptData::SetOldKeys(const char *Password)
|
||||
{
|
||||
uint PswCRC=CRC(0xffffffff,Password,strlen(Password));
|
||||
OldKey[0]=PswCRC&0xffff;
|
||||
OldKey[1]=(PswCRC>>16)&0xffff;
|
||||
OldKey[2]=OldKey[3]=0;
|
||||
PN1=PN2=PN3=0;
|
||||
byte Ch;
|
||||
while ((Ch=*Password)!=0)
|
||||
{
|
||||
PN1+=Ch;
|
||||
PN2^=Ch;
|
||||
PN3+=Ch;
|
||||
PN3=(byte)rol(PN3,1,8);
|
||||
OldKey[2]^=Ch^CRCTab[Ch];
|
||||
OldKey[3]+=Ch+(CRCTab[Ch]>>16);
|
||||
Password++;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void CryptData::SetAV15Encryption()
|
||||
{
|
||||
OldKey[0]=0x4765;
|
||||
OldKey[1]=0x9021;
|
||||
OldKey[2]=0x7382;
|
||||
OldKey[3]=0x5215;
|
||||
}
|
||||
|
||||
|
||||
void CryptData::SetCmt13Encryption()
|
||||
{
|
||||
PN1=0;
|
||||
PN2=7;
|
||||
PN3=77;
|
||||
}
|
||||
|
||||
|
||||
void CryptData::Crypt(byte *Data,uint Count,int Method)
|
||||
{
|
||||
if (Method==OLD_DECODE)
|
||||
Decode13(Data,Count);
|
||||
else
|
||||
if (Method==OLD_ENCODE)
|
||||
Encode13(Data,Count);
|
||||
else
|
||||
Crypt15(Data,Count);
|
||||
}
|
||||
|
||||
|
||||
void CryptData::Encode13(byte *Data,uint Count)
|
||||
{
|
||||
while (Count--)
|
||||
{
|
||||
PN2+=PN3;
|
||||
PN1+=PN2;
|
||||
*Data+=PN1;
|
||||
Data++;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void CryptData::Decode13(byte *Data,uint Count)
|
||||
{
|
||||
while (Count--)
|
||||
{
|
||||
PN2+=PN3;
|
||||
PN1+=PN2;
|
||||
*Data-=PN1;
|
||||
Data++;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void CryptData::Crypt15(byte *Data,uint Count)
|
||||
{
|
||||
while (Count--)
|
||||
{
|
||||
OldKey[0]+=0x1234;
|
||||
OldKey[1]^=CRCTab[(OldKey[0] & 0x1fe)>>1];
|
||||
OldKey[2]-=CRCTab[(OldKey[0] & 0x1fe)>>1]>>16;
|
||||
OldKey[0]^=OldKey[2];
|
||||
OldKey[3]=ror(OldKey[3]&0xffff,1,16)^OldKey[1];
|
||||
OldKey[3]=ror(OldKey[3]&0xffff,1,16);
|
||||
OldKey[0]^=OldKey[3];
|
||||
*Data^=(byte)(OldKey[0]>>8);
|
||||
Data++;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
|
|
@ -0,0 +1,62 @@
|
|||
#ifndef _RAR_CRYPT_
|
||||
#define _RAR_CRYPT_
|
||||
|
||||
enum { OLD_DECODE=0,OLD_ENCODE=1,NEW_CRYPT=2 };
|
||||
|
||||
|
||||
struct CryptKeyCacheItem
|
||||
{
|
||||
#ifndef _SFX_RTL_
|
||||
CryptKeyCacheItem()
|
||||
{
|
||||
*Password=0;
|
||||
}
|
||||
|
||||
~CryptKeyCacheItem()
|
||||
{
|
||||
memset(AESKey,0,sizeof(AESKey));
|
||||
memset(AESInit,0,sizeof(AESInit));
|
||||
memset(Password,0,sizeof(Password));
|
||||
}
|
||||
#endif
|
||||
byte AESKey[16],AESInit[16];
|
||||
char Password[MAXPASSWORD];
|
||||
bool SaltPresent;
|
||||
byte Salt[SALT_SIZE];
|
||||
bool HandsOffHash;
|
||||
};
|
||||
|
||||
class CryptData
|
||||
{
|
||||
private:
|
||||
void Encode13(byte *Data,uint Count);
|
||||
void Decode13(byte *Data,uint Count);
|
||||
void Crypt15(byte *Data,uint Count);
|
||||
void UpdKeys(byte *Buf);
|
||||
void Swap(byte *Ch1,byte *Ch2);
|
||||
void SetOldKeys(const char *Password);
|
||||
|
||||
Rijndael rin;
|
||||
|
||||
byte SubstTable[256];
|
||||
uint Key[4];
|
||||
ushort OldKey[4];
|
||||
byte PN1,PN2,PN3;
|
||||
|
||||
byte AESKey[16],AESInit[16];
|
||||
|
||||
static CryptKeyCacheItem Cache[4];
|
||||
static int CachePos;
|
||||
public:
|
||||
void SetCryptKeys(const char *Password,const byte *Salt,bool Encrypt,bool OldOnly,bool HandsOffHash);
|
||||
void SetAV15Encryption();
|
||||
void SetCmt13Encryption();
|
||||
void EncryptBlock20(byte *Buf);
|
||||
void DecryptBlock20(byte *Buf);
|
||||
void EncryptBlock(byte *Buf,size_t Size);
|
||||
void DecryptBlock(byte *Buf,size_t Size);
|
||||
void Crypt(byte *Data,uint Count,int Method);
|
||||
static void SetSalt(byte *Salt,int SaltSize);
|
||||
};
|
||||
|
||||
#endif
|
|
@ -0,0 +1,369 @@
|
|||
#include "rar.hpp"
|
||||
#include "dll.hpp"
|
||||
|
||||
static int RarErrorToDll(int ErrCode);
|
||||
|
||||
struct DataSet
|
||||
{
|
||||
CommandData Cmd;
|
||||
CmdExtract Extract;
|
||||
Archive Arc;
|
||||
int OpenMode;
|
||||
int HeaderSize;
|
||||
|
||||
DataSet():Arc(&Cmd) {};
|
||||
};
|
||||
|
||||
|
||||
HANDLE PASCAL RAROpenArchive(struct RAROpenArchiveData *r)
|
||||
{
|
||||
RAROpenArchiveDataEx rx;
|
||||
memset(&rx,0,sizeof(rx));
|
||||
rx.ArcName=r->ArcName;
|
||||
rx.OpenMode=r->OpenMode;
|
||||
rx.CmtBuf=r->CmtBuf;
|
||||
rx.CmtBufSize=r->CmtBufSize;
|
||||
HANDLE hArc=RAROpenArchiveEx(&rx);
|
||||
r->OpenResult=rx.OpenResult;
|
||||
r->CmtSize=rx.CmtSize;
|
||||
r->CmtState=rx.CmtState;
|
||||
return(hArc);
|
||||
}
|
||||
|
||||
|
||||
HANDLE PASCAL RAROpenArchiveEx(struct RAROpenArchiveDataEx *r)
|
||||
{
|
||||
try
|
||||
{
|
||||
r->OpenResult=0;
|
||||
DataSet *Data=new DataSet;
|
||||
Data->Cmd.DllError=0;
|
||||
Data->OpenMode=r->OpenMode;
|
||||
Data->Cmd.FileArgs->AddString("*");
|
||||
|
||||
char an[NM];
|
||||
if (r->ArcName==NULL && r->ArcNameW!=NULL)
|
||||
{
|
||||
WideToChar(r->ArcNameW,an,NM);
|
||||
r->ArcName=an;
|
||||
}
|
||||
|
||||
Data->Cmd.AddArcName(r->ArcName,r->ArcNameW);
|
||||
Data->Cmd.Overwrite=OVERWRITE_ALL;
|
||||
Data->Cmd.VersionControl=1;
|
||||
if (!Data->Arc.Open(r->ArcName,r->ArcNameW))
|
||||
{
|
||||
r->OpenResult=ERAR_EOPEN;
|
||||
delete Data;
|
||||
return(NULL);
|
||||
}
|
||||
if (!Data->Arc.IsArchive(false))
|
||||
{
|
||||
r->OpenResult=Data->Cmd.DllError!=0 ? Data->Cmd.DllError:ERAR_BAD_ARCHIVE;
|
||||
delete Data;
|
||||
return(NULL);
|
||||
}
|
||||
r->Flags=Data->Arc.NewMhd.Flags;
|
||||
Array<byte> CmtData;
|
||||
if (r->CmtBufSize!=0 && Data->Arc.GetComment(&CmtData,NULL))
|
||||
{
|
||||
r->Flags|=2;
|
||||
size_t Size=CmtData.Size()+1;
|
||||
r->CmtState=Size>r->CmtBufSize ? ERAR_SMALL_BUF:1;
|
||||
r->CmtSize=(uint)Min(Size,r->CmtBufSize);
|
||||
memcpy(r->CmtBuf,&CmtData[0],r->CmtSize-1);
|
||||
if (Size<=r->CmtBufSize)
|
||||
r->CmtBuf[r->CmtSize-1]=0;
|
||||
}
|
||||
else
|
||||
r->CmtState=r->CmtSize=0;
|
||||
if (Data->Arc.Signed)
|
||||
r->Flags|=0x20;
|
||||
Data->Extract.ExtractArchiveInit(&Data->Cmd,Data->Arc);
|
||||
return((HANDLE)Data);
|
||||
}
|
||||
catch (int ErrCode)
|
||||
{
|
||||
r->OpenResult=RarErrorToDll(ErrCode);
|
||||
return(NULL);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
int PASCAL RARCloseArchive(HANDLE hArcData)
|
||||
{
|
||||
DataSet *Data=(DataSet *)hArcData;
|
||||
bool Success=Data==NULL ? false:Data->Arc.Close();
|
||||
delete Data;
|
||||
return(Success ? 0:ERAR_ECLOSE);
|
||||
}
|
||||
|
||||
|
||||
int PASCAL RARReadHeader(HANDLE hArcData,struct RARHeaderData *D)
|
||||
{
|
||||
DataSet *Data=(DataSet *)hArcData;
|
||||
try
|
||||
{
|
||||
if ((Data->HeaderSize=(int)Data->Arc.SearchBlock(FILE_HEAD))<=0)
|
||||
{
|
||||
if (Data->Arc.Volume && Data->Arc.GetHeaderType()==ENDARC_HEAD &&
|
||||
(Data->Arc.EndArcHead.Flags & EARC_NEXT_VOLUME))
|
||||
if (MergeArchive(Data->Arc,NULL,false,'L'))
|
||||
{
|
||||
Data->Extract.SignatureFound=false;
|
||||
Data->Arc.Seek(Data->Arc.CurBlockPos,SEEK_SET);
|
||||
return(RARReadHeader(hArcData,D));
|
||||
}
|
||||
else
|
||||
return(ERAR_EOPEN);
|
||||
return(Data->Arc.BrokenFileHeader ? ERAR_BAD_DATA:ERAR_END_ARCHIVE);
|
||||
}
|
||||
if (Data->OpenMode==RAR_OM_LIST && (Data->Arc.NewLhd.Flags & LHD_SPLIT_BEFORE))
|
||||
{
|
||||
int Code=RARProcessFile(hArcData,RAR_SKIP,NULL,NULL);
|
||||
if (Code==0)
|
||||
return(RARReadHeader(hArcData,D));
|
||||
else
|
||||
return(Code);
|
||||
}
|
||||
strncpyz(D->ArcName,Data->Arc.FileName,ASIZE(D->ArcName));
|
||||
strncpyz(D->FileName,Data->Arc.NewLhd.FileName,ASIZE(D->FileName));
|
||||
D->Flags=Data->Arc.NewLhd.Flags;
|
||||
D->PackSize=Data->Arc.NewLhd.PackSize;
|
||||
D->UnpSize=Data->Arc.NewLhd.UnpSize;
|
||||
D->HostOS=Data->Arc.NewLhd.HostOS;
|
||||
D->FileCRC=Data->Arc.NewLhd.FileCRC;
|
||||
D->FileTime=Data->Arc.NewLhd.FileTime;
|
||||
D->UnpVer=Data->Arc.NewLhd.UnpVer;
|
||||
D->Method=Data->Arc.NewLhd.Method;
|
||||
D->FileAttr=Data->Arc.NewLhd.FileAttr;
|
||||
D->CmtSize=0;
|
||||
D->CmtState=0;
|
||||
}
|
||||
catch (int ErrCode)
|
||||
{
|
||||
return(RarErrorToDll(ErrCode));
|
||||
}
|
||||
return(0);
|
||||
}
|
||||
|
||||
|
||||
int PASCAL RARReadHeaderEx(HANDLE hArcData,struct RARHeaderDataEx *D)
|
||||
{
|
||||
DataSet *Data=(DataSet *)hArcData;
|
||||
try
|
||||
{
|
||||
if ((Data->HeaderSize=(int)Data->Arc.SearchBlock(FILE_HEAD))<=0)
|
||||
{
|
||||
if (Data->Arc.Volume && Data->Arc.GetHeaderType()==ENDARC_HEAD &&
|
||||
(Data->Arc.EndArcHead.Flags & EARC_NEXT_VOLUME))
|
||||
if (MergeArchive(Data->Arc,NULL,false,'L'))
|
||||
{
|
||||
Data->Extract.SignatureFound=false;
|
||||
Data->Arc.Seek(Data->Arc.CurBlockPos,SEEK_SET);
|
||||
return(RARReadHeaderEx(hArcData,D));
|
||||
}
|
||||
else
|
||||
return(ERAR_EOPEN);
|
||||
return(Data->Arc.BrokenFileHeader ? ERAR_BAD_DATA:ERAR_END_ARCHIVE);
|
||||
}
|
||||
if (Data->OpenMode==RAR_OM_LIST && (Data->Arc.NewLhd.Flags & LHD_SPLIT_BEFORE))
|
||||
{
|
||||
int Code=RARProcessFile(hArcData,RAR_SKIP,NULL,NULL);
|
||||
if (Code==0)
|
||||
return(RARReadHeaderEx(hArcData,D));
|
||||
else
|
||||
return(Code);
|
||||
}
|
||||
strncpyz(D->ArcName,Data->Arc.FileName,ASIZE(D->ArcName));
|
||||
if (*Data->Arc.FileNameW)
|
||||
strncpyw(D->ArcNameW,Data->Arc.FileNameW,sizeof(D->ArcNameW));
|
||||
else
|
||||
CharToWide(Data->Arc.FileName,D->ArcNameW);
|
||||
strncpyz(D->FileName,Data->Arc.NewLhd.FileName,ASIZE(D->FileName));
|
||||
if (*Data->Arc.NewLhd.FileNameW)
|
||||
strncpyw(D->FileNameW,Data->Arc.NewLhd.FileNameW,sizeof(D->FileNameW));
|
||||
else
|
||||
{
|
||||
#ifdef _WIN_32
|
||||
char AnsiName[NM];
|
||||
OemToChar(Data->Arc.NewLhd.FileName,AnsiName);
|
||||
CharToWide(AnsiName,D->FileNameW);
|
||||
#else
|
||||
CharToWide(Data->Arc.NewLhd.FileName,D->FileNameW);
|
||||
#endif
|
||||
}
|
||||
D->Flags=Data->Arc.NewLhd.Flags;
|
||||
D->PackSize=Data->Arc.NewLhd.PackSize;
|
||||
D->PackSizeHigh=Data->Arc.NewLhd.HighPackSize;
|
||||
D->UnpSize=Data->Arc.NewLhd.UnpSize;
|
||||
D->UnpSizeHigh=Data->Arc.NewLhd.HighUnpSize;
|
||||
D->HostOS=Data->Arc.NewLhd.HostOS;
|
||||
D->FileCRC=Data->Arc.NewLhd.FileCRC;
|
||||
D->FileTime=Data->Arc.NewLhd.FileTime;
|
||||
D->UnpVer=Data->Arc.NewLhd.UnpVer;
|
||||
D->Method=Data->Arc.NewLhd.Method;
|
||||
D->FileAttr=Data->Arc.NewLhd.FileAttr;
|
||||
D->CmtSize=0;
|
||||
D->CmtState=0;
|
||||
}
|
||||
catch (int ErrCode)
|
||||
{
|
||||
return(RarErrorToDll(ErrCode));
|
||||
}
|
||||
return(0);
|
||||
}
|
||||
|
||||
|
||||
int PASCAL ProcessFile(HANDLE hArcData,int Operation,char *DestPath,char *DestName,wchar *DestPathW,wchar *DestNameW)
|
||||
{
|
||||
DataSet *Data=(DataSet *)hArcData;
|
||||
try
|
||||
{
|
||||
Data->Cmd.DllError=0;
|
||||
if (Data->OpenMode==RAR_OM_LIST || Data->OpenMode==RAR_OM_LIST_INCSPLIT ||
|
||||
Operation==RAR_SKIP && !Data->Arc.Solid)
|
||||
{
|
||||
if (Data->Arc.Volume &&
|
||||
Data->Arc.GetHeaderType()==FILE_HEAD &&
|
||||
(Data->Arc.NewLhd.Flags & LHD_SPLIT_AFTER)!=0)
|
||||
if (MergeArchive(Data->Arc,NULL,false,'L'))
|
||||
{
|
||||
Data->Extract.SignatureFound=false;
|
||||
Data->Arc.Seek(Data->Arc.CurBlockPos,SEEK_SET);
|
||||
return(0);
|
||||
}
|
||||
else
|
||||
return(ERAR_EOPEN);
|
||||
Data->Arc.SeekToNext();
|
||||
}
|
||||
else
|
||||
{
|
||||
Data->Cmd.DllOpMode=Operation;
|
||||
|
||||
if (DestPath!=NULL || DestName!=NULL)
|
||||
{
|
||||
#ifdef _WIN_32
|
||||
OemToChar(NullToEmpty(DestPath),Data->Cmd.ExtrPath);
|
||||
#else
|
||||
strcpy(Data->Cmd.ExtrPath,NullToEmpty(DestPath));
|
||||
#endif
|
||||
AddEndSlash(Data->Cmd.ExtrPath);
|
||||
#ifdef _WIN_32
|
||||
OemToChar(NullToEmpty(DestName),Data->Cmd.DllDestName);
|
||||
#else
|
||||
strcpy(Data->Cmd.DllDestName,NullToEmpty(DestName));
|
||||
#endif
|
||||
}
|
||||
else
|
||||
{
|
||||
*Data->Cmd.ExtrPath=0;
|
||||
*Data->Cmd.DllDestName=0;
|
||||
}
|
||||
|
||||
if (DestPathW!=NULL || DestNameW!=NULL)
|
||||
{
|
||||
strncpyw(Data->Cmd.ExtrPathW,NullToEmpty(DestPathW),NM-2);
|
||||
AddEndSlash(Data->Cmd.ExtrPathW);
|
||||
strncpyw(Data->Cmd.DllDestNameW,NullToEmpty(DestNameW),NM-1);
|
||||
|
||||
if (*Data->Cmd.DllDestNameW!=0 && *Data->Cmd.DllDestName==0)
|
||||
WideToChar(Data->Cmd.DllDestNameW,Data->Cmd.DllDestName);
|
||||
}
|
||||
else
|
||||
{
|
||||
*Data->Cmd.ExtrPathW=0;
|
||||
*Data->Cmd.DllDestNameW=0;
|
||||
}
|
||||
|
||||
strcpy(Data->Cmd.Command,Operation==RAR_EXTRACT ? "X":"T");
|
||||
Data->Cmd.Test=Operation!=RAR_EXTRACT;
|
||||
bool Repeat=false;
|
||||
Data->Extract.ExtractCurrentFile(&Data->Cmd,Data->Arc,Data->HeaderSize,Repeat);
|
||||
|
||||
while (Data->Arc.ReadHeader()!=0 && Data->Arc.GetHeaderType()==NEWSUB_HEAD)
|
||||
{
|
||||
Data->Extract.ExtractCurrentFile(&Data->Cmd,Data->Arc,Data->HeaderSize,Repeat);
|
||||
Data->Arc.SeekToNext();
|
||||
}
|
||||
Data->Arc.Seek(Data->Arc.CurBlockPos,SEEK_SET);
|
||||
}
|
||||
}
|
||||
catch (int ErrCode)
|
||||
{
|
||||
return(RarErrorToDll(ErrCode));
|
||||
}
|
||||
return(Data->Cmd.DllError);
|
||||
}
|
||||
|
||||
|
||||
int PASCAL RARProcessFile(HANDLE hArcData,int Operation,char *DestPath,char *DestName)
|
||||
{
|
||||
return(ProcessFile(hArcData,Operation,DestPath,DestName,NULL,NULL));
|
||||
}
|
||||
|
||||
|
||||
int PASCAL RARProcessFileW(HANDLE hArcData,int Operation,wchar *DestPath,wchar *DestName)
|
||||
{
|
||||
return(ProcessFile(hArcData,Operation,NULL,NULL,DestPath,DestName));
|
||||
}
|
||||
|
||||
|
||||
void PASCAL RARSetChangeVolProc(HANDLE hArcData,CHANGEVOLPROC ChangeVolProc)
|
||||
{
|
||||
DataSet *Data=(DataSet *)hArcData;
|
||||
Data->Cmd.ChangeVolProc=ChangeVolProc;
|
||||
}
|
||||
|
||||
|
||||
void PASCAL RARSetCallback(HANDLE hArcData,UNRARCALLBACK Callback,LPARAM UserData)
|
||||
{
|
||||
DataSet *Data=(DataSet *)hArcData;
|
||||
Data->Cmd.Callback=Callback;
|
||||
Data->Cmd.UserData=UserData;
|
||||
}
|
||||
|
||||
|
||||
void PASCAL RARSetProcessDataProc(HANDLE hArcData,PROCESSDATAPROC ProcessDataProc)
|
||||
{
|
||||
DataSet *Data=(DataSet *)hArcData;
|
||||
Data->Cmd.ProcessDataProc=ProcessDataProc;
|
||||
}
|
||||
|
||||
#ifndef NOCRYPT
|
||||
void PASCAL RARSetPassword(HANDLE hArcData,char *Password)
|
||||
{
|
||||
DataSet *Data=(DataSet *)hArcData;
|
||||
strncpyz(Data->Cmd.Password,Password,ASIZE(Data->Cmd.Password));
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
int PASCAL RARGetDllVersion()
|
||||
{
|
||||
return(RAR_DLL_VERSION);
|
||||
}
|
||||
|
||||
|
||||
static int RarErrorToDll(int ErrCode)
|
||||
{
|
||||
switch(ErrCode)
|
||||
{
|
||||
case FATAL_ERROR:
|
||||
return(ERAR_EREAD);
|
||||
case CRC_ERROR:
|
||||
return(ERAR_BAD_DATA);
|
||||
case WRITE_ERROR:
|
||||
return(ERAR_EWRITE);
|
||||
case OPEN_ERROR:
|
||||
return(ERAR_EOPEN);
|
||||
case CREATE_ERROR:
|
||||
return(ERAR_ECREATE);
|
||||
case MEMORY_ERROR:
|
||||
return(ERAR_NO_MEMORY);
|
||||
case SUCCESS:
|
||||
return(0);
|
||||
default:
|
||||
return(ERAR_UNKNOWN);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,12 @@
|
|||
EXPORTS
|
||||
RAROpenArchive
|
||||
RAROpenArchiveEx
|
||||
RARCloseArchive
|
||||
RARReadHeader
|
||||
RARReadHeaderEx
|
||||
RARProcessFile
|
||||
RARSetCallback
|
||||
RARSetChangeVolProc
|
||||
RARSetProcessDataProc
|
||||
RARSetPassword
|
||||
RARGetDllVersion
|
|
@ -0,0 +1,140 @@
|
|||
#ifndef _UNRAR_DLL_
|
||||
#define _UNRAR_DLL_
|
||||
|
||||
#define ERAR_END_ARCHIVE 10
|
||||
#define ERAR_NO_MEMORY 11
|
||||
#define ERAR_BAD_DATA 12
|
||||
#define ERAR_BAD_ARCHIVE 13
|
||||
#define ERAR_UNKNOWN_FORMAT 14
|
||||
#define ERAR_EOPEN 15
|
||||
#define ERAR_ECREATE 16
|
||||
#define ERAR_ECLOSE 17
|
||||
#define ERAR_EREAD 18
|
||||
#define ERAR_EWRITE 19
|
||||
#define ERAR_SMALL_BUF 20
|
||||
#define ERAR_UNKNOWN 21
|
||||
#define ERAR_MISSING_PASSWORD 22
|
||||
|
||||
#define RAR_OM_LIST 0
|
||||
#define RAR_OM_EXTRACT 1
|
||||
#define RAR_OM_LIST_INCSPLIT 2
|
||||
|
||||
#define RAR_SKIP 0
|
||||
#define RAR_TEST 1
|
||||
#define RAR_EXTRACT 2
|
||||
|
||||
#define RAR_VOL_ASK 0
|
||||
#define RAR_VOL_NOTIFY 1
|
||||
|
||||
#define RAR_DLL_VERSION 4
|
||||
|
||||
#ifdef _UNIX
|
||||
#define CALLBACK
|
||||
#define PASCAL
|
||||
#define LONG long
|
||||
#define HANDLE void *
|
||||
#define LPARAM long
|
||||
#define UINT unsigned int
|
||||
#endif
|
||||
|
||||
struct RARHeaderData
|
||||
{
|
||||
char ArcName[260];
|
||||
char FileName[260];
|
||||
unsigned int Flags;
|
||||
unsigned int PackSize;
|
||||
unsigned int UnpSize;
|
||||
unsigned int HostOS;
|
||||
unsigned int FileCRC;
|
||||
unsigned int FileTime;
|
||||
unsigned int UnpVer;
|
||||
unsigned int Method;
|
||||
unsigned int FileAttr;
|
||||
char *CmtBuf;
|
||||
unsigned int CmtBufSize;
|
||||
unsigned int CmtSize;
|
||||
unsigned int CmtState;
|
||||
};
|
||||
|
||||
|
||||
struct RARHeaderDataEx
|
||||
{
|
||||
char ArcName[1024];
|
||||
wchar_t ArcNameW[1024];
|
||||
char FileName[1024];
|
||||
wchar_t FileNameW[1024];
|
||||
unsigned int Flags;
|
||||
unsigned int PackSize;
|
||||
unsigned int PackSizeHigh;
|
||||
unsigned int UnpSize;
|
||||
unsigned int UnpSizeHigh;
|
||||
unsigned int HostOS;
|
||||
unsigned int FileCRC;
|
||||
unsigned int FileTime;
|
||||
unsigned int UnpVer;
|
||||
unsigned int Method;
|
||||
unsigned int FileAttr;
|
||||
char *CmtBuf;
|
||||
unsigned int CmtBufSize;
|
||||
unsigned int CmtSize;
|
||||
unsigned int CmtState;
|
||||
unsigned int Reserved[1024];
|
||||
};
|
||||
|
||||
|
||||
struct RAROpenArchiveData
|
||||
{
|
||||
char *ArcName;
|
||||
unsigned int OpenMode;
|
||||
unsigned int OpenResult;
|
||||
char *CmtBuf;
|
||||
unsigned int CmtBufSize;
|
||||
unsigned int CmtSize;
|
||||
unsigned int CmtState;
|
||||
};
|
||||
|
||||
struct RAROpenArchiveDataEx
|
||||
{
|
||||
char *ArcName;
|
||||
wchar_t *ArcNameW;
|
||||
unsigned int OpenMode;
|
||||
unsigned int OpenResult;
|
||||
char *CmtBuf;
|
||||
unsigned int CmtBufSize;
|
||||
unsigned int CmtSize;
|
||||
unsigned int CmtState;
|
||||
unsigned int Flags;
|
||||
unsigned int Reserved[32];
|
||||
};
|
||||
|
||||
enum UNRARCALLBACK_MESSAGES {
|
||||
UCM_CHANGEVOLUME,UCM_PROCESSDATA,UCM_NEEDPASSWORD
|
||||
};
|
||||
|
||||
typedef int (CALLBACK *UNRARCALLBACK)(UINT msg,LPARAM UserData,LPARAM P1,LPARAM P2);
|
||||
|
||||
typedef int (PASCAL *CHANGEVOLPROC)(char *ArcName,int Mode);
|
||||
typedef int (PASCAL *PROCESSDATAPROC)(unsigned char *Addr,int Size);
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
HANDLE PASCAL RAROpenArchive(struct RAROpenArchiveData *ArchiveData);
|
||||
HANDLE PASCAL RAROpenArchiveEx(struct RAROpenArchiveDataEx *ArchiveData);
|
||||
int PASCAL RARCloseArchive(HANDLE hArcData);
|
||||
int PASCAL RARReadHeader(HANDLE hArcData,struct RARHeaderData *HeaderData);
|
||||
int PASCAL RARReadHeaderEx(HANDLE hArcData,struct RARHeaderDataEx *HeaderData);
|
||||
int PASCAL RARProcessFile(HANDLE hArcData,int Operation,char *DestPath,char *DestName);
|
||||
int PASCAL RARProcessFileW(HANDLE hArcData,int Operation,wchar_t *DestPath,wchar_t *DestName);
|
||||
void PASCAL RARSetCallback(HANDLE hArcData,UNRARCALLBACK Callback,LPARAM UserData);
|
||||
void PASCAL RARSetChangeVolProc(HANDLE hArcData,CHANGEVOLPROC ChangeVolProc);
|
||||
void PASCAL RARSetProcessDataProc(HANDLE hArcData,PROCESSDATAPROC ProcessDataProc);
|
||||
void PASCAL RARSetPassword(HANDLE hArcData,char *Password);
|
||||
int PASCAL RARGetDllVersion();
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
|
@ -0,0 +1,57 @@
|
|||
#include "rar.hpp"
|
||||
|
||||
EncodeFileName::EncodeFileName()
|
||||
{
|
||||
Flags=0;
|
||||
FlagBits=0;
|
||||
FlagsPos=0;
|
||||
DestSize=0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
void EncodeFileName::Decode(char *Name,byte *EncName,size_t EncSize,wchar *NameW,
|
||||
size_t MaxDecSize)
|
||||
{
|
||||
size_t EncPos=0,DecPos=0;
|
||||
byte HighByte=EncName[EncPos++];
|
||||
while (EncPos<EncSize && DecPos<MaxDecSize)
|
||||
{
|
||||
if (FlagBits==0)
|
||||
{
|
||||
Flags=EncName[EncPos++];
|
||||
FlagBits=8;
|
||||
}
|
||||
switch(Flags>>6)
|
||||
{
|
||||
case 0:
|
||||
NameW[DecPos++]=EncName[EncPos++];
|
||||
break;
|
||||
case 1:
|
||||
NameW[DecPos++]=EncName[EncPos++]+(HighByte<<8);
|
||||
break;
|
||||
case 2:
|
||||
NameW[DecPos++]=EncName[EncPos]+(EncName[EncPos+1]<<8);
|
||||
EncPos+=2;
|
||||
break;
|
||||
case 3:
|
||||
{
|
||||
int Length=EncName[EncPos++];
|
||||
if (Length & 0x80)
|
||||
{
|
||||
byte Correction=EncName[EncPos++];
|
||||
for (Length=(Length&0x7f)+2;Length>0 && DecPos<MaxDecSize;Length--,DecPos++)
|
||||
NameW[DecPos]=((Name[DecPos]+Correction)&0xff)+(HighByte<<8);
|
||||
}
|
||||
else
|
||||
for (Length+=2;Length>0 && DecPos<MaxDecSize;Length--,DecPos++)
|
||||
NameW[DecPos]=Name[DecPos];
|
||||
}
|
||||
break;
|
||||
}
|
||||
Flags<<=2;
|
||||
FlagBits-=2;
|
||||
}
|
||||
NameW[DecPos<MaxDecSize ? DecPos:MaxDecSize-1]=0;
|
||||
}
|
|
@ -0,0 +1,20 @@
|
|||
#ifndef _RAR_ENCNAME_
|
||||
#define _RAR_ENCNAME_
|
||||
|
||||
class EncodeFileName
|
||||
{
|
||||
private:
|
||||
void AddFlags(int Value);
|
||||
|
||||
byte *EncName;
|
||||
byte Flags;
|
||||
uint FlagBits;
|
||||
size_t FlagsPos;
|
||||
size_t DestSize;
|
||||
public:
|
||||
EncodeFileName();
|
||||
size_t Encode(char *Name,wchar *NameW,byte *EncName);
|
||||
void Decode(char *Name,byte *EncName,size_t EncSize,wchar *NameW,size_t MaxDecSize);
|
||||
};
|
||||
|
||||
#endif
|
|
@ -0,0 +1,377 @@
|
|||
#include "rar.hpp"
|
||||
|
||||
|
||||
static bool UserBreak;
|
||||
|
||||
ErrorHandler::ErrorHandler()
|
||||
{
|
||||
Clean();
|
||||
}
|
||||
|
||||
|
||||
void ErrorHandler::Clean()
|
||||
{
|
||||
ExitCode=SUCCESS;
|
||||
ErrCount=0;
|
||||
EnableBreak=true;
|
||||
Silent=false;
|
||||
DoShutdown=false;
|
||||
}
|
||||
|
||||
|
||||
void ErrorHandler::MemoryError()
|
||||
{
|
||||
MemoryErrorMsg();
|
||||
Throw(MEMORY_ERROR);
|
||||
}
|
||||
|
||||
|
||||
void ErrorHandler::OpenError(const char *FileName)
|
||||
{
|
||||
#ifndef SILENT
|
||||
OpenErrorMsg(FileName);
|
||||
Throw(OPEN_ERROR);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
void ErrorHandler::CloseError(const char *FileName)
|
||||
{
|
||||
#ifndef SILENT
|
||||
if (!UserBreak)
|
||||
{
|
||||
ErrMsg(NULL,St(MErrFClose),FileName);
|
||||
SysErrMsg();
|
||||
}
|
||||
#endif
|
||||
#if !defined(SILENT) || defined(RARDLL)
|
||||
Throw(FATAL_ERROR);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
void ErrorHandler::ReadError(const char *FileName)
|
||||
{
|
||||
#ifndef SILENT
|
||||
ReadErrorMsg(NULL,FileName);
|
||||
#endif
|
||||
#if !defined(SILENT) || defined(RARDLL)
|
||||
Throw(FATAL_ERROR);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
bool ErrorHandler::AskRepeatRead(const char *FileName)
|
||||
{
|
||||
#if !defined(SILENT) && !defined(SFX_MODULE) && !defined(_WIN_CE)
|
||||
if (!Silent)
|
||||
{
|
||||
SysErrMsg();
|
||||
mprintf("\n");
|
||||
Log(NULL,St(MErrRead),FileName);
|
||||
return(Ask(St(MRetryAbort))==1);
|
||||
}
|
||||
#endif
|
||||
return(false);
|
||||
}
|
||||
|
||||
|
||||
void ErrorHandler::WriteError(const char *ArcName,const char *FileName)
|
||||
{
|
||||
#ifndef SILENT
|
||||
WriteErrorMsg(ArcName,FileName);
|
||||
#endif
|
||||
#if !defined(SILENT) || defined(RARDLL)
|
||||
Throw(WRITE_ERROR);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
#ifdef _WIN_32
|
||||
void ErrorHandler::WriteErrorFAT(const char *FileName)
|
||||
{
|
||||
#if !defined(SILENT) && !defined(SFX_MODULE)
|
||||
SysErrMsg();
|
||||
ErrMsg(NULL,St(MNTFSRequired),FileName);
|
||||
#endif
|
||||
#if !defined(SILENT) && !defined(SFX_MODULE) || defined(RARDLL)
|
||||
Throw(WRITE_ERROR);
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
bool ErrorHandler::AskRepeatWrite(const char *FileName,bool DiskFull)
|
||||
{
|
||||
#if !defined(SILENT) && !defined(_WIN_CE)
|
||||
if (!Silent)
|
||||
{
|
||||
SysErrMsg();
|
||||
mprintf("\n");
|
||||
Log(NULL,St(DiskFull ? MNotEnoughDisk:MErrWrite),FileName);
|
||||
return(Ask(St(MRetryAbort))==1);
|
||||
}
|
||||
#endif
|
||||
return(false);
|
||||
}
|
||||
|
||||
|
||||
void ErrorHandler::SeekError(const char *FileName)
|
||||
{
|
||||
#ifndef SILENT
|
||||
if (!UserBreak)
|
||||
{
|
||||
ErrMsg(NULL,St(MErrSeek),FileName);
|
||||
SysErrMsg();
|
||||
}
|
||||
#endif
|
||||
#if !defined(SILENT) || defined(RARDLL)
|
||||
Throw(FATAL_ERROR);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
void ErrorHandler::GeneralErrMsg(const char *Msg)
|
||||
{
|
||||
#ifndef SILENT
|
||||
Log(NULL,"%s",Msg);
|
||||
SysErrMsg();
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
void ErrorHandler::MemoryErrorMsg()
|
||||
{
|
||||
#ifndef SILENT
|
||||
ErrMsg(NULL,St(MErrOutMem));
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
void ErrorHandler::OpenErrorMsg(const char *FileName)
|
||||
{
|
||||
OpenErrorMsg(NULL,FileName);
|
||||
}
|
||||
|
||||
|
||||
void ErrorHandler::OpenErrorMsg(const char *ArcName,const char *FileName)
|
||||
{
|
||||
#ifndef SILENT
|
||||
Log(ArcName && *ArcName ? ArcName:NULL,St(MCannotOpen),FileName);
|
||||
Alarm();
|
||||
SysErrMsg();
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
void ErrorHandler::CreateErrorMsg(const char *FileName)
|
||||
{
|
||||
CreateErrorMsg(NULL,FileName);
|
||||
}
|
||||
|
||||
|
||||
void ErrorHandler::CreateErrorMsg(const char *ArcName,const char *FileName)
|
||||
{
|
||||
#ifndef SILENT
|
||||
Log(ArcName && *ArcName ? ArcName:NULL,St(MCannotCreate),FileName);
|
||||
Alarm();
|
||||
#if defined(_WIN_32) && !defined(_WIN_CE) && !defined(SFX_MODULE) && defined(MAX_PATH)
|
||||
if (GetLastError()==ERROR_PATH_NOT_FOUND)
|
||||
{
|
||||
size_t NameLength=strlen(FileName);
|
||||
if (!IsFullPath(FileName))
|
||||
{
|
||||
char CurDir[NM];
|
||||
GetCurrentDirectory(sizeof(CurDir),CurDir);
|
||||
NameLength+=strlen(CurDir)+1;
|
||||
}
|
||||
if (NameLength>MAX_PATH)
|
||||
{
|
||||
Log(ArcName && *ArcName ? ArcName:NULL,St(MMaxPathLimit),MAX_PATH);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
SysErrMsg();
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
void ErrorHandler::ReadErrorMsg(const char *ArcName,const char *FileName)
|
||||
{
|
||||
#ifndef SILENT
|
||||
ErrMsg(ArcName,St(MErrRead),FileName);
|
||||
SysErrMsg();
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
void ErrorHandler::WriteErrorMsg(const char *ArcName,const char *FileName)
|
||||
{
|
||||
#ifndef SILENT
|
||||
ErrMsg(ArcName,St(MErrWrite),FileName);
|
||||
SysErrMsg();
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
void ErrorHandler::Exit(int ExitCode)
|
||||
{
|
||||
#ifndef SFX_MODULE
|
||||
Alarm();
|
||||
#endif
|
||||
Throw(ExitCode);
|
||||
}
|
||||
|
||||
|
||||
#ifndef GUI
|
||||
void ErrorHandler::ErrMsg(const char *ArcName,const char *fmt,...)
|
||||
{
|
||||
safebuf char Msg[NM+1024];
|
||||
va_list argptr;
|
||||
va_start(argptr,fmt);
|
||||
vsprintf(Msg,fmt,argptr);
|
||||
va_end(argptr);
|
||||
#ifdef _WIN_32
|
||||
if (UserBreak)
|
||||
Sleep(5000);
|
||||
#endif
|
||||
Alarm();
|
||||
if (*Msg)
|
||||
{
|
||||
Log(ArcName,"\n%s",Msg);
|
||||
mprintf("\n%s\n",St(MProgAborted));
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
void ErrorHandler::SetErrorCode(int Code)
|
||||
{
|
||||
switch(Code)
|
||||
{
|
||||
case WARNING:
|
||||
case USER_BREAK:
|
||||
if (ExitCode==SUCCESS)
|
||||
ExitCode=Code;
|
||||
break;
|
||||
case FATAL_ERROR:
|
||||
if (ExitCode==SUCCESS || ExitCode==WARNING)
|
||||
ExitCode=FATAL_ERROR;
|
||||
break;
|
||||
default:
|
||||
ExitCode=Code;
|
||||
break;
|
||||
}
|
||||
ErrCount++;
|
||||
}
|
||||
|
||||
|
||||
#if !defined(GUI) && !defined(_SFX_RTL_)
|
||||
#ifdef _WIN_32
|
||||
BOOL __stdcall ProcessSignal(DWORD SigType)
|
||||
#else
|
||||
#if defined(__sun)
|
||||
extern "C"
|
||||
#endif
|
||||
void _stdfunction ProcessSignal(int SigType)
|
||||
#endif
|
||||
{
|
||||
#ifdef _WIN_32
|
||||
if (SigType==CTRL_LOGOFF_EVENT)
|
||||
return(TRUE);
|
||||
#endif
|
||||
UserBreak=true;
|
||||
mprintf(St(MBreak));
|
||||
for (int I=0;!File::RemoveCreated() && I<3;I++)
|
||||
{
|
||||
#ifdef _WIN_32
|
||||
Sleep(100);
|
||||
#endif
|
||||
}
|
||||
#if defined(USE_RC) && !defined(SFX_MODULE) && !defined(_WIN_CE)
|
||||
ExtRes.UnloadDLL();
|
||||
#endif
|
||||
exit(USER_BREAK);
|
||||
#if defined(_WIN_32) && !defined(_MSC_VER)
|
||||
// never reached, just to avoid a compiler warning
|
||||
return(TRUE);
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
void ErrorHandler::SetSignalHandlers(bool Enable)
|
||||
{
|
||||
EnableBreak=Enable;
|
||||
#if !defined(GUI) && !defined(_SFX_RTL_)
|
||||
#ifdef _WIN_32
|
||||
SetConsoleCtrlHandler(Enable ? ProcessSignal:NULL,TRUE);
|
||||
// signal(SIGBREAK,Enable ? ProcessSignal:SIG_IGN);
|
||||
#else
|
||||
signal(SIGINT,Enable ? ProcessSignal:SIG_IGN);
|
||||
signal(SIGTERM,Enable ? ProcessSignal:SIG_IGN);
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
void ErrorHandler::Throw(int Code)
|
||||
{
|
||||
if (Code==USER_BREAK && !EnableBreak)
|
||||
return;
|
||||
ErrHandler.SetErrorCode(Code);
|
||||
#ifdef ALLOW_EXCEPTIONS
|
||||
throw Code;
|
||||
#else
|
||||
File::RemoveCreated();
|
||||
exit(Code);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
void ErrorHandler::SysErrMsg()
|
||||
{
|
||||
#if !defined(SFX_MODULE) && !defined(SILENT)
|
||||
#ifdef _WIN_32
|
||||
#define STRCHR strchr
|
||||
#define ERRCHAR char
|
||||
ERRCHAR *lpMsgBuf=NULL;
|
||||
int ErrType=GetLastError();
|
||||
if (ErrType!=0 && FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER|FORMAT_MESSAGE_FROM_SYSTEM,
|
||||
NULL,ErrType,MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
|
||||
(LPTSTR)&lpMsgBuf,0,NULL))
|
||||
{
|
||||
ERRCHAR *CurMsg=lpMsgBuf;
|
||||
while (CurMsg!=NULL)
|
||||
{
|
||||
while (*CurMsg=='\r' || *CurMsg=='\n')
|
||||
CurMsg++;
|
||||
if (*CurMsg==0)
|
||||
break;
|
||||
ERRCHAR *EndMsg=STRCHR(CurMsg,'\r');
|
||||
if (EndMsg==NULL)
|
||||
EndMsg=STRCHR(CurMsg,'\n');
|
||||
if (EndMsg!=NULL)
|
||||
{
|
||||
*EndMsg=0;
|
||||
EndMsg++;
|
||||
}
|
||||
Log(NULL,"\n%s",CurMsg);
|
||||
CurMsg=EndMsg;
|
||||
}
|
||||
}
|
||||
LocalFree( lpMsgBuf );
|
||||
#endif
|
||||
|
||||
#if defined(_UNIX) || defined(_EMX)
|
||||
char *err=strerror(errno);
|
||||
if (err!=NULL)
|
||||
Log(NULL,"\n%s",err);
|
||||
#endif
|
||||
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
|
@ -0,0 +1,63 @@
|
|||
#ifndef _RAR_ERRHANDLER_
|
||||
#define _RAR_ERRHANDLER_
|
||||
|
||||
#if (defined(GUI) || !defined(_WIN_32)) && !defined(SFX_MODULE) && !defined(_WIN_CE) || defined(RARDLL)
|
||||
#define ALLOW_EXCEPTIONS
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
#define rarmalloc malloc
|
||||
#define rarcalloc calloc
|
||||
#define rarrealloc realloc
|
||||
#define rarfree free
|
||||
#define rarstrdup strdup
|
||||
#define rarstrdupw strdupw
|
||||
|
||||
|
||||
|
||||
enum { SUCCESS,WARNING,FATAL_ERROR,CRC_ERROR,LOCK_ERROR,WRITE_ERROR,
|
||||
OPEN_ERROR,USER_ERROR,MEMORY_ERROR,CREATE_ERROR,USER_BREAK=255};
|
||||
|
||||
class ErrorHandler
|
||||
{
|
||||
private:
|
||||
void ErrMsg(const char *ArcName,const char *fmt,...);
|
||||
|
||||
int ExitCode;
|
||||
int ErrCount;
|
||||
bool EnableBreak;
|
||||
bool Silent;
|
||||
bool DoShutdown;
|
||||
public:
|
||||
ErrorHandler();
|
||||
void Clean();
|
||||
void MemoryError();
|
||||
void OpenError(const char *FileName);
|
||||
void CloseError(const char *FileName);
|
||||
void ReadError(const char *FileName);
|
||||
bool AskRepeatRead(const char *FileName);
|
||||
void WriteError(const char *ArcName,const char *FileName);
|
||||
void WriteErrorFAT(const char *FileName);
|
||||
bool AskRepeatWrite(const char *FileName,bool DiskFull);
|
||||
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);
|
||||
void CreateErrorMsg(const char *FileName);
|
||||
void CreateErrorMsg(const char *ArcName,const char *FileName);
|
||||
void ReadErrorMsg(const char *ArcName,const char *FileName);
|
||||
void WriteErrorMsg(const char *ArcName,const char *FileName);
|
||||
void Exit(int ExitCode);
|
||||
void SetErrorCode(int Code);
|
||||
int GetErrorCode() {return(ExitCode);}
|
||||
int GetErrorCount() {return(ErrCount);}
|
||||
void SetSignalHandlers(bool Enable);
|
||||
void Throw(int Code);
|
||||
void SetSilent(bool Mode) {Silent=Mode;};
|
||||
void SetShutdown(bool Mode) {DoShutdown=Mode;};
|
||||
void SysErrMsg();
|
||||
};
|
||||
|
||||
#endif
|
|
@ -0,0 +1,76 @@
|
|||
#include "rar.hpp"
|
||||
|
||||
#ifdef _WIN_32
|
||||
#include "win32acl.cpp"
|
||||
#include "win32stm.cpp"
|
||||
#endif
|
||||
#ifdef _BEOS
|
||||
#include "beosea.cpp"
|
||||
#endif
|
||||
#if defined(_EMX) && !defined(_DJGPP)
|
||||
#include "os2ea.cpp"
|
||||
#endif
|
||||
#ifdef _UNIX
|
||||
#include "uowners.cpp"
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
#ifndef SFX_MODULE
|
||||
void SetExtraInfo(CommandData *Cmd,Archive &Arc,char *Name,wchar *NameW)
|
||||
{
|
||||
switch(Arc.SubBlockHead.SubType)
|
||||
{
|
||||
#if defined(_EMX) && !defined(_DJGPP)
|
||||
case EA_HEAD:
|
||||
if (Cmd->ProcessEA)
|
||||
ExtractOS2EA(Arc,Name);
|
||||
break;
|
||||
#endif
|
||||
#ifdef _UNIX
|
||||
case UO_HEAD:
|
||||
if (Cmd->ProcessOwners)
|
||||
ExtractUnixOwner(Arc,Name);
|
||||
break;
|
||||
#endif
|
||||
#ifdef _BEOS
|
||||
case BEEA_HEAD:
|
||||
if (Cmd->ProcessEA)
|
||||
ExtractBeEA(Arc,Name);
|
||||
break;
|
||||
#endif
|
||||
#ifdef _WIN_32
|
||||
case NTACL_HEAD:
|
||||
if (Cmd->ProcessOwners)
|
||||
ExtractACL(Arc,Name,NameW);
|
||||
break;
|
||||
case STREAM_HEAD:
|
||||
ExtractStreams(Arc,Name,NameW);
|
||||
break;
|
||||
#endif
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
void SetExtraInfoNew(CommandData *Cmd,Archive &Arc,char *Name,wchar *NameW)
|
||||
{
|
||||
#if defined(_EMX) && !defined(_DJGPP)
|
||||
if (Cmd->ProcessEA && Arc.SubHead.CmpName(SUBHEAD_TYPE_OS2EA))
|
||||
ExtractOS2EANew(Arc,Name);
|
||||
#endif
|
||||
#ifdef _UNIX
|
||||
if (Cmd->ProcessOwners && Arc.SubHead.CmpName(SUBHEAD_TYPE_UOWNER))
|
||||
ExtractUnixOwnerNew(Arc,Name);
|
||||
#endif
|
||||
#ifdef _BEOS
|
||||
if (Cmd->ProcessEA && Arc.SubHead.CmpName(SUBHEAD_TYPE_UOWNER))
|
||||
ExtractUnixOwnerNew(Arc,Name);
|
||||
#endif
|
||||
#ifdef _WIN_32
|
||||
if (Cmd->ProcessOwners && Arc.SubHead.CmpName(SUBHEAD_TYPE_ACL))
|
||||
ExtractACLNew(Arc,Name,NameW);
|
||||
if (Arc.SubHead.CmpName(SUBHEAD_TYPE_STREAM))
|
||||
ExtractStreamsNew(Arc,Name,NameW);
|
||||
#endif
|
||||
}
|
|
@ -0,0 +1,8 @@
|
|||
#ifndef _RAR_EXTINFO_
|
||||
#define _RAR_EXTINFO_
|
||||
|
||||
|
||||
void SetExtraInfo(CommandData *Cmd,Archive &Arc,char *Name,wchar *NameW);
|
||||
void SetExtraInfoNew(CommandData *Cmd,Archive &Arc,char *Name,wchar *NameW);
|
||||
|
||||
#endif
|
|
@ -0,0 +1,928 @@
|
|||
#include "rar.hpp"
|
||||
|
||||
CmdExtract::CmdExtract()
|
||||
{
|
||||
TotalFileCount=0;
|
||||
*Password=0;
|
||||
Unp=new Unpack(&DataIO);
|
||||
Unp->Init(NULL);
|
||||
}
|
||||
|
||||
|
||||
CmdExtract::~CmdExtract()
|
||||
{
|
||||
delete Unp;
|
||||
memset(Password,0,sizeof(Password));
|
||||
}
|
||||
|
||||
|
||||
void CmdExtract::DoExtract(CommandData *Cmd)
|
||||
{
|
||||
PasswordCancelled=false;
|
||||
DataIO.SetCurrentCommand(*Cmd->Command);
|
||||
|
||||
struct FindData FD;
|
||||
while (Cmd->GetArcName(ArcName,ArcNameW,sizeof(ArcName)))
|
||||
if (FindFile::FastFind(ArcName,ArcNameW,&FD))
|
||||
DataIO.TotalArcSize+=FD.Size;
|
||||
|
||||
Cmd->ArcNames->Rewind();
|
||||
while (Cmd->GetArcName(ArcName,ArcNameW,sizeof(ArcName)))
|
||||
{
|
||||
while (true)
|
||||
{
|
||||
char PrevCmdPassword[MAXPASSWORD];
|
||||
strcpy(PrevCmdPassword,Cmd->Password);
|
||||
|
||||
EXTRACT_ARC_CODE Code=ExtractArchive(Cmd);
|
||||
|
||||
// Restore Cmd->Password, which could be changed in IsArchive() call
|
||||
// for next header encrypted archive.
|
||||
strcpy(Cmd->Password,PrevCmdPassword);
|
||||
|
||||
if (Code!=EXTRACT_ARC_REPEAT)
|
||||
break;
|
||||
}
|
||||
if (FindFile::FastFind(ArcName,ArcNameW,&FD))
|
||||
DataIO.ProcessedArcSize+=FD.Size;
|
||||
}
|
||||
|
||||
if (TotalFileCount==0 && *Cmd->Command!='I')
|
||||
{
|
||||
if (!PasswordCancelled)
|
||||
{
|
||||
mprintf(St(MExtrNoFiles));
|
||||
}
|
||||
ErrHandler.SetErrorCode(WARNING);
|
||||
}
|
||||
#ifndef GUI
|
||||
else
|
||||
if (!Cmd->DisableDone)
|
||||
if (*Cmd->Command=='I')
|
||||
mprintf(St(MDone));
|
||||
else
|
||||
if (ErrHandler.GetErrorCount()==0)
|
||||
mprintf(St(MExtrAllOk));
|
||||
else
|
||||
mprintf(St(MExtrTotalErr),ErrHandler.GetErrorCount());
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
void CmdExtract::ExtractArchiveInit(CommandData *Cmd,Archive &Arc)
|
||||
{
|
||||
DataIO.UnpArcSize=Arc.FileLength();
|
||||
|
||||
FileCount=0;
|
||||
MatchedArgs=0;
|
||||
#ifndef SFX_MODULE
|
||||
FirstFile=true;
|
||||
#endif
|
||||
|
||||
if (*Cmd->Password!=0)
|
||||
strcpy(Password,Cmd->Password);
|
||||
PasswordAll=(*Cmd->Password!=0);
|
||||
|
||||
DataIO.UnpVolume=false;
|
||||
|
||||
PrevExtracted=false;
|
||||
SignatureFound=false;
|
||||
AllMatchesExact=true;
|
||||
ReconstructDone=false;
|
||||
|
||||
StartTime.SetCurrentTime();
|
||||
}
|
||||
|
||||
|
||||
EXTRACT_ARC_CODE CmdExtract::ExtractArchive(CommandData *Cmd)
|
||||
{
|
||||
Archive Arc(Cmd);
|
||||
if (!Arc.WOpen(ArcName,ArcNameW))
|
||||
{
|
||||
ErrHandler.SetErrorCode(OPEN_ERROR);
|
||||
return(EXTRACT_ARC_NEXT);
|
||||
}
|
||||
|
||||
if (!Arc.IsArchive(true))
|
||||
{
|
||||
#ifndef GUI
|
||||
mprintf(St(MNotRAR),ArcName);
|
||||
#endif
|
||||
if (CmpExt(ArcName,"rar"))
|
||||
ErrHandler.SetErrorCode(WARNING);
|
||||
return(EXTRACT_ARC_NEXT);
|
||||
}
|
||||
|
||||
// archive with corrupt encrypted header can be closed in IsArchive() call
|
||||
if (!Arc.IsOpened())
|
||||
return(EXTRACT_ARC_NEXT);
|
||||
|
||||
#ifndef SFX_MODULE
|
||||
if (Arc.Volume && Arc.NotFirstVolume)
|
||||
{
|
||||
char FirstVolName[NM];
|
||||
VolNameToFirstName(ArcName,FirstVolName,(Arc.NewMhd.Flags & MHD_NEWNUMBERING)!=0);
|
||||
|
||||
// If several volume names from same volume set are specified
|
||||
// and current volume is not first in set and first volume is present
|
||||
// and specified too, let's skip the current volume.
|
||||
if (stricomp(ArcName,FirstVolName)!=0 && FileExist(FirstVolName) &&
|
||||
Cmd->ArcNames->Search(FirstVolName,NULL,false))
|
||||
return(EXTRACT_ARC_NEXT);
|
||||
}
|
||||
#endif
|
||||
|
||||
int64 VolumeSetSize=0; // Total size of volumes after the current volume.
|
||||
|
||||
if (Arc.Volume)
|
||||
{
|
||||
// Calculate the total size of all accessible volumes.
|
||||
// This size is necessary to display the correct total progress indicator.
|
||||
|
||||
char NextName[NM];
|
||||
wchar NextNameW[NM];
|
||||
|
||||
strcpy(NextName,Arc.FileName);
|
||||
strcpyw(NextNameW,Arc.FileNameW);
|
||||
|
||||
while (true)
|
||||
{
|
||||
// First volume is already added to DataIO.TotalArcSize
|
||||
// in initial TotalArcSize calculation in DoExtract.
|
||||
// So we skip it and start from second volume.
|
||||
NextVolumeName(NextName,NextNameW,ASIZE(NextName),(Arc.NewMhd.Flags & MHD_NEWNUMBERING)==0 || Arc.OldFormat);
|
||||
struct FindData FD;
|
||||
if (FindFile::FastFind(NextName,NextNameW,&FD))
|
||||
VolumeSetSize+=FD.Size;
|
||||
else
|
||||
break;
|
||||
}
|
||||
DataIO.TotalArcSize+=VolumeSetSize;
|
||||
}
|
||||
|
||||
ExtractArchiveInit(Cmd,Arc);
|
||||
|
||||
if (*Cmd->Command=='T' || *Cmd->Command=='I')
|
||||
Cmd->Test=true;
|
||||
|
||||
#ifndef GUI
|
||||
if (*Cmd->Command=='I')
|
||||
Cmd->DisablePercentage=true;
|
||||
else
|
||||
if (Cmd->Test)
|
||||
mprintf(St(MExtrTest),ArcName);
|
||||
else
|
||||
mprintf(St(MExtracting),ArcName);
|
||||
#endif
|
||||
|
||||
Arc.ViewComment();
|
||||
|
||||
// RAR can close a corrupt encrypted archive
|
||||
if (!Arc.IsOpened())
|
||||
return(EXTRACT_ARC_NEXT);
|
||||
|
||||
|
||||
while (1)
|
||||
{
|
||||
size_t Size=Arc.ReadHeader();
|
||||
bool Repeat=false;
|
||||
if (!ExtractCurrentFile(Cmd,Arc,Size,Repeat))
|
||||
if (Repeat)
|
||||
{
|
||||
// If we started extraction from not first volume and need to
|
||||
// restart it from first, we must correct DataIO.TotalArcSize
|
||||
// for correct total progress display. We subtract the size
|
||||
// of current volume and all volumes after it and add the size
|
||||
// of new (first) volume.
|
||||
struct FindData OldArc,NewArc;
|
||||
if (FindFile::FastFind(Arc.FileName,Arc.FileNameW,&OldArc) &&
|
||||
FindFile::FastFind(ArcName,ArcNameW,&NewArc))
|
||||
DataIO.TotalArcSize-=VolumeSetSize+OldArc.Size-NewArc.Size;
|
||||
return(EXTRACT_ARC_REPEAT);
|
||||
}
|
||||
else
|
||||
break;
|
||||
}
|
||||
|
||||
return(EXTRACT_ARC_NEXT);
|
||||
}
|
||||
|
||||
|
||||
bool CmdExtract::ExtractCurrentFile(CommandData *Cmd,Archive &Arc,size_t HeaderSize,bool &Repeat)
|
||||
{
|
||||
char Command=*Cmd->Command;
|
||||
if (HeaderSize==0)
|
||||
if (DataIO.UnpVolume)
|
||||
{
|
||||
#ifdef NOVOLUME
|
||||
return(false);
|
||||
#else
|
||||
if (!MergeArchive(Arc,&DataIO,false,Command))
|
||||
{
|
||||
ErrHandler.SetErrorCode(WARNING);
|
||||
return(false);
|
||||
}
|
||||
SignatureFound=false;
|
||||
#endif
|
||||
}
|
||||
else
|
||||
return(false);
|
||||
int HeadType=Arc.GetHeaderType();
|
||||
if (HeadType!=FILE_HEAD)
|
||||
{
|
||||
if (HeadType==AV_HEAD || HeadType==SIGN_HEAD)
|
||||
SignatureFound=true;
|
||||
#if !defined(SFX_MODULE) && !defined(_WIN_CE)
|
||||
if (HeadType==SUB_HEAD && PrevExtracted)
|
||||
SetExtraInfo(Cmd,Arc,DestFileName,*DestFileNameW ? DestFileNameW:NULL);
|
||||
#endif
|
||||
if (HeadType==NEWSUB_HEAD)
|
||||
{
|
||||
if (Arc.SubHead.CmpName(SUBHEAD_TYPE_AV))
|
||||
SignatureFound=true;
|
||||
#if !defined(NOSUBBLOCKS) && !defined(_WIN_CE)
|
||||
if (PrevExtracted)
|
||||
SetExtraInfoNew(Cmd,Arc,DestFileName,*DestFileNameW ? DestFileNameW:NULL);
|
||||
#endif
|
||||
}
|
||||
if (HeadType==ENDARC_HEAD)
|
||||
if (Arc.EndArcHead.Flags & EARC_NEXT_VOLUME)
|
||||
{
|
||||
#ifndef NOVOLUME
|
||||
if (!MergeArchive(Arc,&DataIO,false,Command))
|
||||
{
|
||||
ErrHandler.SetErrorCode(WARNING);
|
||||
return(false);
|
||||
}
|
||||
SignatureFound=false;
|
||||
#endif
|
||||
Arc.Seek(Arc.CurBlockPos,SEEK_SET);
|
||||
return(true);
|
||||
}
|
||||
else
|
||||
return(false);
|
||||
Arc.SeekToNext();
|
||||
return(true);
|
||||
}
|
||||
PrevExtracted=false;
|
||||
|
||||
if (SignatureFound ||
|
||||
!Cmd->Recurse && MatchedArgs>=Cmd->FileArgs->ItemsCount() &&
|
||||
AllMatchesExact)
|
||||
return(false);
|
||||
|
||||
char ArcFileName[NM];
|
||||
IntToExt(Arc.NewLhd.FileName,Arc.NewLhd.FileName);
|
||||
strcpy(ArcFileName,Arc.NewLhd.FileName);
|
||||
|
||||
wchar ArcFileNameW[NM];
|
||||
*ArcFileNameW=0;
|
||||
|
||||
int MatchType=MATCH_WILDSUBPATH;
|
||||
|
||||
bool EqualNames=false;
|
||||
int MatchNumber=Cmd->IsProcessFile(Arc.NewLhd,&EqualNames,MatchType);
|
||||
bool ExactMatch=MatchNumber!=0;
|
||||
#if !defined(SFX_MODULE) && !defined(_WIN_CE)
|
||||
if (Cmd->ExclPath==EXCL_BASEPATH)
|
||||
{
|
||||
*Cmd->ArcPath=0;
|
||||
if (ExactMatch)
|
||||
{
|
||||
Cmd->FileArgs->Rewind();
|
||||
if (Cmd->FileArgs->GetString(Cmd->ArcPath,NULL,sizeof(Cmd->ArcPath),MatchNumber-1))
|
||||
*PointToName(Cmd->ArcPath)=0;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
if (ExactMatch && !EqualNames)
|
||||
AllMatchesExact=false;
|
||||
|
||||
#ifdef UNICODE_SUPPORTED
|
||||
bool WideName=(Arc.NewLhd.Flags & LHD_UNICODE) && UnicodeEnabled();
|
||||
#else
|
||||
bool WideName=false;
|
||||
#endif
|
||||
|
||||
#ifdef _APPLE
|
||||
if (WideName)
|
||||
{
|
||||
WideToUtf(Arc.NewLhd.FileNameW,ArcFileName,sizeof(ArcFileName));
|
||||
WideName=false;
|
||||
}
|
||||
#endif
|
||||
|
||||
wchar *DestNameW=WideName ? DestFileNameW:NULL;
|
||||
|
||||
#ifdef UNICODE_SUPPORTED
|
||||
if (WideName)
|
||||
{
|
||||
ConvertPath(Arc.NewLhd.FileNameW,ArcFileNameW);
|
||||
char Name[NM];
|
||||
if (WideToChar(ArcFileNameW,Name) && IsNameUsable(Name))
|
||||
strcpy(ArcFileName,Name);
|
||||
}
|
||||
#endif
|
||||
|
||||
ConvertPath(ArcFileName,ArcFileName);
|
||||
|
||||
if (Arc.IsArcLabel())
|
||||
return(true);
|
||||
|
||||
if (Arc.NewLhd.Flags & LHD_VERSION)
|
||||
{
|
||||
if (Cmd->VersionControl!=1 && !EqualNames)
|
||||
{
|
||||
if (Cmd->VersionControl==0)
|
||||
ExactMatch=false;
|
||||
int Version=ParseVersionFileName(ArcFileName,ArcFileNameW,false);
|
||||
if (Cmd->VersionControl-1==Version)
|
||||
ParseVersionFileName(ArcFileName,ArcFileNameW,true);
|
||||
else
|
||||
ExactMatch=false;
|
||||
}
|
||||
}
|
||||
else
|
||||
if (!Arc.IsArcDir() && Cmd->VersionControl>1)
|
||||
ExactMatch=false;
|
||||
|
||||
Arc.ConvertAttributes();
|
||||
|
||||
#ifndef SFX_MODULE
|
||||
if ((Arc.NewLhd.Flags & (LHD_SPLIT_BEFORE/*|LHD_SOLID*/)) && FirstFile)
|
||||
{
|
||||
char CurVolName[NM];
|
||||
strcpy(CurVolName,ArcName);
|
||||
|
||||
VolNameToFirstName(ArcName,ArcName,(Arc.NewMhd.Flags & MHD_NEWNUMBERING)!=0);
|
||||
if (stricomp(ArcName,CurVolName)!=0 && FileExist(ArcName))
|
||||
{
|
||||
*ArcNameW=0;
|
||||
Repeat=true;
|
||||
return(false);
|
||||
}
|
||||
#if !defined(RARDLL) && !defined(_WIN_CE)
|
||||
if (!ReconstructDone)
|
||||
{
|
||||
ReconstructDone=true;
|
||||
|
||||
RecVolumes RecVol;
|
||||
if (RecVol.Restore(Cmd,Arc.FileName,Arc.FileNameW,true))
|
||||
{
|
||||
Repeat=true;
|
||||
return(false);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
strcpy(ArcName,CurVolName);
|
||||
}
|
||||
#endif
|
||||
DataIO.UnpVolume=(Arc.NewLhd.Flags & LHD_SPLIT_AFTER)!=0;
|
||||
DataIO.NextVolumeMissing=false;
|
||||
|
||||
Arc.Seek(Arc.NextBlockPos-Arc.NewLhd.FullPackSize,SEEK_SET);
|
||||
|
||||
bool TestMode=false;
|
||||
bool ExtrFile=false;
|
||||
bool SkipSolid=false;
|
||||
|
||||
#ifndef SFX_MODULE
|
||||
if (FirstFile && (ExactMatch || Arc.Solid) && (Arc.NewLhd.Flags & (LHD_SPLIT_BEFORE/*|LHD_SOLID*/))!=0)
|
||||
{
|
||||
if (ExactMatch)
|
||||
{
|
||||
Log(Arc.FileName,St(MUnpCannotMerge),ArcFileName);
|
||||
#ifdef RARDLL
|
||||
Cmd->DllError=ERAR_BAD_DATA;
|
||||
#endif
|
||||
ErrHandler.SetErrorCode(OPEN_ERROR);
|
||||
}
|
||||
ExactMatch=false;
|
||||
}
|
||||
|
||||
FirstFile=false;
|
||||
#endif
|
||||
|
||||
if (ExactMatch || (SkipSolid=Arc.Solid)!=0)
|
||||
{
|
||||
if ((Arc.NewLhd.Flags & LHD_PASSWORD)!=0)
|
||||
#ifndef RARDLL
|
||||
if (*Password==0)
|
||||
#endif
|
||||
{
|
||||
#ifdef RARDLL
|
||||
if (*Cmd->Password==0)
|
||||
if (Cmd->Callback==NULL ||
|
||||
Cmd->Callback(UCM_NEEDPASSWORD,Cmd->UserData,(LPARAM)Cmd->Password,sizeof(Cmd->Password))==-1)
|
||||
return(false);
|
||||
strcpy(Password,Cmd->Password);
|
||||
|
||||
#else
|
||||
if (!GetPassword(PASSWORD_FILE,ArcFileName,Password,sizeof(Password)))
|
||||
{
|
||||
PasswordCancelled=true;
|
||||
return(false);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
#if !defined(GUI) && !defined(SILENT)
|
||||
else
|
||||
if (!PasswordAll && (!Arc.Solid || Arc.NewLhd.UnpVer>=20 && (Arc.NewLhd.Flags & LHD_SOLID)==0))
|
||||
{
|
||||
eprintf(St(MUseCurPsw),ArcFileName);
|
||||
switch(Cmd->AllYes ? 1:Ask(St(MYesNoAll)))
|
||||
{
|
||||
case -1:
|
||||
ErrHandler.Exit(USER_BREAK);
|
||||
case 2:
|
||||
if (!GetPassword(PASSWORD_FILE,ArcFileName,Password,sizeof(Password)))
|
||||
{
|
||||
return(false);
|
||||
}
|
||||
break;
|
||||
case 3:
|
||||
PasswordAll=true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifndef SFX_MODULE
|
||||
if (*Cmd->ExtrPath==0 && *Cmd->ExtrPathW!=0)
|
||||
WideToChar(Cmd->ExtrPathW,DestFileName);
|
||||
else
|
||||
#endif
|
||||
strcpy(DestFileName,Cmd->ExtrPath);
|
||||
|
||||
|
||||
#ifndef SFX_MODULE
|
||||
if (Cmd->AppendArcNameToPath)
|
||||
{
|
||||
strcat(DestFileName,PointToName(Arc.FirstVolumeName));
|
||||
SetExt(DestFileName,NULL);
|
||||
AddEndSlash(DestFileName);
|
||||
}
|
||||
#endif
|
||||
|
||||
char *ExtrName=ArcFileName;
|
||||
|
||||
bool EmptyName=false;
|
||||
#ifndef SFX_MODULE
|
||||
size_t 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);
|
||||
|
||||
char DiskLetter=etoupper(DestFileName[0]);
|
||||
|
||||
if (AbsPaths && DestFileName[1]=='_' && IsPathDiv(DestFileName[2]) &&
|
||||
DiskLetter>='A' && DiskLetter<='Z')
|
||||
DestFileName[1]=':';
|
||||
|
||||
#ifndef SFX_MODULE
|
||||
if (!WideName && *Cmd->ExtrPathW!=0)
|
||||
{
|
||||
DestNameW=DestFileNameW;
|
||||
WideName=true;
|
||||
CharToWide(ArcFileName,ArcFileNameW);
|
||||
}
|
||||
#endif
|
||||
|
||||
if (WideName)
|
||||
{
|
||||
if (*Cmd->ExtrPathW!=0)
|
||||
strcpyw(DestFileNameW,Cmd->ExtrPathW);
|
||||
else
|
||||
CharToWide(Cmd->ExtrPath,DestFileNameW);
|
||||
|
||||
#ifndef SFX_MODULE
|
||||
if (Cmd->AppendArcNameToPath)
|
||||
{
|
||||
wchar FileNameW[NM];
|
||||
if (*Arc.FirstVolumeNameW!=0)
|
||||
strcpyw(FileNameW,Arc.FirstVolumeNameW);
|
||||
else
|
||||
CharToWide(Arc.FirstVolumeName,FileNameW);
|
||||
strcatw(DestFileNameW,PointToName(FileNameW));
|
||||
SetExt(DestFileNameW,NULL);
|
||||
AddEndSlash(DestFileNameW);
|
||||
}
|
||||
#endif
|
||||
wchar *ExtrNameW=ArcFileNameW;
|
||||
#ifndef SFX_MODULE
|
||||
if (Length>0)
|
||||
{
|
||||
wchar ArcPathW[NM];
|
||||
GetWideName(Cmd->ArcPath,Cmd->ArcPathW,ArcPathW);
|
||||
Length=strlenw(ArcPathW);
|
||||
}
|
||||
ExtrNameW+=Length;
|
||||
while (*ExtrNameW==CPATHDIVIDER)
|
||||
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 && !EmptyName && (Arc.NewLhd.Flags & LHD_SPLIT_BEFORE)==0;
|
||||
|
||||
if ((Cmd->FreshFiles || Cmd->UpdateFiles) && (Command=='E' || Command=='X'))
|
||||
{
|
||||
struct FindData FD;
|
||||
if (FindFile::FastFind(DestFileName,DestNameW,&FD))
|
||||
{
|
||||
if (FD.mtime >= Arc.NewLhd.mtime)
|
||||
{
|
||||
// If directory already exists and its modification time is newer
|
||||
// than start of extraction, it is likely it was created
|
||||
// when creating a path to one of already extracted items.
|
||||
// In such case we'll better update its time even if archived
|
||||
// directory is older.
|
||||
|
||||
if (!FD.IsDir || FD.mtime<StartTime)
|
||||
ExtrFile=false;
|
||||
}
|
||||
}
|
||||
else
|
||||
if (Cmd->FreshFiles)
|
||||
ExtrFile=false;
|
||||
}
|
||||
|
||||
// Skip encrypted file if no password is specified.
|
||||
if ((Arc.NewLhd.Flags & LHD_PASSWORD)!=0 && *Password==0)
|
||||
{
|
||||
ErrHandler.SetErrorCode(WARNING);
|
||||
#ifdef RARDLL
|
||||
Cmd->DllError=ERAR_MISSING_PASSWORD;
|
||||
#endif
|
||||
ExtrFile=false;
|
||||
}
|
||||
|
||||
#ifdef RARDLL
|
||||
if (*Cmd->DllDestName)
|
||||
{
|
||||
strncpyz(DestFileName,Cmd->DllDestName,ASIZE(DestFileName));
|
||||
*DestFileNameW=0;
|
||||
if (Cmd->DllOpMode!=RAR_EXTRACT)
|
||||
ExtrFile=false;
|
||||
}
|
||||
if (*Cmd->DllDestNameW)
|
||||
{
|
||||
strncpyzw(DestFileNameW,Cmd->DllDestNameW,ASIZE(DestFileNameW));
|
||||
DestNameW=DestFileNameW;
|
||||
if (Cmd->DllOpMode!=RAR_EXTRACT)
|
||||
ExtrFile=false;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef SFX_MODULE
|
||||
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
|
||||
{
|
||||
#ifndef SILENT
|
||||
Log(Arc.FileName,St(MUnknownMeth),ArcFileName);
|
||||
#ifndef SFX_MODULE
|
||||
Log(Arc.FileName,St(MVerRequired),Arc.NewLhd.UnpVer/10,Arc.NewLhd.UnpVer%10);
|
||||
#endif
|
||||
#endif
|
||||
ExtrFile=false;
|
||||
ErrHandler.SetErrorCode(WARNING);
|
||||
#ifdef RARDLL
|
||||
Cmd->DllError=ERAR_UNKNOWN_FORMAT;
|
||||
#endif
|
||||
}
|
||||
|
||||
File CurFile;
|
||||
|
||||
if (!IsLink(Arc.NewLhd.FileAttr))
|
||||
if (Arc.IsArcDir())
|
||||
{
|
||||
if (!ExtrFile || Command=='P' || Command=='E' || Cmd->ExclPath==EXCL_SKIPWHOLEPATH)
|
||||
return(true);
|
||||
if (SkipSolid)
|
||||
{
|
||||
#ifndef GUI
|
||||
mprintf(St(MExtrSkipFile),ArcFileName);
|
||||
#endif
|
||||
return(true);
|
||||
}
|
||||
TotalFileCount++;
|
||||
if (Cmd->Test)
|
||||
{
|
||||
#ifndef GUI
|
||||
mprintf(St(MExtrTestFile),ArcFileName);
|
||||
mprintf(" %s",St(MOk));
|
||||
#endif
|
||||
return(true);
|
||||
}
|
||||
MKDIR_CODE MDCode=MakeDir(DestFileName,DestNameW,!Cmd->IgnoreGeneralAttr,Arc.NewLhd.FileAttr);
|
||||
bool DirExist=false;
|
||||
if (MDCode!=MKDIR_SUCCESS)
|
||||
{
|
||||
DirExist=FileExist(DestFileName,DestNameW);
|
||||
if (DirExist && !IsDir(GetFileAttr(DestFileName,DestNameW)))
|
||||
{
|
||||
bool UserReject;
|
||||
FileCreate(Cmd,NULL,DestFileName,DestNameW,Cmd->Overwrite,&UserReject,Arc.NewLhd.FullUnpSize,Arc.NewLhd.FileTime);
|
||||
DirExist=false;
|
||||
}
|
||||
CreatePath(DestFileName,DestNameW,true);
|
||||
MDCode=MakeDir(DestFileName,DestNameW,!Cmd->IgnoreGeneralAttr,Arc.NewLhd.FileAttr);
|
||||
}
|
||||
if (MDCode==MKDIR_SUCCESS)
|
||||
{
|
||||
#ifndef GUI
|
||||
mprintf(St(MCreatDir),DestFileName);
|
||||
mprintf(" %s",St(MOk));
|
||||
#endif
|
||||
PrevExtracted=true;
|
||||
}
|
||||
else
|
||||
if (DirExist)
|
||||
{
|
||||
if (!Cmd->IgnoreGeneralAttr)
|
||||
SetFileAttr(DestFileName,DestNameW,Arc.NewLhd.FileAttr);
|
||||
PrevExtracted=true;
|
||||
}
|
||||
else
|
||||
{
|
||||
Log(Arc.FileName,St(MExtrErrMkDir),DestFileName);
|
||||
ErrHandler.SysErrMsg();
|
||||
#ifdef RARDLL
|
||||
Cmd->DllError=ERAR_ECREATE;
|
||||
#endif
|
||||
ErrHandler.SetErrorCode(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,DestNameW,true);
|
||||
#endif
|
||||
SetDirTime(DestFileName,DestNameW,
|
||||
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
|
||||
{
|
||||
if (Cmd->Test && ExtrFile)
|
||||
TestMode=true;
|
||||
#if !defined(GUI) && !defined(SFX_MODULE)
|
||||
if (Command=='P' && ExtrFile)
|
||||
CurFile.SetHandleType(FILE_HANDLESTD);
|
||||
#endif
|
||||
if ((Command=='E' || Command=='X') && ExtrFile && !Cmd->Test)
|
||||
{
|
||||
bool UserReject;
|
||||
if (!FileCreate(Cmd,&CurFile,DestFileName,DestNameW,Cmd->Overwrite,&UserReject,Arc.NewLhd.FullUnpSize,Arc.NewLhd.FileTime))
|
||||
{
|
||||
ExtrFile=false;
|
||||
if (!UserReject)
|
||||
{
|
||||
ErrHandler.CreateErrorMsg(Arc.FileName,DestFileName);
|
||||
ErrHandler.SetErrorCode(CREATE_ERROR);
|
||||
#ifdef RARDLL
|
||||
Cmd->DllError=ERAR_ECREATE;
|
||||
#endif
|
||||
if (!IsNameUsable(DestFileName))
|
||||
{
|
||||
Log(Arc.FileName,St(MCorrectingName));
|
||||
char OrigName[sizeof(DestFileName)];
|
||||
strncpyz(OrigName,DestFileName,ASIZE(OrigName));
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!ExtrFile && Arc.Solid)
|
||||
{
|
||||
SkipSolid=true;
|
||||
TestMode=true;
|
||||
ExtrFile=true;
|
||||
|
||||
}
|
||||
if (ExtrFile)
|
||||
{
|
||||
if (!SkipSolid)
|
||||
{
|
||||
if (!TestMode && Command!='P' && CurFile.IsDevice())
|
||||
{
|
||||
Log(Arc.FileName,St(MInvalidName),DestFileName);
|
||||
ErrHandler.WriteError(Arc.FileName,DestFileName);
|
||||
}
|
||||
TotalFileCount++;
|
||||
}
|
||||
FileCount++;
|
||||
#ifndef GUI
|
||||
if (Command!='I')
|
||||
if (SkipSolid)
|
||||
mprintf(St(MExtrSkipFile),ArcFileName);
|
||||
else
|
||||
switch(Cmd->Test ? 'T':Command)
|
||||
{
|
||||
case 'T':
|
||||
mprintf(St(MExtrTestFile),ArcFileName);
|
||||
break;
|
||||
#ifndef SFX_MODULE
|
||||
case 'P':
|
||||
mprintf(St(MExtrPrinting),ArcFileName);
|
||||
break;
|
||||
#endif
|
||||
case 'X':
|
||||
case 'E':
|
||||
mprintf(St(MExtrFile),DestFileName);
|
||||
break;
|
||||
}
|
||||
if (!Cmd->DisablePercentage)
|
||||
mprintf(" ");
|
||||
#endif
|
||||
DataIO.CurUnpRead=0;
|
||||
DataIO.CurUnpWrite=0;
|
||||
DataIO.UnpFileCRC=Arc.OldFormat ? 0 : 0xffffffff;
|
||||
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.UnpVer>=36);
|
||||
DataIO.SetPackedSizeToRead(Arc.NewLhd.FullPackSize);
|
||||
DataIO.SetFiles(&Arc,&CurFile);
|
||||
DataIO.SetTestMode(TestMode);
|
||||
DataIO.SetSkipUnpCRC(SkipSolid);
|
||||
#ifndef _WIN_CE
|
||||
if (!TestMode && !Arc.BrokenFileHeader &&
|
||||
(Arc.NewLhd.FullPackSize<<11)>Arc.NewLhd.FullUnpSize &&
|
||||
(Arc.NewLhd.FullUnpSize<100000000 || Arc.FileLength()>Arc.NewLhd.FullPackSize))
|
||||
CurFile.Prealloc(Arc.NewLhd.FullUnpSize);
|
||||
#endif
|
||||
|
||||
CurFile.SetAllowDelete(!Cmd->KeepBroken);
|
||||
|
||||
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)!=0);
|
||||
}
|
||||
|
||||
if (Arc.IsOpened())
|
||||
Arc.SeekToNext();
|
||||
|
||||
bool BrokenFile=false;
|
||||
if (!SkipSolid)
|
||||
{
|
||||
if (Arc.OldFormat && UINT32(DataIO.UnpFileCRC)==UINT32(Arc.NewLhd.FileCRC) ||
|
||||
!Arc.OldFormat && UINT32(DataIO.UnpFileCRC)==UINT32(Arc.NewLhd.FileCRC^0xffffffff))
|
||||
{
|
||||
#ifndef GUI
|
||||
if (Command!='P' && Command!='I')
|
||||
mprintf("%s%s ",Cmd->DisablePercentage ? " ":"\b\b\b\b\b ",St(MOk));
|
||||
#endif
|
||||
}
|
||||
else
|
||||
{
|
||||
char *BadArcName=/*(Arc.NewLhd.Flags & LHD_SPLIT_BEFORE) ? NULL:*/Arc.FileName;
|
||||
if (Arc.NewLhd.Flags & LHD_PASSWORD)
|
||||
{
|
||||
Log(BadArcName,St(MEncrBadCRC),ArcFileName);
|
||||
}
|
||||
else
|
||||
{
|
||||
Log(BadArcName,St(MCRCFailed),ArcFileName);
|
||||
}
|
||||
BrokenFile=true;
|
||||
ErrHandler.SetErrorCode(CRC_ERROR);
|
||||
#ifdef RARDLL
|
||||
Cmd->DllError=ERAR_BAD_DATA;
|
||||
#endif
|
||||
Alarm();
|
||||
}
|
||||
}
|
||||
#ifndef GUI
|
||||
else
|
||||
mprintf("\b\b\b\b\b ");
|
||||
#endif
|
||||
|
||||
if (!TestMode && (Command=='X' || Command=='E') &&
|
||||
!IsLink(Arc.NewLhd.FileAttr))
|
||||
{
|
||||
#if defined(_WIN_32) || defined(_EMX)
|
||||
if (Cmd->ClearArc)
|
||||
Arc.NewLhd.FileAttr&=~FA_ARCH;
|
||||
/*
|
||||
else
|
||||
Arc.NewLhd.FileAttr|=FA_ARCH; //set archive bit for unpacked files (file is not backed up)
|
||||
*/
|
||||
#endif
|
||||
if (!BrokenFile || Cmd->KeepBroken)
|
||||
{
|
||||
if (BrokenFile)
|
||||
CurFile.Truncate();
|
||||
CurFile.SetOpenFileTime(
|
||||
Cmd->xmtime==EXTTIME_NONE ? NULL:&Arc.NewLhd.mtime,
|
||||
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.SetCloseFileTime(
|
||||
Cmd->xmtime==EXTTIME_NONE ? NULL:&Arc.NewLhd.mtime,
|
||||
Cmd->xatime==EXTTIME_NONE ? NULL:&Arc.NewLhd.atime);
|
||||
if (!Cmd->IgnoreGeneralAttr)
|
||||
SetFileAttr(CurFile.FileName,CurFile.FileNameW,Arc.NewLhd.FileAttr);
|
||||
PrevExtracted=true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (ExactMatch)
|
||||
MatchedArgs++;
|
||||
if (DataIO.NextVolumeMissing || !Arc.IsOpened())
|
||||
return(false);
|
||||
if (!ExtrFile)
|
||||
if (!Arc.Solid)
|
||||
Arc.SeekToNext();
|
||||
else
|
||||
if (!SkipSolid)
|
||||
return(false);
|
||||
return(true);
|
||||
}
|
||||
|
||||
|
||||
void CmdExtract::UnstoreFile(ComprDataIO &DataIO,int64 DestUnpSize)
|
||||
{
|
||||
Array<byte> Buffer(0x10000);
|
||||
while (1)
|
||||
{
|
||||
uint Code=DataIO.UnpRead(&Buffer[0],Buffer.Size());
|
||||
if (Code==0 || (int)Code==-1)
|
||||
break;
|
||||
Code=Code<DestUnpSize ? Code:(uint)DestUnpSize;
|
||||
DataIO.UnpWrite(&Buffer[0],Code);
|
||||
if (DestUnpSize>=0)
|
||||
DestUnpSize-=Code;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,43 @@
|
|||
#ifndef _RAR_EXTRACT_
|
||||
#define _RAR_EXTRACT_
|
||||
|
||||
enum EXTRACT_ARC_CODE {EXTRACT_ARC_NEXT,EXTRACT_ARC_REPEAT};
|
||||
|
||||
class CmdExtract
|
||||
{
|
||||
private:
|
||||
EXTRACT_ARC_CODE ExtractArchive(CommandData *Cmd);
|
||||
RarTime StartTime; // time when extraction started
|
||||
|
||||
ComprDataIO DataIO;
|
||||
Unpack *Unp;
|
||||
unsigned long TotalFileCount;
|
||||
|
||||
unsigned long FileCount;
|
||||
unsigned long MatchedArgs;
|
||||
bool FirstFile;
|
||||
bool AllMatchesExact;
|
||||
bool ReconstructDone;
|
||||
|
||||
char ArcName[NM];
|
||||
wchar ArcNameW[NM];
|
||||
|
||||
char Password[MAXPASSWORD];
|
||||
bool PasswordAll;
|
||||
bool PrevExtracted;
|
||||
char DestFileName[NM];
|
||||
wchar DestFileNameW[NM];
|
||||
bool PasswordCancelled;
|
||||
public:
|
||||
CmdExtract();
|
||||
~CmdExtract();
|
||||
void DoExtract(CommandData *Cmd);
|
||||
void ExtractArchiveInit(CommandData *Cmd,Archive &Arc);
|
||||
bool ExtractCurrentFile(CommandData *Cmd,Archive &Arc,size_t HeaderSize,
|
||||
bool &Repeat);
|
||||
static void UnstoreFile(ComprDataIO &DataIO,int64 DestUnpSize);
|
||||
|
||||
bool SignatureFound;
|
||||
};
|
||||
|
||||
#endif
|
|
@ -0,0 +1,245 @@
|
|||
#include "rar.hpp"
|
||||
|
||||
bool FileCreate(RAROptions *Cmd,File *NewFile,char *Name,wchar *NameW,
|
||||
OVERWRITE_MODE Mode,bool *UserReject,int64 FileSize,
|
||||
uint FileTime)
|
||||
{
|
||||
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)
|
||||
*UserReject=true;
|
||||
return(false);
|
||||
}
|
||||
#ifdef SILENT
|
||||
Mode=OVERWRITE_ALL;
|
||||
#endif
|
||||
if (Cmd->AllYes || Mode==OVERWRITE_ALL)
|
||||
break;
|
||||
if (Mode==OVERWRITE_DEFAULT || Mode==OVERWRITE_FORCE_ASK)
|
||||
{
|
||||
eprintf(St(MFileExists),Name);
|
||||
int Choice=Ask(St(MYesNoAllRenQ));
|
||||
if (Choice==1)
|
||||
break;
|
||||
if (Choice==2)
|
||||
{
|
||||
if (UserReject!=NULL)
|
||||
*UserReject=true;
|
||||
return(false);
|
||||
}
|
||||
if (Choice==3)
|
||||
{
|
||||
Cmd->Overwrite=OVERWRITE_ALL;
|
||||
break;
|
||||
}
|
||||
if (Choice==4)
|
||||
{
|
||||
if (UserReject!=NULL)
|
||||
*UserReject=true;
|
||||
Cmd->Overwrite=OVERWRITE_NONE;
|
||||
return(false);
|
||||
}
|
||||
if (Choice==5)
|
||||
{
|
||||
mprintf(St(MAskNewName));
|
||||
|
||||
char NewName[NM];
|
||||
#ifdef _WIN_32
|
||||
File SrcFile;
|
||||
SrcFile.SetHandleType(FILE_HANDLESTD);
|
||||
int Size=SrcFile.Read(NewName,sizeof(NewName)-1);
|
||||
NewName[Size]=0;
|
||||
OemToChar(NewName,NewName);
|
||||
#else
|
||||
if (fgets(NewName,sizeof(NewName),stdin)==NULL)
|
||||
{
|
||||
// Process fgets failure as if user answered 'No'.
|
||||
if (UserReject!=NULL)
|
||||
*UserReject=true;
|
||||
return(false);
|
||||
}
|
||||
#endif
|
||||
RemoveLF(NewName);
|
||||
if (PointToName(NewName)==NewName)
|
||||
strcpy(PointToName(Name),NewName);
|
||||
else
|
||||
strcpy(Name,NewName);
|
||||
if (NameW!=NULL)
|
||||
*NameW=0;
|
||||
continue;
|
||||
}
|
||||
if (Choice==6)
|
||||
ErrHandler.Exit(USER_BREAK);
|
||||
}
|
||||
if (Mode==OVERWRITE_AUTORENAME)
|
||||
{
|
||||
if (GetAutoRenamedName(Name))
|
||||
{
|
||||
if (NameW!=NULL)
|
||||
*NameW=0;
|
||||
}
|
||||
else
|
||||
Mode=OVERWRITE_DEFAULT;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
if (NewFile!=NULL && NewFile->Create(Name,NameW))
|
||||
return(true);
|
||||
PrepareToDelete(Name,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",int(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)
|
||||
{
|
||||
strncpyz(NewName,Name,ASIZE(NewName));
|
||||
sprintf(PointToName(NewName),"rtmp%d",I);
|
||||
if (!FileExist(NewName))
|
||||
break;
|
||||
}
|
||||
if (FileExist(NewName))
|
||||
return(false);
|
||||
char FullName[NM];
|
||||
strncpyz(FullName,Name,ASIZE(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
|
|
@ -0,0 +1,13 @@
|
|||
#ifndef _RAR_FILECREATE_
|
||||
#define _RAR_FILECREATE_
|
||||
|
||||
bool FileCreate(RAROptions *Cmd,File *NewFile,char *Name,wchar *NameW,
|
||||
OVERWRITE_MODE Mode,bool *UserReject,int64 FileSize=INT64NDF,
|
||||
uint FileTime=0);
|
||||
bool GetAutoRenamedName(char *Name);
|
||||
|
||||
#if defined(_WIN_32) && !defined(_WIN_CE)
|
||||
bool UpdateExistingShortName(char *Name,wchar *NameW);
|
||||
#endif
|
||||
|
||||
#endif
|
|
@ -0,0 +1,678 @@
|
|||
#include "rar.hpp"
|
||||
|
||||
static File *CreatedFiles[256];
|
||||
static int RemoveCreatedActive=0;
|
||||
|
||||
File::File()
|
||||
{
|
||||
hFile=BAD_HANDLE;
|
||||
*FileName=0;
|
||||
*FileNameW=0;
|
||||
NewFile=false;
|
||||
LastWrite=false;
|
||||
HandleType=FILE_HANDLENORMAL;
|
||||
SkipClose=false;
|
||||
IgnoreReadErrors=false;
|
||||
ErrorType=FILE_SUCCESS;
|
||||
OpenShared=false;
|
||||
AllowDelete=true;
|
||||
CloseCount=0;
|
||||
AllowExceptions=true;
|
||||
#ifdef _WIN_32
|
||||
NoSequentialRead=false;
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
File::~File()
|
||||
{
|
||||
if (hFile!=BAD_HANDLE && !SkipClose)
|
||||
if (NewFile)
|
||||
Delete();
|
||||
else
|
||||
Close();
|
||||
}
|
||||
|
||||
|
||||
void File::operator = (File &SrcFile)
|
||||
{
|
||||
hFile=SrcFile.hFile;
|
||||
strcpy(FileName,SrcFile.FileName);
|
||||
NewFile=SrcFile.NewFile;
|
||||
LastWrite=SrcFile.LastWrite;
|
||||
HandleType=SrcFile.HandleType;
|
||||
SrcFile.SkipClose=true;
|
||||
}
|
||||
|
||||
|
||||
bool File::Open(const char *Name,const wchar *NameW,bool OpenShared,bool Update)
|
||||
{
|
||||
ErrorType=FILE_SUCCESS;
|
||||
FileHandle hNewFile;
|
||||
if (File::OpenShared)
|
||||
OpenShared=true;
|
||||
#ifdef _WIN_32
|
||||
uint Access=GENERIC_READ;
|
||||
if (Update)
|
||||
Access|=GENERIC_WRITE;
|
||||
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,Flags,NULL);
|
||||
else
|
||||
hNewFile=CreateFile(Name,Access,ShareMode,NULL,OPEN_EXISTING,Flags,NULL);
|
||||
|
||||
if (hNewFile==BAD_HANDLE && GetLastError()==ERROR_FILE_NOT_FOUND)
|
||||
ErrorType=FILE_NOTFOUND;
|
||||
#else
|
||||
int flags=Update ? O_RDWR:O_RDONLY;
|
||||
#ifdef O_BINARY
|
||||
flags|=O_BINARY;
|
||||
#if defined(_AIX) && defined(_LARGE_FILE_API)
|
||||
flags|=O_LARGEFILE;
|
||||
#endif
|
||||
#endif
|
||||
#if defined(_EMX) && !defined(_DJGPP)
|
||||
int sflags=OpenShared ? SH_DENYNO:SH_DENYWR;
|
||||
int handle=sopen(Name,flags,sflags);
|
||||
#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);
|
||||
return(false);
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
hNewFile=handle==-1 ? BAD_HANDLE:fdopen(handle,Update ? UPDATEBINARY:READBINARY);
|
||||
if (hNewFile==BAD_HANDLE && errno==ENOENT)
|
||||
ErrorType=FILE_NOTFOUND;
|
||||
#endif
|
||||
NewFile=false;
|
||||
HandleType=FILE_HANDLENORMAL;
|
||||
SkipClose=false;
|
||||
bool Success=hNewFile!=BAD_HANDLE;
|
||||
if (Success)
|
||||
{
|
||||
hFile=hNewFile;
|
||||
if (NameW!=NULL)
|
||||
strcpyw(FileNameW,NameW);
|
||||
else
|
||||
*FileNameW=0;
|
||||
if (Name!=NULL)
|
||||
strcpy(FileName,Name);
|
||||
else
|
||||
WideToChar(NameW,FileName);
|
||||
AddFileToList(hFile);
|
||||
}
|
||||
return(Success);
|
||||
}
|
||||
|
||||
|
||||
#if !defined(SHELL_EXT) && !defined(SFX_MODULE)
|
||||
void File::TOpen(const char *Name,const wchar *NameW)
|
||||
{
|
||||
if (!WOpen(Name,NameW))
|
||||
ErrHandler.Exit(OPEN_ERROR);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
bool File::WOpen(const char *Name,const wchar *NameW)
|
||||
{
|
||||
if (Open(Name,NameW))
|
||||
return(true);
|
||||
ErrHandler.OpenErrorMsg(Name);
|
||||
return(false);
|
||||
}
|
||||
|
||||
|
||||
bool File::Create(const char *Name,const wchar *NameW,bool ShareRead)
|
||||
{
|
||||
#ifdef _WIN_32
|
||||
DWORD ShareMode=(ShareRead || File::OpenShared) ? FILE_SHARE_READ:0;
|
||||
if (WinNT() && NameW!=NULL && *NameW!=0)
|
||||
hFile=CreateFileW(NameW,GENERIC_READ|GENERIC_WRITE,ShareMode,NULL,
|
||||
CREATE_ALWAYS,0,NULL);
|
||||
else
|
||||
hFile=CreateFile(Name,GENERIC_READ|GENERIC_WRITE,ShareMode,NULL,
|
||||
CREATE_ALWAYS,0,NULL);
|
||||
#else
|
||||
hFile=fopen(Name,CREATEBINARY);
|
||||
#endif
|
||||
NewFile=true;
|
||||
HandleType=FILE_HANDLENORMAL;
|
||||
SkipClose=false;
|
||||
if (NameW!=NULL)
|
||||
strcpyw(FileNameW,NameW);
|
||||
else
|
||||
*FileNameW=0;
|
||||
if (Name!=NULL)
|
||||
strcpy(FileName,Name);
|
||||
else
|
||||
WideToChar(NameW,FileName);
|
||||
AddFileToList(hFile);
|
||||
return(hFile!=BAD_HANDLE);
|
||||
}
|
||||
|
||||
|
||||
void File::AddFileToList(FileHandle hFile)
|
||||
{
|
||||
if (hFile!=BAD_HANDLE)
|
||||
for (int I=0;I<sizeof(CreatedFiles)/sizeof(CreatedFiles[0]);I++)
|
||||
if (CreatedFiles[I]==NULL)
|
||||
{
|
||||
CreatedFiles[I]=this;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#if !defined(SHELL_EXT) && !defined(SFX_MODULE)
|
||||
void File::TCreate(const char *Name,const wchar *NameW,bool ShareRead)
|
||||
{
|
||||
if (!WCreate(Name,NameW,ShareRead))
|
||||
ErrHandler.Exit(FATAL_ERROR);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
bool File::WCreate(const char *Name,const wchar *NameW,bool ShareRead)
|
||||
{
|
||||
if (Create(Name,NameW,ShareRead))
|
||||
return(true);
|
||||
ErrHandler.SetErrorCode(CREATE_ERROR);
|
||||
ErrHandler.CreateErrorMsg(Name);
|
||||
return(false);
|
||||
}
|
||||
|
||||
|
||||
bool File::Close()
|
||||
{
|
||||
bool Success=true;
|
||||
if (HandleType!=FILE_HANDLENORMAL)
|
||||
HandleType=FILE_HANDLENORMAL;
|
||||
else
|
||||
if (hFile!=BAD_HANDLE)
|
||||
{
|
||||
if (!SkipClose)
|
||||
{
|
||||
#ifdef _WIN_32
|
||||
Success=CloseHandle(hFile)==TRUE;
|
||||
#else
|
||||
Success=fclose(hFile)!=EOF;
|
||||
#endif
|
||||
if (Success || !RemoveCreatedActive)
|
||||
for (int I=0;I<sizeof(CreatedFiles)/sizeof(CreatedFiles[0]);I++)
|
||||
if (CreatedFiles[I]==this)
|
||||
{
|
||||
CreatedFiles[I]=NULL;
|
||||
break;
|
||||
}
|
||||
}
|
||||
hFile=BAD_HANDLE;
|
||||
if (!Success && AllowExceptions)
|
||||
ErrHandler.CloseError(FileName);
|
||||
}
|
||||
CloseCount++;
|
||||
return(Success);
|
||||
}
|
||||
|
||||
|
||||
void File::Flush()
|
||||
{
|
||||
#ifdef _WIN_32
|
||||
FlushFileBuffers(hFile);
|
||||
#else
|
||||
fflush(hFile);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
bool File::Delete()
|
||||
{
|
||||
if (HandleType!=FILE_HANDLENORMAL)
|
||||
return(false);
|
||||
if (hFile!=BAD_HANDLE)
|
||||
Close();
|
||||
if (!AllowDelete)
|
||||
return(false);
|
||||
return(DelFile(FileName,FileNameW));
|
||||
}
|
||||
|
||||
|
||||
bool File::Rename(const char *NewName,const wchar *NewNameW)
|
||||
{
|
||||
// we do not need to rename if names are already same
|
||||
bool Success=strcmp(FileName,NewName)==0;
|
||||
if (Success && *FileNameW!=0 && *NullToEmpty(NewNameW)!=0)
|
||||
Success=strcmpw(FileNameW,NewNameW)==0;
|
||||
|
||||
if (!Success)
|
||||
Success=RenameFile(FileName,FileNameW,NewName,NewNameW);
|
||||
|
||||
if (Success)
|
||||
{
|
||||
// renamed successfully, storing the new name
|
||||
strcpy(FileName,NewName);
|
||||
strcpyw(FileNameW,NullToEmpty(NewNameW));
|
||||
}
|
||||
return(Success);
|
||||
}
|
||||
|
||||
|
||||
void File::Write(const void *Data,size_t Size)
|
||||
{
|
||||
if (Size==0)
|
||||
return;
|
||||
#ifndef _WIN_CE
|
||||
if (HandleType!=FILE_HANDLENORMAL)
|
||||
switch(HandleType)
|
||||
{
|
||||
case FILE_HANDLESTD:
|
||||
#ifdef _WIN_32
|
||||
hFile=GetStdHandle(STD_OUTPUT_HANDLE);
|
||||
#else
|
||||
hFile=stdout;
|
||||
#endif
|
||||
break;
|
||||
case FILE_HANDLEERR:
|
||||
#ifdef _WIN_32
|
||||
hFile=GetStdHandle(STD_ERROR_HANDLE);
|
||||
#else
|
||||
hFile=stderr;
|
||||
#endif
|
||||
break;
|
||||
}
|
||||
#endif
|
||||
while (1)
|
||||
{
|
||||
bool Success=false;
|
||||
#ifdef _WIN_32
|
||||
DWORD Written=0;
|
||||
if (HandleType!=FILE_HANDLENORMAL)
|
||||
{
|
||||
// writing to stdout can fail in old Windows if data block is too large
|
||||
const size_t MaxSize=0x4000;
|
||||
for (size_t I=0;I<Size;I+=MaxSize)
|
||||
{
|
||||
Success=WriteFile(hFile,(byte *)Data+I,(DWORD)Min(Size-I,MaxSize),&Written,NULL)==TRUE;
|
||||
if (!Success)
|
||||
break;
|
||||
}
|
||||
}
|
||||
else
|
||||
Success=WriteFile(hFile,Data,(DWORD)Size,&Written,NULL)==TRUE;
|
||||
#else
|
||||
int Written=fwrite(Data,1,Size,hFile);
|
||||
Success=Written==Size && !ferror(hFile);
|
||||
#endif
|
||||
if (!Success && AllowExceptions && HandleType==FILE_HANDLENORMAL)
|
||||
{
|
||||
#if defined(_WIN_32) && !defined(SFX_MODULE) && !defined(RARDLL)
|
||||
int ErrCode=GetLastError();
|
||||
int64 FilePos=Tell();
|
||||
uint64 FreeSize=GetFreeDisk(FileName);
|
||||
SetLastError(ErrCode);
|
||||
if (FreeSize>Size && FilePos-Size<=0xffffffff && FilePos+Size>0xffffffff)
|
||||
ErrHandler.WriteErrorFAT(FileName);
|
||||
#endif
|
||||
if (ErrHandler.AskRepeatWrite(FileName,false))
|
||||
{
|
||||
#ifndef _WIN_32
|
||||
clearerr(hFile);
|
||||
#endif
|
||||
if (Written<Size && Written>0)
|
||||
Seek(Tell()-Written,SEEK_SET);
|
||||
continue;
|
||||
}
|
||||
ErrHandler.WriteError(NULL,FileName);
|
||||
}
|
||||
break;
|
||||
}
|
||||
LastWrite=true;
|
||||
}
|
||||
|
||||
|
||||
int File::Read(void *Data,size_t Size)
|
||||
{
|
||||
int64 FilePos=0; //initialized only to suppress some compilers warning
|
||||
|
||||
if (IgnoreReadErrors)
|
||||
FilePos=Tell();
|
||||
int ReadSize;
|
||||
while (true)
|
||||
{
|
||||
ReadSize=DirectRead(Data,Size);
|
||||
if (ReadSize==-1)
|
||||
{
|
||||
ErrorType=FILE_READERROR;
|
||||
if (AllowExceptions)
|
||||
if (IgnoreReadErrors)
|
||||
{
|
||||
ReadSize=0;
|
||||
for (size_t I=0;I<Size;I+=512)
|
||||
{
|
||||
Seek(FilePos+I,SEEK_SET);
|
||||
size_t SizeToRead=Min(Size-I,512);
|
||||
int ReadCode=DirectRead(Data,SizeToRead);
|
||||
ReadSize+=(ReadCode==-1) ? 512:ReadCode;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (HandleType==FILE_HANDLENORMAL && ErrHandler.AskRepeatRead(FileName))
|
||||
continue;
|
||||
ErrHandler.ReadError(FileName);
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
return(ReadSize);
|
||||
}
|
||||
|
||||
|
||||
// Returns -1 in case of error.
|
||||
int File::DirectRead(void *Data,size_t Size)
|
||||
{
|
||||
#ifdef _WIN_32
|
||||
const size_t MaxDeviceRead=20000;
|
||||
#endif
|
||||
#ifndef _WIN_CE
|
||||
if (HandleType==FILE_HANDLESTD)
|
||||
{
|
||||
#ifdef _WIN_32
|
||||
if (Size>MaxDeviceRead)
|
||||
Size=MaxDeviceRead;
|
||||
hFile=GetStdHandle(STD_INPUT_HANDLE);
|
||||
#else
|
||||
hFile=stdin;
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
#ifdef _WIN_32
|
||||
DWORD Read;
|
||||
if (!ReadFile(hFile,Data,(DWORD)Size,&Read,NULL))
|
||||
{
|
||||
if (IsDevice() && Size>MaxDeviceRead)
|
||||
return(DirectRead(Data,MaxDeviceRead));
|
||||
if (HandleType==FILE_HANDLESTD && GetLastError()==ERROR_BROKEN_PIPE)
|
||||
return(0);
|
||||
return(-1);
|
||||
}
|
||||
return(Read);
|
||||
#else
|
||||
if (LastWrite)
|
||||
{
|
||||
fflush(hFile);
|
||||
LastWrite=false;
|
||||
}
|
||||
clearerr(hFile);
|
||||
size_t ReadSize=fread(Data,1,Size,hFile);
|
||||
if (ferror(hFile))
|
||||
return(-1);
|
||||
return((int)ReadSize);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
void File::Seek(int64 Offset,int Method)
|
||||
{
|
||||
if (!RawSeek(Offset,Method) && AllowExceptions)
|
||||
ErrHandler.SeekError(FileName);
|
||||
}
|
||||
|
||||
|
||||
bool File::RawSeek(int64 Offset,int Method)
|
||||
{
|
||||
if (hFile==BAD_HANDLE)
|
||||
return(true);
|
||||
if (Offset<0 && Method!=SEEK_SET)
|
||||
{
|
||||
Offset=(Method==SEEK_CUR ? Tell():FileLength())+Offset;
|
||||
Method=SEEK_SET;
|
||||
}
|
||||
#ifdef _WIN_32
|
||||
LONG HighDist=(LONG)(Offset>>32);
|
||||
if (SetFilePointer(hFile,(LONG)Offset,&HighDist,Method)==0xffffffff &&
|
||||
GetLastError()!=NO_ERROR)
|
||||
return(false);
|
||||
#else
|
||||
LastWrite=false;
|
||||
#if defined(_LARGEFILE_SOURCE) && !defined(_OSF_SOURCE) && !defined(__VMS)
|
||||
if (fseeko(hFile,Offset,Method)!=0)
|
||||
#else
|
||||
if (fseek(hFile,(long)Offset,Method)!=0)
|
||||
#endif
|
||||
return(false);
|
||||
#endif
|
||||
return(true);
|
||||
}
|
||||
|
||||
|
||||
int64 File::Tell()
|
||||
{
|
||||
#ifdef _WIN_32
|
||||
LONG HighDist=0;
|
||||
uint LowDist=SetFilePointer(hFile,0,&HighDist,FILE_CURRENT);
|
||||
if (LowDist==0xffffffff && GetLastError()!=NO_ERROR)
|
||||
if (AllowExceptions)
|
||||
ErrHandler.SeekError(FileName);
|
||||
else
|
||||
return(-1);
|
||||
return(INT32TO64(HighDist,LowDist));
|
||||
#else
|
||||
#if defined(_LARGEFILE_SOURCE) && !defined(_OSF_SOURCE)
|
||||
return(ftello(hFile));
|
||||
#else
|
||||
return(ftell(hFile));
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
void File::Prealloc(int64 Size)
|
||||
{
|
||||
#ifdef _WIN_32
|
||||
if (RawSeek(Size,SEEK_SET))
|
||||
{
|
||||
Truncate();
|
||||
Seek(0,SEEK_SET);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
byte File::GetByte()
|
||||
{
|
||||
byte Byte=0;
|
||||
Read(&Byte,1);
|
||||
return(Byte);
|
||||
}
|
||||
|
||||
|
||||
void File::PutByte(byte Byte)
|
||||
{
|
||||
Write(&Byte,1);
|
||||
}
|
||||
|
||||
|
||||
bool File::Truncate()
|
||||
{
|
||||
#ifdef _WIN_32
|
||||
return(SetEndOfFile(hFile)==TRUE);
|
||||
#else
|
||||
return(false);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
void File::SetOpenFileTime(RarTime *ftm,RarTime *ftc,RarTime *fta)
|
||||
{
|
||||
#ifdef _WIN_32
|
||||
bool sm=ftm!=NULL && ftm->IsSet();
|
||||
bool sc=ftc!=NULL && ftc->IsSet();
|
||||
bool sa=fta!=NULL && fta->IsSet();
|
||||
FILETIME fm,fc,fa;
|
||||
if (sm)
|
||||
ftm->GetWin32(&fm);
|
||||
if (sc)
|
||||
ftc->GetWin32(&fc);
|
||||
if (sa)
|
||||
fta->GetWin32(&fa);
|
||||
SetFileTime(hFile,sc ? &fc:NULL,sa ? &fa:NULL,sm ? &fm:NULL);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
void File::SetCloseFileTime(RarTime *ftm,RarTime *fta)
|
||||
{
|
||||
#if defined(_UNIX) || defined(_EMX)
|
||||
SetCloseFileTimeByName(FileName,ftm,fta);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
void File::SetCloseFileTimeByName(const char *Name,RarTime *ftm,RarTime *fta)
|
||||
{
|
||||
#if defined(_UNIX) || defined(_EMX)
|
||||
bool setm=ftm!=NULL && ftm->IsSet();
|
||||
bool seta=fta!=NULL && fta->IsSet();
|
||||
if (setm || seta)
|
||||
{
|
||||
struct utimbuf ut;
|
||||
if (setm)
|
||||
ut.modtime=ftm->GetUnix();
|
||||
else
|
||||
ut.modtime=fta->GetUnix();
|
||||
if (seta)
|
||||
ut.actime=fta->GetUnix();
|
||||
else
|
||||
ut.actime=ut.modtime;
|
||||
utime(Name,&ut);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
void File::GetOpenFileTime(RarTime *ft)
|
||||
{
|
||||
#ifdef _WIN_32
|
||||
FILETIME FileTime;
|
||||
GetFileTime(hFile,NULL,NULL,&FileTime);
|
||||
*ft=FileTime;
|
||||
#endif
|
||||
#if defined(_UNIX) || defined(_EMX)
|
||||
struct stat st;
|
||||
fstat(fileno(hFile),&st);
|
||||
*ft=st.st_mtime;
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
int64 File::FileLength()
|
||||
{
|
||||
SaveFilePos SavePos(*this);
|
||||
Seek(0,SEEK_END);
|
||||
return(Tell());
|
||||
}
|
||||
|
||||
|
||||
void File::SetHandleType(FILE_HANDLETYPE Type)
|
||||
{
|
||||
HandleType=Type;
|
||||
}
|
||||
|
||||
|
||||
bool File::IsDevice()
|
||||
{
|
||||
if (hFile==BAD_HANDLE)
|
||||
return(false);
|
||||
#ifdef _WIN_32
|
||||
uint Type=GetFileType(hFile);
|
||||
return(Type==FILE_TYPE_CHAR || Type==FILE_TYPE_PIPE);
|
||||
#else
|
||||
return(isatty(fileno(hFile)));
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
#ifndef SFX_MODULE
|
||||
void File::fprintf(const char *fmt,...)
|
||||
{
|
||||
va_list argptr;
|
||||
va_start(argptr,fmt);
|
||||
safebuf char Msg[2*NM+1024],OutMsg[2*NM+1024];
|
||||
vsprintf(Msg,fmt,argptr);
|
||||
#ifdef _WIN_32
|
||||
for (int Src=0,Dest=0;;Src++)
|
||||
{
|
||||
char CurChar=Msg[Src];
|
||||
if (CurChar=='\n')
|
||||
OutMsg[Dest++]='\r';
|
||||
OutMsg[Dest++]=CurChar;
|
||||
if (CurChar==0)
|
||||
break;
|
||||
}
|
||||
#else
|
||||
strcpy(OutMsg,Msg);
|
||||
#endif
|
||||
Write(OutMsg,strlen(OutMsg));
|
||||
va_end(argptr);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
bool File::RemoveCreated()
|
||||
{
|
||||
RemoveCreatedActive++;
|
||||
bool RetCode=true;
|
||||
for (int I=0;I<sizeof(CreatedFiles)/sizeof(CreatedFiles[0]);I++)
|
||||
if (CreatedFiles[I]!=NULL)
|
||||
{
|
||||
CreatedFiles[I]->SetExceptions(false);
|
||||
bool Success;
|
||||
if (CreatedFiles[I]->NewFile)
|
||||
Success=CreatedFiles[I]->Delete();
|
||||
else
|
||||
Success=CreatedFiles[I]->Close();
|
||||
if (Success)
|
||||
CreatedFiles[I]=NULL;
|
||||
else
|
||||
RetCode=false;
|
||||
}
|
||||
RemoveCreatedActive--;
|
||||
return(RetCode);
|
||||
}
|
||||
|
||||
|
||||
#ifndef SFX_MODULE
|
||||
int64 File::Copy(File &Dest,int64 Length)
|
||||
{
|
||||
Array<char> Buffer(0x10000);
|
||||
int64 CopySize=0;
|
||||
bool CopyAll=(Length==INT64NDF);
|
||||
|
||||
while (CopyAll || Length>0)
|
||||
{
|
||||
Wait();
|
||||
size_t SizeToRead=(!CopyAll && Length<(int64)Buffer.Size()) ? (size_t)Length:Buffer.Size();
|
||||
int ReadSize=Read(&Buffer[0],SizeToRead);
|
||||
if (ReadSize==0)
|
||||
break;
|
||||
Dest.Write(&Buffer[0],ReadSize);
|
||||
CopySize+=ReadSize;
|
||||
if (!CopyAll)
|
||||
Length-=ReadSize;
|
||||
}
|
||||
return(CopySize);
|
||||
}
|
||||
#endif
|
|
@ -0,0 +1,98 @@
|
|||
#ifndef _RAR_FILE_
|
||||
#define _RAR_FILE_
|
||||
|
||||
#ifdef _WIN_32
|
||||
typedef HANDLE FileHandle;
|
||||
#define BAD_HANDLE INVALID_HANDLE_VALUE
|
||||
#else
|
||||
typedef FILE* FileHandle;
|
||||
#define BAD_HANDLE NULL
|
||||
#endif
|
||||
|
||||
class RAROptions;
|
||||
|
||||
enum FILE_HANDLETYPE {FILE_HANDLENORMAL,FILE_HANDLESTD,FILE_HANDLEERR};
|
||||
|
||||
enum FILE_ERRORTYPE {FILE_SUCCESS,FILE_NOTFOUND,FILE_READERROR};
|
||||
|
||||
struct FileStat
|
||||
{
|
||||
uint FileAttr;
|
||||
uint FileTime;
|
||||
int64 FileSize;
|
||||
bool IsDir;
|
||||
};
|
||||
|
||||
|
||||
class File
|
||||
{
|
||||
private:
|
||||
void AddFileToList(FileHandle hFile);
|
||||
|
||||
FileHandle hFile;
|
||||
bool LastWrite;
|
||||
FILE_HANDLETYPE HandleType;
|
||||
bool SkipClose;
|
||||
bool IgnoreReadErrors;
|
||||
bool NewFile;
|
||||
bool AllowDelete;
|
||||
bool AllowExceptions;
|
||||
#ifdef _WIN_32
|
||||
bool NoSequentialRead;
|
||||
#endif
|
||||
protected:
|
||||
bool OpenShared;
|
||||
public:
|
||||
char FileName[NM];
|
||||
wchar FileNameW[NM];
|
||||
|
||||
FILE_ERRORTYPE ErrorType;
|
||||
|
||||
uint CloseCount;
|
||||
public:
|
||||
File();
|
||||
virtual ~File();
|
||||
void operator = (File &SrcFile);
|
||||
bool Open(const char *Name,const wchar *NameW=NULL,bool OpenShared=false,bool Update=false);
|
||||
void TOpen(const char *Name,const wchar *NameW=NULL);
|
||||
bool WOpen(const char *Name,const wchar *NameW=NULL);
|
||||
bool Create(const char *Name,const wchar *NameW=NULL,bool ShareRead=true);
|
||||
void TCreate(const char *Name,const wchar *NameW=NULL,bool ShareRead=true);
|
||||
bool WCreate(const char *Name,const wchar *NameW=NULL,bool ShareRead=true);
|
||||
bool Close();
|
||||
void Flush();
|
||||
bool Delete();
|
||||
bool Rename(const char *NewName,const wchar *NewNameW=NULL);
|
||||
void Write(const void *Data,size_t Size);
|
||||
int Read(void *Data,size_t Size);
|
||||
int DirectRead(void *Data,size_t Size);
|
||||
void Seek(int64 Offset,int Method);
|
||||
bool RawSeek(int64 Offset,int Method);
|
||||
int64 Tell();
|
||||
void Prealloc(int64 Size);
|
||||
byte GetByte();
|
||||
void PutByte(byte Byte);
|
||||
bool Truncate();
|
||||
void SetOpenFileTime(RarTime *ftm,RarTime *ftc=NULL,RarTime *fta=NULL);
|
||||
void SetCloseFileTime(RarTime *ftm,RarTime *fta=NULL);
|
||||
static void SetCloseFileTimeByName(const char *Name,RarTime *ftm,RarTime *fta);
|
||||
void GetOpenFileTime(RarTime *ft);
|
||||
bool IsOpened() {return(hFile!=BAD_HANDLE);};
|
||||
int64 FileLength();
|
||||
void SetHandleType(FILE_HANDLETYPE Type);
|
||||
FILE_HANDLETYPE GetHandleType() {return(HandleType);};
|
||||
bool IsDevice();
|
||||
void fprintf(const char *fmt,...);
|
||||
static bool RemoveCreated();
|
||||
FileHandle GetHandle() {return(hFile);};
|
||||
void SetIgnoreReadErrors(bool Mode) {IgnoreReadErrors=Mode;};
|
||||
char *GetName() {return(FileName);}
|
||||
int64 Copy(File &Dest,int64 Length=INT64NDF);
|
||||
void SetAllowDelete(bool Allow) {AllowDelete=Allow;}
|
||||
void SetExceptions(bool Allow) {AllowExceptions=Allow;}
|
||||
#ifdef _WIN_32
|
||||
void RemoveSequentialFlag() {NoSequentialRead=true;}
|
||||
#endif
|
||||
};
|
||||
|
||||
#endif
|
|
@ -0,0 +1,585 @@
|
|||
#include "rar.hpp"
|
||||
|
||||
MKDIR_CODE MakeDir(const char *Name,const wchar *NameW,bool SetAttr,uint Attr)
|
||||
{
|
||||
#ifdef _WIN_32
|
||||
int Success;
|
||||
if (WinNT() && NameW!=NULL && *NameW!=0)
|
||||
Success=CreateDirectoryW(NameW,NULL);
|
||||
else
|
||||
Success=CreateDirectory(Name,NULL);
|
||||
if (Success)
|
||||
{
|
||||
if (SetAttr)
|
||||
SetFileAttr(Name,NameW,Attr);
|
||||
return(MKDIR_SUCCESS);
|
||||
}
|
||||
int ErrCode=GetLastError();
|
||||
if (ErrCode==ERROR_FILE_NOT_FOUND || ErrCode==ERROR_PATH_NOT_FOUND)
|
||||
return(MKDIR_BADPATH);
|
||||
return(MKDIR_ERROR);
|
||||
#endif
|
||||
#ifdef _EMX
|
||||
#ifdef _DJGPP
|
||||
if (mkdir(Name,(Attr & FA_RDONLY) ? 0:S_IWUSR)==0)
|
||||
#else
|
||||
if (__mkdir(Name)==0)
|
||||
#endif
|
||||
{
|
||||
if (SetAttr)
|
||||
SetFileAttr(Name,NameW,Attr);
|
||||
return(MKDIR_SUCCESS);
|
||||
}
|
||||
return(errno==ENOENT ? MKDIR_BADPATH:MKDIR_ERROR);
|
||||
#endif
|
||||
#ifdef _UNIX
|
||||
mode_t uattr=SetAttr ? (mode_t)Attr:0777;
|
||||
int ErrCode=Name==NULL ? -1:mkdir(Name,uattr);
|
||||
if (ErrCode==-1)
|
||||
return(errno==ENOENT ? MKDIR_BADPATH:MKDIR_ERROR);
|
||||
return(MKDIR_SUCCESS);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
bool CreatePath(const char *Path,const wchar *PathW,bool SkipLastName)
|
||||
{
|
||||
#if defined(_WIN_32) || defined(_EMX)
|
||||
uint DirAttr=0;
|
||||
#else
|
||||
uint DirAttr=0777;
|
||||
#endif
|
||||
#ifdef UNICODE_SUPPORTED
|
||||
bool Wide=PathW!=NULL && *PathW!=0 && UnicodeEnabled();
|
||||
#else
|
||||
bool Wide=false;
|
||||
#endif
|
||||
bool IgnoreAscii=false;
|
||||
bool Success=true;
|
||||
|
||||
const char *s=Path;
|
||||
for (int PosW=0;;PosW++)
|
||||
{
|
||||
if (s==NULL || s-Path>=NM || *s==0)
|
||||
IgnoreAscii=true;
|
||||
if (Wide && (PosW>=NM || PathW[PosW]==0) || !Wide && IgnoreAscii)
|
||||
break;
|
||||
if (Wide && PathW[PosW]==CPATHDIVIDER || !Wide && *s==CPATHDIVIDER)
|
||||
{
|
||||
wchar *DirPtrW=NULL,DirNameW[NM];
|
||||
if (Wide)
|
||||
{
|
||||
strncpyw(DirNameW,PathW,PosW);
|
||||
DirNameW[PosW]=0;
|
||||
DirPtrW=DirNameW;
|
||||
}
|
||||
char DirName[NM];
|
||||
if (IgnoreAscii)
|
||||
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;
|
||||
}
|
||||
if (MakeDir(DirName,DirPtrW,true,DirAttr)==MKDIR_SUCCESS)
|
||||
{
|
||||
#ifndef GUI
|
||||
mprintf(St(MCreatDir),DirName);
|
||||
mprintf(" %s",St(MOk));
|
||||
#endif
|
||||
}
|
||||
else
|
||||
Success=false;
|
||||
}
|
||||
if (!IgnoreAscii)
|
||||
s=charnext(s);
|
||||
}
|
||||
if (!SkipLastName && !IsPathDiv(*PointToLastChar(Path)))
|
||||
if (MakeDir(Path,PathW,true,DirAttr)!=MKDIR_SUCCESS)
|
||||
Success=false;
|
||||
return(Success);
|
||||
}
|
||||
|
||||
|
||||
void SetDirTime(const char *Name,const wchar *NameW,RarTime *ftm,RarTime *ftc,RarTime *fta)
|
||||
{
|
||||
#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,NameW);
|
||||
bool ResetAttr=(DirAttr!=0xffffffff && (DirAttr & FA_RDONLY)!=0);
|
||||
if (ResetAttr)
|
||||
SetFileAttr(Name,NameW,0);
|
||||
|
||||
wchar DirNameW[NM];
|
||||
GetWideName(Name,NameW,DirNameW);
|
||||
HANDLE hFile=CreateFileW(DirNameW,GENERIC_WRITE,FILE_SHARE_READ|FILE_SHARE_WRITE,
|
||||
NULL,OPEN_EXISTING,FILE_FLAG_BACKUP_SEMANTICS,NULL);
|
||||
if (hFile==INVALID_HANDLE_VALUE)
|
||||
return;
|
||||
FILETIME fm,fc,fa;
|
||||
if (sm)
|
||||
ftm->GetWin32(&fm);
|
||||
if (sc)
|
||||
ftc->GetWin32(&fc);
|
||||
if (sa)
|
||||
fta->GetWin32(&fa);
|
||||
SetFileTime(hFile,sc ? &fc:NULL,sa ? &fa:NULL,sm ? &fm:NULL);
|
||||
CloseHandle(hFile);
|
||||
if (ResetAttr)
|
||||
SetFileAttr(Name,NameW,DirAttr);
|
||||
#endif
|
||||
#if defined(_UNIX) || defined(_EMX)
|
||||
File::SetCloseFileTimeByName(Name,ftm,fta);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
bool IsRemovable(const char *Name)
|
||||
{
|
||||
#ifdef _WIN_32
|
||||
char Root[NM];
|
||||
GetPathRoot(Name,Root);
|
||||
int Type=GetDriveType(*Root ? Root:NULL);
|
||||
return(Type==DRIVE_REMOVABLE || Type==DRIVE_CDROM);
|
||||
#elif defined(_EMX)
|
||||
char Drive=etoupper(Name[0]);
|
||||
return((Drive=='A' || Drive=='B') && Name[1]==':');
|
||||
#else
|
||||
return(false);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
#ifndef SFX_MODULE
|
||||
int64 GetFreeDisk(const char *Name)
|
||||
{
|
||||
#ifdef _WIN_32
|
||||
char Root[NM];
|
||||
GetPathRoot(Name,Root);
|
||||
|
||||
typedef BOOL (WINAPI *GETDISKFREESPACEEX)(
|
||||
LPCTSTR,PULARGE_INTEGER,PULARGE_INTEGER,PULARGE_INTEGER
|
||||
);
|
||||
static GETDISKFREESPACEEX pGetDiskFreeSpaceEx=NULL;
|
||||
|
||||
if (pGetDiskFreeSpaceEx==NULL)
|
||||
{
|
||||
HMODULE hKernel=GetModuleHandle("kernel32.dll");
|
||||
if (hKernel!=NULL)
|
||||
pGetDiskFreeSpaceEx=(GETDISKFREESPACEEX)GetProcAddress(hKernel,"GetDiskFreeSpaceExA");
|
||||
}
|
||||
if (pGetDiskFreeSpaceEx!=NULL)
|
||||
{
|
||||
GetFilePath(Name,Root,ASIZE(Root));
|
||||
ULARGE_INTEGER uiTotalSize,uiTotalFree,uiUserFree;
|
||||
uiUserFree.u.LowPart=uiUserFree.u.HighPart=0;
|
||||
if (pGetDiskFreeSpaceEx(*Root ? Root:NULL,&uiUserFree,&uiTotalSize,&uiTotalFree) &&
|
||||
uiUserFree.u.HighPart<=uiTotalFree.u.HighPart)
|
||||
return(INT32TO64(uiUserFree.u.HighPart,uiUserFree.u.LowPart));
|
||||
}
|
||||
|
||||
// We are here if we failed to load GetDiskFreeSpaceExA.
|
||||
DWORD SectorsPerCluster,BytesPerSector,FreeClusters,TotalClusters;
|
||||
if (!GetDiskFreeSpace(*Root ? Root:NULL,&SectorsPerCluster,&BytesPerSector,&FreeClusters,&TotalClusters))
|
||||
return(1457664);
|
||||
int64 FreeSize=SectorsPerCluster*BytesPerSector;
|
||||
FreeSize=FreeSize*FreeClusters;
|
||||
return(FreeSize);
|
||||
#elif defined(_BEOS)
|
||||
char Root[NM];
|
||||
GetFilePath(Name,Root,ASIZE(Root));
|
||||
dev_t Dev=dev_for_path(*Root ? Root:".");
|
||||
if (Dev<0)
|
||||
return(1457664);
|
||||
fs_info Info;
|
||||
if (fs_stat_dev(Dev,&Info)!=0)
|
||||
return(1457664);
|
||||
int64 FreeSize=Info.block_size;
|
||||
FreeSize=FreeSize*Info.free_blocks;
|
||||
return(FreeSize);
|
||||
#elif defined(_UNIX)
|
||||
return(1457664);
|
||||
#elif defined(_EMX)
|
||||
int Drive=IsDiskLetter(Name) ? etoupper(Name[0])-'A'+1:0;
|
||||
#ifndef _DJGPP
|
||||
if (_osmode == OS2_MODE)
|
||||
{
|
||||
FSALLOCATE fsa;
|
||||
if (DosQueryFSInfo(Drive,1,&fsa,sizeof(fsa))!=0)
|
||||
return(1457664);
|
||||
int64 FreeSize=fsa.cSectorUnit*fsa.cbSector;
|
||||
FreeSize=FreeSize*fsa.cUnitAvail;
|
||||
return(FreeSize);
|
||||
}
|
||||
else
|
||||
#endif
|
||||
{
|
||||
union REGS regs,outregs;
|
||||
memset(®s,0,sizeof(regs));
|
||||
regs.h.ah=0x36;
|
||||
regs.h.dl=Drive;
|
||||
#ifdef _DJGPP
|
||||
int86 (0x21,®s,&outregs);
|
||||
#else
|
||||
_int86 (0x21,®s,&outregs);
|
||||
#endif
|
||||
if (outregs.x.ax==0xffff)
|
||||
return(1457664);
|
||||
int64 FreeSize=outregs.x.ax*outregs.x.cx;
|
||||
FreeSize=FreeSize*outregs.x.bx;
|
||||
return(FreeSize);
|
||||
}
|
||||
#else
|
||||
#define DISABLEAUTODETECT
|
||||
return(1457664);
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
bool FileExist(const char *Name,const wchar *NameW)
|
||||
{
|
||||
#ifdef _WIN_32
|
||||
if (WinNT() && NameW!=NULL && *NameW!=0)
|
||||
return(GetFileAttributesW(NameW)!=0xffffffff);
|
||||
else
|
||||
return(GetFileAttributes(Name)!=0xffffffff);
|
||||
#elif defined(ENABLE_ACCESS)
|
||||
return(access(Name,0)==0);
|
||||
#else
|
||||
struct FindData FD;
|
||||
return(FindFile::FastFind(Name,NameW,&FD));
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
bool WildFileExist(const char *Name,const wchar *NameW)
|
||||
{
|
||||
if (IsWildcard(Name,NameW))
|
||||
{
|
||||
FindFile Find;
|
||||
Find.SetMask(Name);
|
||||
Find.SetMaskW(NameW);
|
||||
struct FindData fd;
|
||||
return(Find.Next(&fd));
|
||||
}
|
||||
return(FileExist(Name,NameW));
|
||||
}
|
||||
|
||||
|
||||
bool IsDir(uint Attr)
|
||||
{
|
||||
#if defined (_WIN_32) || defined(_EMX)
|
||||
return(Attr!=0xffffffff && (Attr & 0x10)!=0);
|
||||
#endif
|
||||
#if defined(_UNIX)
|
||||
return((Attr & 0xF000)==0x4000);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
bool IsUnreadable(uint Attr)
|
||||
{
|
||||
#if defined(_UNIX) && defined(S_ISFIFO) && defined(S_ISSOCK) && defined(S_ISCHR)
|
||||
return(S_ISFIFO(Attr) || S_ISSOCK(Attr) || S_ISCHR(Attr));
|
||||
#endif
|
||||
return(false);
|
||||
}
|
||||
|
||||
|
||||
bool IsLabel(uint Attr)
|
||||
{
|
||||
#if defined (_WIN_32) || defined(_EMX)
|
||||
return((Attr & 8)!=0);
|
||||
#else
|
||||
return(false);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
bool IsLink(uint Attr)
|
||||
{
|
||||
#ifdef _UNIX
|
||||
return((Attr & 0xF000)==0xA000);
|
||||
#else
|
||||
return(false);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
bool IsDeleteAllowed(uint FileAttr)
|
||||
{
|
||||
#if defined(_WIN_32) || defined(_EMX)
|
||||
return((FileAttr & (FA_RDONLY|FA_SYSTEM|FA_HIDDEN))==0);
|
||||
#else
|
||||
return((FileAttr & (S_IRUSR|S_IWUSR))==(S_IRUSR|S_IWUSR));
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
void PrepareToDelete(const char *Name,const wchar *NameW)
|
||||
{
|
||||
#if defined(_WIN_32) || defined(_EMX)
|
||||
SetFileAttr(Name,NameW,0);
|
||||
#endif
|
||||
#ifdef _UNIX
|
||||
chmod(Name,S_IRUSR|S_IWUSR|S_IXUSR);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
uint GetFileAttr(const char *Name,const wchar *NameW)
|
||||
{
|
||||
#ifdef _WIN_32
|
||||
if (WinNT() && NameW!=NULL && *NameW!=0)
|
||||
return(GetFileAttributesW(NameW));
|
||||
else
|
||||
return(GetFileAttributes(Name));
|
||||
#elif defined(_DJGPP)
|
||||
return(_chmod(Name,0));
|
||||
#else
|
||||
struct stat st;
|
||||
if (stat(Name,&st)!=0)
|
||||
return(0);
|
||||
#ifdef _EMX
|
||||
return(st.st_attr);
|
||||
#else
|
||||
return(st.st_mode);
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
bool SetFileAttr(const char *Name,const wchar *NameW,uint Attr)
|
||||
{
|
||||
bool Success;
|
||||
#ifdef _WIN_32
|
||||
if (WinNT() && NameW!=NULL && *NameW!=0)
|
||||
Success=SetFileAttributesW(NameW,Attr)!=0;
|
||||
else
|
||||
Success=SetFileAttributes(Name,Attr)!=0;
|
||||
#elif defined(_DJGPP)
|
||||
Success=_chmod(Name,1,Attr)!=-1;
|
||||
#elif defined(_EMX)
|
||||
Success=__chmod(Name,1,Attr)!=-1;
|
||||
#elif defined(_UNIX)
|
||||
Success=chmod(Name,(mode_t)Attr)==0;
|
||||
#else
|
||||
Success=false;
|
||||
#endif
|
||||
return(Success);
|
||||
}
|
||||
|
||||
|
||||
void ConvertNameToFull(const char *Src,char *Dest)
|
||||
{
|
||||
#ifdef _WIN_32
|
||||
#ifndef _WIN_CE
|
||||
char FullName[NM],*NamePtr;
|
||||
if (GetFullPathName(Src,sizeof(FullName),FullName,&NamePtr))
|
||||
strcpy(Dest,FullName);
|
||||
else
|
||||
#endif
|
||||
if (Src!=Dest)
|
||||
strcpy(Dest,Src);
|
||||
#else
|
||||
char FullName[NM];
|
||||
if (IsPathDiv(*Src) || IsDiskLetter(Src))
|
||||
strcpy(FullName,Src);
|
||||
else
|
||||
{
|
||||
if (getcwd(FullName,sizeof(FullName))==NULL)
|
||||
*FullName=0;
|
||||
else
|
||||
AddEndSlash(FullName);
|
||||
strcat(FullName,Src);
|
||||
}
|
||||
strcpy(Dest,FullName);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
#ifndef SFX_MODULE
|
||||
void ConvertNameToFull(const wchar *Src,wchar *Dest)
|
||||
{
|
||||
if (Src==NULL || *Src==0)
|
||||
{
|
||||
*Dest=0;
|
||||
return;
|
||||
}
|
||||
#ifdef _WIN_32
|
||||
#ifndef _WIN_CE
|
||||
if (WinNT())
|
||||
#endif
|
||||
{
|
||||
#ifndef _WIN_CE
|
||||
wchar FullName[NM],*NamePtr;
|
||||
if (GetFullPathNameW(Src,sizeof(FullName)/sizeof(FullName[0]),FullName,&NamePtr))
|
||||
strcpyw(Dest,FullName);
|
||||
else
|
||||
#endif
|
||||
if (Src!=Dest)
|
||||
strcpyw(Dest,Src);
|
||||
}
|
||||
#ifndef _WIN_CE
|
||||
else
|
||||
{
|
||||
char AnsiName[NM];
|
||||
WideToChar(Src,AnsiName);
|
||||
ConvertNameToFull(AnsiName,AnsiName);
|
||||
CharToWide(AnsiName,Dest);
|
||||
}
|
||||
#endif
|
||||
#else
|
||||
char AnsiName[NM];
|
||||
WideToChar(Src,AnsiName);
|
||||
ConvertNameToFull(AnsiName,AnsiName);
|
||||
CharToWide(AnsiName,Dest);
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
#ifndef SFX_MODULE
|
||||
char *MkTemp(char *Name)
|
||||
{
|
||||
size_t Length=strlen(Name);
|
||||
if (Length<=6)
|
||||
return(NULL);
|
||||
int Random=clock();
|
||||
for (int Attempt=0;;Attempt++)
|
||||
{
|
||||
sprintf(Name+Length-6,"%06u",Random+Attempt);
|
||||
Name[Length-4]='.';
|
||||
if (!FileExist(Name))
|
||||
break;
|
||||
if (Attempt==1000)
|
||||
return(NULL);
|
||||
}
|
||||
return(Name);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
|
||||
#ifndef SFX_MODULE
|
||||
uint CalcFileCRC(File *SrcFile,int64 Size,CALCCRC_SHOWMODE ShowMode)
|
||||
{
|
||||
SaveFilePos SavePos(*SrcFile);
|
||||
const size_t BufSize=0x10000;
|
||||
Array<byte> Data(BufSize);
|
||||
int64 BlockCount=0;
|
||||
uint DataCRC=0xffffffff;
|
||||
|
||||
#if !defined(SILENT) && !defined(_WIN_CE)
|
||||
int64 FileLength=SrcFile->FileLength();
|
||||
if (ShowMode!=CALCCRC_SHOWNONE)
|
||||
{
|
||||
mprintf(St(MCalcCRC));
|
||||
mprintf(" ");
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
SrcFile->Seek(0,SEEK_SET);
|
||||
while (true)
|
||||
{
|
||||
size_t SizeToRead;
|
||||
if (Size==INT64NDF) // If we process the entire file.
|
||||
SizeToRead=BufSize; // Then always attempt to read the entire buffer.
|
||||
else
|
||||
SizeToRead=(size_t)Min((int64)BufSize,Size);
|
||||
int ReadSize=SrcFile->Read(&Data[0],SizeToRead);
|
||||
if (ReadSize==0)
|
||||
break;
|
||||
|
||||
++BlockCount;
|
||||
if ((BlockCount & 15)==0)
|
||||
{
|
||||
#if !defined(SILENT) && !defined(_WIN_CE)
|
||||
if (ShowMode==CALCCRC_SHOWALL)
|
||||
mprintf("\b\b\b\b%3d%%",ToPercent(BlockCount*int64(BufSize),FileLength));
|
||||
#endif
|
||||
Wait();
|
||||
}
|
||||
DataCRC=CRC(DataCRC,&Data[0],ReadSize);
|
||||
if (Size!=INT64NDF)
|
||||
Size-=ReadSize;
|
||||
}
|
||||
#if !defined(SILENT) && !defined(_WIN_CE)
|
||||
if (ShowMode==CALCCRC_SHOWALL)
|
||||
mprintf("\b\b\b\b ");
|
||||
#endif
|
||||
return(DataCRC^0xffffffff);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
bool RenameFile(const char *SrcName,const wchar *SrcNameW,const char *DestName,const wchar *DestNameW)
|
||||
{
|
||||
return(rename(SrcName,DestName)==0);
|
||||
}
|
||||
|
||||
|
||||
bool DelFile(const char *Name)
|
||||
{
|
||||
return(DelFile(Name,NULL));
|
||||
}
|
||||
|
||||
|
||||
bool DelFile(const char *Name,const wchar *NameW)
|
||||
{
|
||||
return(remove(Name)==0);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#if defined(_WIN_32) && !defined(_WIN_CE) && !defined(SFX_MODULE)
|
||||
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
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
@ -0,0 +1,44 @@
|
|||
#ifndef _RAR_FILEFN_
|
||||
#define _RAR_FILEFN_
|
||||
|
||||
enum MKDIR_CODE {MKDIR_SUCCESS,MKDIR_ERROR,MKDIR_BADPATH};
|
||||
|
||||
MKDIR_CODE MakeDir(const char *Name,const wchar *NameW,bool SetAttr,uint Attr);
|
||||
bool CreatePath(const char *Path,const wchar *PathW,bool SkipLastName);
|
||||
void SetDirTime(const char *Name,const wchar *NameW,RarTime *ftm,RarTime *ftc,RarTime *fta);
|
||||
bool IsRemovable(const char *Name);
|
||||
int64 GetFreeDisk(const char *Name);
|
||||
bool FileExist(const char *Name,const wchar *NameW=NULL);
|
||||
bool WildFileExist(const char *Name,const wchar *NameW=NULL);
|
||||
bool IsDir(uint Attr);
|
||||
bool IsUnreadable(uint Attr);
|
||||
bool IsLabel(uint Attr);
|
||||
bool IsLink(uint Attr);
|
||||
void SetSFXMode(const char *FileName);
|
||||
void EraseDiskContents(const char *FileName);
|
||||
bool IsDeleteAllowed(uint FileAttr);
|
||||
void PrepareToDelete(const char *Name,const wchar *NameW=NULL);
|
||||
uint GetFileAttr(const char *Name,const wchar *NameW=NULL);
|
||||
bool SetFileAttr(const char *Name,const wchar *NameW,uint Attr);
|
||||
void ConvertNameToFull(const char *Src,char *Dest);
|
||||
void ConvertNameToFull(const wchar *Src,wchar *Dest);
|
||||
char* MkTemp(char *Name);
|
||||
|
||||
|
||||
enum CALCCRC_SHOWMODE {CALCCRC_SHOWNONE,CALCCRC_SHOWTEXT,CALCCRC_SHOWALL};
|
||||
uint CalcFileCRC(File *SrcFile,int64 Size=INT64NDF,CALCCRC_SHOWMODE ShowMode=CALCCRC_SHOWNONE);
|
||||
|
||||
bool RenameFile(const char *SrcName,const wchar *SrcNameW,const char *DestName,const wchar *DestNameW);
|
||||
bool DelFile(const char *Name);
|
||||
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
|
|
@ -0,0 +1,189 @@
|
|||
#include "rar.hpp"
|
||||
|
||||
static bool IsUnicode(byte *Data,int Size);
|
||||
|
||||
bool ReadTextFile(const char *Name,StringList *List,bool Config,
|
||||
bool AbortOnError,RAR_CHARSET SrcCharset,bool Unquote,
|
||||
bool SkipComments,bool ExpandEnvStr)
|
||||
{
|
||||
char FileName[NM];
|
||||
if (Config)
|
||||
GetConfigName(Name,FileName,true);
|
||||
else
|
||||
strcpy(FileName,Name);
|
||||
|
||||
File SrcFile;
|
||||
if (*FileName)
|
||||
{
|
||||
bool OpenCode=AbortOnError ? SrcFile.WOpen(FileName):SrcFile.Open(FileName);
|
||||
|
||||
if (!OpenCode)
|
||||
{
|
||||
if (AbortOnError)
|
||||
ErrHandler.Exit(OPEN_ERROR);
|
||||
return(false);
|
||||
}
|
||||
}
|
||||
else
|
||||
SrcFile.SetHandleType(FILE_HANDLESTD);
|
||||
|
||||
unsigned int DataSize=0,ReadSize;
|
||||
const int ReadBlock=1024;
|
||||
Array<char> Data(ReadBlock+5);
|
||||
while ((ReadSize=SrcFile.Read(&Data[DataSize],ReadBlock))!=0)
|
||||
{
|
||||
DataSize+=ReadSize;
|
||||
Data.Add(ReadSize);
|
||||
}
|
||||
|
||||
memset(&Data[DataSize],0,5);
|
||||
|
||||
if (SrcCharset==RCH_UNICODE ||
|
||||
SrcCharset==RCH_DEFAULT && IsUnicode((byte *)&Data[0],DataSize))
|
||||
{
|
||||
// Unicode in native system format, can be more than 2 bytes per character.
|
||||
Array<wchar> DataW(Data.Size()/2+1);
|
||||
for (size_t I=2;I<Data.Size()-1;I+=2)
|
||||
{
|
||||
// Need to convert Data to (byte) first to prevent the sign extension
|
||||
// to higher bytes.
|
||||
DataW[(I-2)/2]=(wchar)((byte)Data[I])+(wchar)((byte)Data[I+1])*256;
|
||||
}
|
||||
|
||||
wchar *CurStr=&DataW[0];
|
||||
Array<char> AnsiName;
|
||||
|
||||
while (*CurStr!=0)
|
||||
{
|
||||
wchar *NextStr=CurStr,*CmtPtr=NULL;
|
||||
while (*NextStr!='\r' && *NextStr!='\n' && *NextStr!=0)
|
||||
{
|
||||
if (SkipComments && NextStr[0]=='/' && NextStr[1]=='/')
|
||||
{
|
||||
*NextStr=0;
|
||||
CmtPtr=NextStr;
|
||||
}
|
||||
NextStr++;
|
||||
}
|
||||
*NextStr=0;
|
||||
for (wchar *SpacePtr=(CmtPtr ? CmtPtr:NextStr)-1;SpacePtr>=CurStr;SpacePtr--)
|
||||
{
|
||||
if (*SpacePtr!=' ' && *SpacePtr!='\t')
|
||||
break;
|
||||
*SpacePtr=0;
|
||||
}
|
||||
if (*CurStr)
|
||||
{
|
||||
// Length and AddSize must be defined as signed, because AddSize
|
||||
// can be negative.
|
||||
int Length=(int)strlenw(CurStr);
|
||||
int AddSize=4*(Length-(int)AnsiName.Size()+1);
|
||||
|
||||
if (AddSize>0)
|
||||
AnsiName.Add(AddSize);
|
||||
if (Unquote && *CurStr=='\"' && CurStr[Length-1]=='\"')
|
||||
{
|
||||
CurStr[Length-1]=0;
|
||||
CurStr++;
|
||||
}
|
||||
WideToChar(CurStr,&AnsiName[0],AnsiName.Size());
|
||||
|
||||
bool Expanded=false;
|
||||
#if defined(_WIN_32) && !defined(_WIN_CE)
|
||||
if (ExpandEnvStr && *CurStr=='%')
|
||||
{
|
||||
// expanding environment variables in Windows version
|
||||
|
||||
char ExpName[NM];
|
||||
wchar ExpNameW[NM];
|
||||
*ExpNameW=0;
|
||||
int ret,retw=1;
|
||||
ret=ExpandEnvironmentStrings(&AnsiName[0],ExpName,ASIZE(ExpName));
|
||||
if (ret!=0 && WinNT())
|
||||
retw=ExpandEnvironmentStringsW(CurStr,ExpNameW,ASIZE(ExpNameW));
|
||||
Expanded=ret!=0 && ret<ASIZE(ExpName) &&
|
||||
retw!=0 && retw<ASIZE(ExpNameW);
|
||||
if (Expanded)
|
||||
List->AddString(ExpName,ExpNameW);
|
||||
}
|
||||
#endif
|
||||
if (!Expanded)
|
||||
List->AddString(&AnsiName[0],CurStr);
|
||||
}
|
||||
CurStr=NextStr+1;
|
||||
while (*CurStr=='\r' || *CurStr=='\n')
|
||||
CurStr++;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
char *CurStr=&Data[0];
|
||||
while (*CurStr!=0)
|
||||
{
|
||||
char *NextStr=CurStr,*CmtPtr=NULL;
|
||||
while (*NextStr!='\r' && *NextStr!='\n' && *NextStr!=0)
|
||||
{
|
||||
if (SkipComments && NextStr[0]=='/' && NextStr[1]=='/')
|
||||
{
|
||||
*NextStr=0;
|
||||
CmtPtr=NextStr;
|
||||
}
|
||||
NextStr++;
|
||||
}
|
||||
*NextStr=0;
|
||||
for (char *SpacePtr=(CmtPtr ? CmtPtr:NextStr)-1;SpacePtr>=CurStr;SpacePtr--)
|
||||
{
|
||||
if (*SpacePtr!=' ' && *SpacePtr!='\t')
|
||||
break;
|
||||
*SpacePtr=0;
|
||||
}
|
||||
if (*CurStr)
|
||||
{
|
||||
if (Unquote && *CurStr=='\"')
|
||||
{
|
||||
size_t Length=strlen(CurStr);
|
||||
if (CurStr[Length-1]=='\"')
|
||||
{
|
||||
CurStr[Length-1]=0;
|
||||
CurStr++;
|
||||
}
|
||||