Browse Source

initial for idea

Andrew Dolgov 4 years ago
parent
commit
124f869faa
100 changed files with 12742 additions and 0 deletions
  1. 11 0
      .gitignore
  2. 1 0
      .idea/.name
  3. 23 0
      .idea/compiler.xml
  4. 3 0
      .idea/copyright/profiles_settings.xml
  5. 5 0
      .idea/encodings.xml
  6. 18 0
      .idea/gradle.xml
  7. 23 0
      .idea/misc.xml
  8. 10 0
      .idea/modules.xml
  9. 5 0
      .idea/scopes/scope_settings.xml
  10. 7 0
      .idea/vcs.xml
  11. 19 0
      Tiny-Comics-Reader.iml
  12. 15 0
      build.gradle
  13. BIN
      gradle/wrapper/gradle-wrapper.jar
  14. 6 0
      gradle/wrapper/gradle-wrapper.properties
  15. 164 0
      gradlew
  16. 90 0
      gradlew.bat
  17. 25 0
      org.fox.ttcomics/build.gradle
  18. 88 0
      org.fox.ttcomics/org.fox.ttcomics.iml
  19. 54 0
      org.fox.ttcomics/src/main/AndroidManifest.xml
  20. 583 0
      org.fox.ttcomics/src/main/java/com/github/junrar/Archive.java
  21. 56 0
      org.fox.ttcomics/src/main/java/com/github/junrar/MVTest.java
  22. 21 0
      org.fox.ttcomics/src/main/java/com/github/junrar/UnrarCallback.java
  23. 44 0
      org.fox.ttcomics/src/main/java/com/github/junrar/Volume.java
  24. 28 0
      org.fox.ttcomics/src/main/java/com/github/junrar/VolumeManager.java
  25. 145 0
      org.fox.ttcomics/src/main/java/com/github/junrar/crc/RarCRC.java
  26. 27 0
      org.fox.ttcomics/src/main/java/com/github/junrar/crypt/Rijndael.java
  27. 73 0
      org.fox.ttcomics/src/main/java/com/github/junrar/exception/RarException.java
  28. 65 0
      org.fox.ttcomics/src/main/java/com/github/junrar/impl/FileVolume.java
  29. 54 0
      org.fox.ttcomics/src/main/java/com/github/junrar/impl/FileVolumeManager.java
  30. 61 0
      org.fox.ttcomics/src/main/java/com/github/junrar/io/IReadOnlyAccess.java
  31. 59 0
      org.fox.ttcomics/src/main/java/com/github/junrar/io/InputStreamReadOnlyAccessFile.java
  32. 203 0
      org.fox.ttcomics/src/main/java/com/github/junrar/io/RandomAccessStream.java
  33. 305 0
      org.fox.ttcomics/src/main/java/com/github/junrar/io/Raw.java
  34. 90 0
      org.fox.ttcomics/src/main/java/com/github/junrar/io/ReadOnlyAccessByteArray.java
  35. 55 0
      org.fox.ttcomics/src/main/java/com/github/junrar/io/ReadOnlyAccessFile.java
  36. 81 0
      org.fox.ttcomics/src/main/java/com/github/junrar/io/ReadOnlyAccessInputStream.java
  37. 66 0
      org.fox.ttcomics/src/main/java/com/github/junrar/rarfile/AVHeader.java
  38. 179 0
      org.fox.ttcomics/src/main/java/com/github/junrar/rarfile/BaseBlock.java
  39. 70 0
      org.fox.ttcomics/src/main/java/com/github/junrar/rarfile/BlockHeader.java
  40. 70 0
      org.fox.ttcomics/src/main/java/com/github/junrar/rarfile/CommentHeader.java
  41. 90 0
      org.fox.ttcomics/src/main/java/com/github/junrar/rarfile/EAHeader.java
  42. 63 0
      org.fox.ttcomics/src/main/java/com/github/junrar/rarfile/EndArcHeader.java
  43. 421 0
      org.fox.ttcomics/src/main/java/com/github/junrar/rarfile/FileHeader.java
  44. 76 0
      org.fox.ttcomics/src/main/java/com/github/junrar/rarfile/FileNameDecoder.java
  45. 72 0
      org.fox.ttcomics/src/main/java/com/github/junrar/rarfile/HostSystem.java
  46. 81 0
      org.fox.ttcomics/src/main/java/com/github/junrar/rarfile/MacInfoHeader.java
  47. 141 0
      org.fox.ttcomics/src/main/java/com/github/junrar/rarfile/MainHeader.java
  48. 84 0
      org.fox.ttcomics/src/main/java/com/github/junrar/rarfile/MarkHeader.java
  49. 89 0
      org.fox.ttcomics/src/main/java/com/github/junrar/rarfile/NewSubHeaderType.java
  50. 71 0
      org.fox.ttcomics/src/main/java/com/github/junrar/rarfile/ProtectHeader.java
  51. 60 0
      org.fox.ttcomics/src/main/java/com/github/junrar/rarfile/SignHeader.java
  52. 70 0
      org.fox.ttcomics/src/main/java/com/github/junrar/rarfile/SubBlockHeader.java
  53. 77 0
      org.fox.ttcomics/src/main/java/com/github/junrar/rarfile/SubBlockHeaderType.java
  54. 93 0
      org.fox.ttcomics/src/main/java/com/github/junrar/rarfile/UnixOwnersHeader.java
  55. 164 0
      org.fox.ttcomics/src/main/java/com/github/junrar/rarfile/UnrarHeadertype.java
  56. 362 0
      org.fox.ttcomics/src/main/java/com/github/junrar/unpack/ComprDataIO.java
  57. 1051 0
      org.fox.ttcomics/src/main/java/com/github/junrar/unpack/Unpack.java
  58. 620 0
      org.fox.ttcomics/src/main/java/com/github/junrar/unpack/Unpack15.java
  59. 597 0
      org.fox.ttcomics/src/main/java/com/github/junrar/unpack/Unpack20.java
  60. 94 0
      org.fox.ttcomics/src/main/java/com/github/junrar/unpack/UnpackFilter.java
  61. 144 0
      org.fox.ttcomics/src/main/java/com/github/junrar/unpack/decode/AudioVariables.java
  62. 35 0
      org.fox.ttcomics/src/main/java/com/github/junrar/unpack/decode/BitDecode.java
  63. 29 0
      org.fox.ttcomics/src/main/java/com/github/junrar/unpack/decode/CodeType.java
  64. 45 0
      org.fox.ttcomics/src/main/java/com/github/junrar/unpack/decode/Compress.java
  65. 81 0
      org.fox.ttcomics/src/main/java/com/github/junrar/unpack/decode/Decode.java
  66. 37 0
      org.fox.ttcomics/src/main/java/com/github/junrar/unpack/decode/DistDecode.java
  67. 30 0
      org.fox.ttcomics/src/main/java/com/github/junrar/unpack/decode/FilterType.java
  68. 36 0
      org.fox.ttcomics/src/main/java/com/github/junrar/unpack/decode/LitDecode.java
  69. 37 0
      org.fox.ttcomics/src/main/java/com/github/junrar/unpack/decode/LowDistDecode.java
  70. 37 0
      org.fox.ttcomics/src/main/java/com/github/junrar/unpack/decode/MultDecode.java
  71. 36 0
      org.fox.ttcomics/src/main/java/com/github/junrar/unpack/decode/RepDecode.java
  72. 94 0
      org.fox.ttcomics/src/main/java/com/github/junrar/unpack/ppm/AnalyzeHeapDump.java
  73. 58 0
      org.fox.ttcomics/src/main/java/com/github/junrar/unpack/ppm/BlockTypes.java
  74. 87 0
      org.fox.ttcomics/src/main/java/com/github/junrar/unpack/ppm/FreqData.java
  75. 696 0
      org.fox.ttcomics/src/main/java/com/github/junrar/unpack/ppm/ModelPPM.java
  76. 477 0
      org.fox.ttcomics/src/main/java/com/github/junrar/unpack/ppm/PPMContext.java
  77. 59 0
      org.fox.ttcomics/src/main/java/com/github/junrar/unpack/ppm/Pointer.java
  78. 177 0
      org.fox.ttcomics/src/main/java/com/github/junrar/unpack/ppm/RangeCoder.java
  79. 139 0
      org.fox.ttcomics/src/main/java/com/github/junrar/unpack/ppm/RarMemBlock.java
  80. 69 0
      org.fox.ttcomics/src/main/java/com/github/junrar/unpack/ppm/RarNode.java
  81. 102 0
      org.fox.ttcomics/src/main/java/com/github/junrar/unpack/ppm/SEE2Context.java
  82. 119 0
      org.fox.ttcomics/src/main/java/com/github/junrar/unpack/ppm/State.java
  83. 92 0
      org.fox.ttcomics/src/main/java/com/github/junrar/unpack/ppm/StateRef.java
  84. 427 0
      org.fox.ttcomics/src/main/java/com/github/junrar/unpack/ppm/SubAllocator.java
  85. 108 0
      org.fox.ttcomics/src/main/java/com/github/junrar/unpack/vm/BitInput.java
  86. 1221 0
      org.fox.ttcomics/src/main/java/com/github/junrar/unpack/vm/RarVM.java
  87. 81 0
      org.fox.ttcomics/src/main/java/com/github/junrar/unpack/vm/VMCmdFlags.java
  88. 226 0
      org.fox.ttcomics/src/main/java/com/github/junrar/unpack/vm/VMCommands.java
  89. 79 0
      org.fox.ttcomics/src/main/java/com/github/junrar/unpack/vm/VMFlags.java
  90. 66 0
      org.fox.ttcomics/src/main/java/com/github/junrar/unpack/vm/VMOpType.java
  91. 57 0
      org.fox.ttcomics/src/main/java/com/github/junrar/unpack/vm/VMPreparedCommand.java
  92. 58 0
      org.fox.ttcomics/src/main/java/com/github/junrar/unpack/vm/VMPreparedOperand.java
  93. 127 0
      org.fox.ttcomics/src/main/java/com/github/junrar/unpack/vm/VMPreparedProgram.java
  94. 64 0
      org.fox.ttcomics/src/main/java/com/github/junrar/unpack/vm/VMStandardFilterSignature.java
  95. 79 0
      org.fox.ttcomics/src/main/java/com/github/junrar/unpack/vm/VMStandardFilters.java
  96. 68 0
      org.fox.ttcomics/src/main/java/com/github/junrar/unsigned/UnsignedByte.java
  97. 29 0
      org.fox.ttcomics/src/main/java/com/github/junrar/unsigned/UnsignedInteger.java
  98. 29 0
      org.fox.ttcomics/src/main/java/com/github/junrar/unsigned/UnsignedLong.java
  99. 29 0
      org.fox.ttcomics/src/main/java/com/github/junrar/unsigned/UnsignedShort.java
  100. 0 0
      org.fox.ttcomics/src/main/java/com/github/junrar/util/VolumeHelper.java

+ 11 - 0
.gitignore

@@ -0,0 +1,11 @@
+bin/
+gen/
+.gradle/
+build/
+local.properties
+import-summary.txt
+Thumbs.db
+.idea/workspace.xml
+.idea/tasks.xml
+.idea/datasources.xml
+.idea/dataSources.ids

+ 1 - 0
.idea/.name

@@ -0,0 +1 @@
+Tiny-Comics-Reader

+ 23 - 0
.idea/compiler.xml

@@ -0,0 +1,23 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project version="4">
+  <component name="CompilerConfiguration">
+    <option name="DEFAULT_COMPILER" value="Javac" />
+    <resourceExtensions />
+    <wildcardResourcePatterns>
+      <entry name="!?*.java" />
+      <entry name="!?*.form" />
+      <entry name="!?*.class" />
+      <entry name="!?*.groovy" />
+      <entry name="!?*.scala" />
+      <entry name="!?*.flex" />
+      <entry name="!?*.kt" />
+      <entry name="!?*.clj" />
+    </wildcardResourcePatterns>
+    <annotationProcessing>
+      <profile default="true" name="Default" enabled="false">
+        <processorPath useClasspath="true" />
+      </profile>
+    </annotationProcessing>
+  </component>
+</project>
+

+ 3 - 0
.idea/copyright/profiles_settings.xml

@@ -0,0 +1,3 @@
+<component name="CopyrightManager">
+  <settings default="" />
+</component>

+ 5 - 0
.idea/encodings.xml

@@ -0,0 +1,5 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project version="4">
+  <component name="Encoding" useUTFGuessing="true" native2AsciiForPropertiesFiles="false" />
+</project>
+

+ 18 - 0
.idea/gradle.xml

@@ -0,0 +1,18 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project version="4">
+  <component name="GradleSettings">
+    <option name="linkedExternalProjectsSettings">
+      <GradleProjectSettings>
+        <option name="distributionType" value="DEFAULT_WRAPPED" />
+        <option name="externalProjectPath" value="$PROJECT_DIR$" />
+        <option name="modules">
+          <set>
+            <option value="$PROJECT_DIR$" />
+            <option value="$PROJECT_DIR$/org.fox.ttcomics" />
+          </set>
+        </option>
+      </GradleProjectSettings>
+    </option>
+  </component>
+</project>
+

+ 23 - 0
.idea/misc.xml

@@ -0,0 +1,23 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project version="4">
+  <component name="ProjectRootManager" version="2" languageLevel="JDK_1_6" assert-keyword="true" jdk-15="true" project-jdk-name="JDK" project-jdk-type="JavaSDK">
+    <output url="file://$PROJECT_DIR$/build/classes" />
+  </component>
+  <component name="masterDetails">
+    <states>
+      <state key="ProjectJDKs.UI">
+        <settings>
+          <last-edited>Android API 19 Platform</last-edited>
+          <splitter-proportions>
+            <option name="proportions">
+              <list>
+                <option value="0.2" />
+              </list>
+            </option>
+          </splitter-proportions>
+        </settings>
+      </state>
+    </states>
+  </component>
+</project>
+

+ 10 - 0
.idea/modules.xml

@@ -0,0 +1,10 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project version="4">
+  <component name="ProjectModuleManager">
+    <modules>
+      <module fileurl="file://$PROJECT_DIR$/Tiny-Comics-Reader.iml" filepath="$PROJECT_DIR$/Tiny-Comics-Reader.iml" />
+      <module fileurl="file://$PROJECT_DIR$/org.fox.ttcomics/org.fox.ttcomics.iml" filepath="$PROJECT_DIR$/org.fox.ttcomics/org.fox.ttcomics.iml" />
+    </modules>
+  </component>
+</project>
+

+ 5 - 0
.idea/scopes/scope_settings.xml

@@ -0,0 +1,5 @@
+<component name="DependencyValidationManager">
+  <state>
+    <option name="SKIP_IMPORT_STATEMENTS" value="false" />
+  </state>
+</component>

+ 7 - 0
.idea/vcs.xml

@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project version="4">
+  <component name="VcsDirectoryMappings">
+    <mapping directory="$PROJECT_DIR$" vcs="Git" />
+  </component>
+</project>
+

+ 19 - 0
Tiny-Comics-Reader.iml

@@ -0,0 +1,19 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<module external.linked.project.path="$MODULE_DIR$" external.root.project.path="$MODULE_DIR$" external.system.id="GRADLE" external.system.module.group="" external.system.module.version="unspecified" type="JAVA_MODULE" version="4">
+  <component name="FacetManager">
+    <facet type="java-gradle" name="Java-Gradle">
+      <configuration>
+        <option name="BUILD_FOLDER_PATH" value="$MODULE_DIR$/build" />
+      </configuration>
+    </facet>
+  </component>
+  <component name="NewModuleRootManager" inherit-compiler-output="true">
+    <exclude-output />
+    <content url="file://$MODULE_DIR$">
+      <excludeFolder url="file://$MODULE_DIR$/.gradle" />
+    </content>
+    <orderEntry type="inheritedJdk" />
+    <orderEntry type="sourceFolder" forTests="false" />
+  </component>
+</module>
+

+ 15 - 0
build.gradle

@@ -0,0 +1,15 @@
+// Top-level build file where you can add configuration options common to all sub-projects/modules.
+buildscript {
+    repositories {
+        jcenter()
+    }
+    dependencies {
+        classpath 'com.android.tools.build:gradle:0.12.2'
+    }
+}
+
+allprojects {
+    repositories {
+        jcenter()
+    }
+}

BIN
gradle/wrapper/gradle-wrapper.jar


+ 6 - 0
gradle/wrapper/gradle-wrapper.properties

@@ -0,0 +1,6 @@
+#Wed Apr 10 15:27:10 PDT 2013
+distributionBase=GRADLE_USER_HOME
+distributionPath=wrapper/dists
+zipStoreBase=GRADLE_USER_HOME
+zipStorePath=wrapper/dists
+distributionUrl=http\://services.gradle.org/distributions/gradle-1.12-all.zip

+ 164 - 0
gradlew

@@ -0,0 +1,164 @@
+#!/usr/bin/env bash
+
+##############################################################################
+##
+##  Gradle start up script for UN*X
+##
+##############################################################################
+
+# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
+DEFAULT_JVM_OPTS=""
+
+APP_NAME="Gradle"
+APP_BASE_NAME=`basename "$0"`
+
+# Use the maximum available, or set MAX_FD != -1 to use that value.
+MAX_FD="maximum"
+
+warn ( ) {
+    echo "$*"
+}
+
+die ( ) {
+    echo
+    echo "$*"
+    echo
+    exit 1
+}
+
+# OS specific support (must be 'true' or 'false').
+cygwin=false
+msys=false
+darwin=false
+case "`uname`" in
+  CYGWIN* )
+    cygwin=true
+    ;;
+  Darwin* )
+    darwin=true
+    ;;
+  MINGW* )
+    msys=true
+    ;;
+esac
+
+# For Cygwin, ensure paths are in UNIX format before anything is touched.
+if $cygwin ; then
+    [ -n "$JAVA_HOME" ] && JAVA_HOME=`cygpath --unix "$JAVA_HOME"`
+fi
+
+# Attempt to set APP_HOME
+# Resolve links: $0 may be a link
+PRG="$0"
+# Need this for relative symlinks.
+while [ -h "$PRG" ] ; do
+    ls=`ls -ld "$PRG"`
+    link=`expr "$ls" : '.*-> \(.*\)$'`
+    if expr "$link" : '/.*' > /dev/null; then
+        PRG="$link"
+    else
+        PRG=`dirname "$PRG"`"/$link"
+    fi
+done
+SAVED="`pwd`"
+cd "`dirname \"$PRG\"`/" >&-
+APP_HOME="`pwd -P`"
+cd "$SAVED" >&-
+
+CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
+
+# Determine the Java command to use to start the JVM.
+if [ -n "$JAVA_HOME" ] ; then
+    if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
+        # IBM's JDK on AIX uses strange locations for the executables
+        JAVACMD="$JAVA_HOME/jre/sh/java"
+    else
+        JAVACMD="$JAVA_HOME/bin/java"
+    fi
+    if [ ! -x "$JAVACMD" ] ; then
+        die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
+
+Please set the JAVA_HOME variable in your environment to match the
+location of your Java installation."
+    fi
+else
+    JAVACMD="java"
+    which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
+
+Please set the JAVA_HOME variable in your environment to match the
+location of your Java installation."
+fi
+
+# Increase the maximum file descriptors if we can.
+if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then
+    MAX_FD_LIMIT=`ulimit -H -n`
+    if [ $? -eq 0 ] ; then
+        if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
+            MAX_FD="$MAX_FD_LIMIT"
+        fi
+        ulimit -n $MAX_FD
+        if [ $? -ne 0 ] ; then
+            warn "Could not set maximum file descriptor limit: $MAX_FD"
+        fi
+    else
+        warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
+    fi
+fi
+
+# For Darwin, add options to specify how the application appears in the dock
+if $darwin; then
+    GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
+fi
+
+# For Cygwin, switch paths to Windows format before running java
+if $cygwin ; then
+    APP_HOME=`cygpath --path --mixed "$APP_HOME"`
+    CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
+
+    # We build the pattern for arguments to be converted via cygpath
+    ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
+    SEP=""
+    for dir in $ROOTDIRSRAW ; do
+        ROOTDIRS="$ROOTDIRS$SEP$dir"
+        SEP="|"
+    done
+    OURCYGPATTERN="(^($ROOTDIRS))"
+    # Add a user-defined pattern to the cygpath arguments
+    if [ "$GRADLE_CYGPATTERN" != "" ] ; then
+        OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
+    fi
+    # Now convert the arguments - kludge to limit ourselves to /bin/sh
+    i=0
+    for arg in "[email protected]" ; do
+        CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
+        CHECK2=`echo "$arg"|egrep -c "^-"`                                 ### Determine if an option
+
+        if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then                    ### Added a condition
+            eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
+        else
+            eval `echo args$i`="\"$arg\""
+        fi
+        i=$((i+1))
+    done
+    case $i in
+        (0) set -- ;;
+        (1) set -- "$args0" ;;
+        (2) set -- "$args0" "$args1" ;;
+        (3) set -- "$args0" "$args1" "$args2" ;;
+        (4) set -- "$args0" "$args1" "$args2" "$args3" ;;
+        (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
+        (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
+        (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
+        (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
+        (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
+    esac
+fi
+
+# Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules
+function splitJvmOpts() {
+    JVM_OPTS=("[email protected]")
+}
+eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS
+JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME"
+
+exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "[email protected]"

+ 90 - 0
gradlew.bat

@@ -0,0 +1,90 @@
[email protected] "%DEBUG%" == "" @echo off
[email protected] ##########################################################################
[email protected]
[email protected]  Gradle startup script for Windows
[email protected]
[email protected] ##########################################################################
+
[email protected] Set local scope for the variables with windows NT shell
+if "%OS%"=="Windows_NT" setlocal
+
[email protected] Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
+set DEFAULT_JVM_OPTS=
+
+set DIRNAME=%~dp0
+if "%DIRNAME%" == "" set DIRNAME=.
+set APP_BASE_NAME=%~n0
+set APP_HOME=%DIRNAME%
+
[email protected] Find java.exe
+if defined JAVA_HOME goto findJavaFromJavaHome
+
+set JAVA_EXE=java.exe
+%JAVA_EXE% -version >NUL 2>&1
+if "%ERRORLEVEL%" == "0" goto init
+
+echo.
+echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
+echo.
+echo Please set the JAVA_HOME variable in your environment to match the
+echo location of your Java installation.
+
+goto fail
+
+:findJavaFromJavaHome
+set JAVA_HOME=%JAVA_HOME:"=%
+set JAVA_EXE=%JAVA_HOME%/bin/java.exe
+
+if exist "%JAVA_EXE%" goto init
+
+echo.
+echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
+echo.
+echo Please set the JAVA_HOME variable in your environment to match the
+echo location of your Java installation.
+
+goto fail
+
+:init
[email protected] Get command-line arguments, handling Windowz variants
+
+if not "%OS%" == "Windows_NT" goto win9xME_args
+if "%@eval[2+2]" == "4" goto 4NT_args
+
+:win9xME_args
[email protected] Slurp the command line arguments.
+set CMD_LINE_ARGS=
+set _SKIP=2
+
+:win9xME_args_slurp
+if "x%~1" == "x" goto execute
+
+set CMD_LINE_ARGS=%*
+goto execute
+
+:4NT_args
[email protected] Get arguments from the 4NT Shell from JP Software
+set CMD_LINE_ARGS=%$
+
+:execute
[email protected] Setup the command line
+
+set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
+
[email protected] Execute Gradle
+"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
+
+:end
[email protected] End local scope for the variables with windows NT shell
+if "%ERRORLEVEL%"=="0" goto mainEnd
+
+:fail
+rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
+rem the _cmd.exe /c_ return code!
+if  not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
+exit /b 1
+
+:mainEnd
+if "%OS%"=="Windows_NT" endlocal
+
+:omega

+ 25 - 0
org.fox.ttcomics/build.gradle

@@ -0,0 +1,25 @@
+apply plugin: 'com.android.application'
+
+android {
+    compileSdkVersion 19
+    buildToolsVersion "20.0.0"
+
+    defaultConfig {
+        applicationId "org.fox.ttcomics"
+        minSdkVersion 8
+        targetSdkVersion 19
+    }
+
+    buildTypes {
+        release {
+            runProguard false
+            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
+        }
+    }
+}
+
+dependencies {
+    compile 'com.readystatesoftware.systembartint:systembartint:1.0.3'
+    compile 'com.android.support:support-v4:19.1.0'
+    compile 'com.android.support:appcompat-v7:18.0.0'
+}

+ 88 - 0
org.fox.ttcomics/org.fox.ttcomics.iml

@@ -0,0 +1,88 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<module external.linked.project.path="$MODULE_DIR$" external.root.project.path="$MODULE_DIR$/.." external.system.id="GRADLE" external.system.module.group="Tiny-Comics-Reader" external.system.module.version="unspecified" type="JAVA_MODULE" version="4">
+  <component name="FacetManager">
+    <facet type="android-gradle" name="Android-Gradle">
+      <configuration>
+        <option name="GRADLE_PROJECT_PATH" value=":org.fox.ttcomics" />
+      </configuration>
+    </facet>
+    <facet type="android" name="Android">
+      <configuration>
+        <option name="SELECTED_BUILD_VARIANT" value="debug" />
+        <option name="ASSEMBLE_TASK_NAME" value="assembleDebug" />
+        <option name="COMPILE_JAVA_TASK_NAME" value="compileDebugJava" />
+        <option name="ASSEMBLE_TEST_TASK_NAME" value="assembleDebugTest" />
+        <option name="SOURCE_GEN_TASK_NAME" value="generateDebugSources" />
+        <option name="TEST_SOURCE_GEN_TASK_NAME" value="generateDebugTestSources" />
+        <option name="ALLOW_USER_CONFIGURATION" value="false" />
+        <option name="MANIFEST_FILE_RELATIVE_PATH" value="/src/main/AndroidManifest.xml" />
+        <option name="RES_FOLDER_RELATIVE_PATH" value="/src/main/res" />
+        <option name="RES_FOLDERS_RELATIVE_PATH" value="file://$MODULE_DIR$/src/main/res" />
+        <option name="ASSETS_FOLDER_RELATIVE_PATH" value="/src/main/assets" />
+      </configuration>
+    </facet>
+  </component>
+  <component name="NewModuleRootManager" inherit-compiler-output="false">
+    <output url="file://$MODULE_DIR$/build/intermediates/classes/debug" />
+    <exclude-output />
+    <content url="file://$MODULE_DIR$">
+      <sourceFolder url="file://$MODULE_DIR$/build/generated/source/r/debug" isTestSource="false" generated="true" />
+      <sourceFolder url="file://$MODULE_DIR$/build/generated/source/aidl/debug" isTestSource="false" generated="true" />
+      <sourceFolder url="file://$MODULE_DIR$/build/generated/source/buildConfig/debug" isTestSource="false" generated="true" />
+      <sourceFolder url="file://$MODULE_DIR$/build/generated/source/rs/debug" isTestSource="false" generated="true" />
+      <sourceFolder url="file://$MODULE_DIR$/build/generated/res/rs/debug" type="java-resource" />
+      <sourceFolder url="file://$MODULE_DIR$/build/generated/source/r/test/debug" isTestSource="true" generated="true" />
+      <sourceFolder url="file://$MODULE_DIR$/build/generated/source/aidl/test/debug" isTestSource="true" generated="true" />
+      <sourceFolder url="file://$MODULE_DIR$/build/generated/source/buildConfig/test/debug" isTestSource="true" generated="true" />
+      <sourceFolder url="file://$MODULE_DIR$/build/generated/source/rs/test/debug" isTestSource="true" generated="true" />
+      <sourceFolder url="file://$MODULE_DIR$/build/generated/res/rs/test/debug" type="java-test-resource" />
+      <sourceFolder url="file://$MODULE_DIR$/src/debug/res" type="java-resource" />
+      <sourceFolder url="file://$MODULE_DIR$/src/debug/resources" type="java-resource" />
+      <sourceFolder url="file://$MODULE_DIR$/src/debug/assets" type="java-resource" />
+      <sourceFolder url="file://$MODULE_DIR$/src/debug/aidl" isTestSource="false" />
+      <sourceFolder url="file://$MODULE_DIR$/src/debug/java" isTestSource="false" />
+      <sourceFolder url="file://$MODULE_DIR$/src/debug/jni" isTestSource="false" />
+      <sourceFolder url="file://$MODULE_DIR$/src/debug/rs" isTestSource="false" />
+      <sourceFolder url="file://$MODULE_DIR$/src/main/res" type="java-resource" />
+      <sourceFolder url="file://$MODULE_DIR$/src/main/resources" type="java-resource" />
+      <sourceFolder url="file://$MODULE_DIR$/src/main/assets" type="java-resource" />
+      <sourceFolder url="file://$MODULE_DIR$/src/main/aidl" isTestSource="false" />
+      <sourceFolder url="file://$MODULE_DIR$/src/main/java" isTestSource="false" />
+      <sourceFolder url="file://$MODULE_DIR$/src/main/jni" isTestSource="false" />
+      <sourceFolder url="file://$MODULE_DIR$/src/main/rs" isTestSource="false" />
+      <sourceFolder url="file://$MODULE_DIR$/src/androidTest/res" type="java-test-resource" />
+      <sourceFolder url="file://$MODULE_DIR$/src/androidTest/resources" type="java-test-resource" />
+      <sourceFolder url="file://$MODULE_DIR$/src/androidTest/assets" type="java-test-resource" />
+      <sourceFolder url="file://$MODULE_DIR$/src/androidTest/aidl" isTestSource="true" />
+      <sourceFolder url="file://$MODULE_DIR$/src/androidTest/java" isTestSource="true" />
+      <sourceFolder url="file://$MODULE_DIR$/src/androidTest/jni" isTestSource="true" />
+      <sourceFolder url="file://$MODULE_DIR$/src/androidTest/rs" isTestSource="true" />
+      <excludeFolder url="file://$MODULE_DIR$/build/intermediates/assets" />
+      <excludeFolder url="file://$MODULE_DIR$/build/intermediates/bundles" />
+      <excludeFolder url="file://$MODULE_DIR$/build/intermediates/classes" />
+      <excludeFolder url="file://$MODULE_DIR$/build/intermediates/coverage-instrumented-classes" />
+      <excludeFolder url="file://$MODULE_DIR$/build/intermediates/dependency-cache" />
+      <excludeFolder url="file://$MODULE_DIR$/build/intermediates/dex" />
+      <excludeFolder url="file://$MODULE_DIR$/build/intermediates/dex-cache" />
+      <excludeFolder url="file://$MODULE_DIR$/build/intermediates/incremental" />
+      <excludeFolder url="file://$MODULE_DIR$/build/intermediates/jacoco" />
+      <excludeFolder url="file://$MODULE_DIR$/build/intermediates/javaResources" />
+      <excludeFolder url="file://$MODULE_DIR$/build/intermediates/libs" />
+      <excludeFolder url="file://$MODULE_DIR$/build/intermediates/lint" />
+      <excludeFolder url="file://$MODULE_DIR$/build/intermediates/manifests" />
+      <excludeFolder url="file://$MODULE_DIR$/build/intermediates/ndk" />
+      <excludeFolder url="file://$MODULE_DIR$/build/intermediates/pre-dexed" />
+      <excludeFolder url="file://$MODULE_DIR$/build/intermediates/proguard" />
+      <excludeFolder url="file://$MODULE_DIR$/build/intermediates/res" />
+      <excludeFolder url="file://$MODULE_DIR$/build/intermediates/rs" />
+      <excludeFolder url="file://$MODULE_DIR$/build/intermediates/symbols" />
+      <excludeFolder url="file://$MODULE_DIR$/build/outputs" />
+    </content>
+    <orderEntry type="jdk" jdkName="Android API 19 Platform" jdkType="Android SDK" />
+    <orderEntry type="sourceFolder" forTests="false" />
+    <orderEntry type="library" exported="" name="systembartint-1.0.3" level="project" />
+    <orderEntry type="library" exported="" name="support-v4-19.1.0" level="project" />
+    <orderEntry type="library" exported="" name="appcompat-v7-18.0.0" level="project" />
+  </component>
+</module>
+

+ 54 - 0
org.fox.ttcomics/src/main/AndroidManifest.xml

@@ -0,0 +1,54 @@
+<manifest xmlns:android="http://schemas.android.com/apk/res/android"
+    package="org.fox.ttcomics"
+    android:versionCode="47"
+    android:versionName="1.13" >
+
+    <uses-sdk
+        android:minSdkVersion="8"
+        android:targetSdkVersion="19" />
+
+    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
+    <uses-permission android:name="android.permission.GET_ACCOUNTS" />
+    <uses-permission android:name="android.permission.INTERNET" />
+    
+    <application
+        android:icon="@drawable/ic_launcher"
+        android:label="@string/app_name"
+        android:hardwareAccelerated="true"
+        android:largeHeap="true"        
+        android:allowBackup="true">        
+        <activity
+            android:theme="@style/AppTheme"
+            android:name=".MainActivity"
+            android:label="@string/title_activity_main" >
+            <intent-filter>
+                <action android:name="android.intent.action.MAIN" />
+
+                <category android:name="android.intent.category.LAUNCHER" />
+            </intent-filter>
+        </activity>
+        
+        <activity
+            android:name=".PreferencesActivity"
+            android:label="@string/title_activity_preferences">
+        </activity>
+        
+        <activity
+            android:theme="@style/ViewLightTheme"
+            android:name=".ViewComicActivity"
+            android:label="@string/title_activity_main">
+        </activity>
+
+        <activity
+            android:name=".CommonActivity"
+            android:label="@string/title_activity_main">
+        </activity>
+
+        <activity
+            android:name=".DirectoryPicker"
+            android:label="@string/title_activity_main">
+        </activity>
+        
+    </application>
+
+</manifest>

+ 583 - 0
org.fox.ttcomics/src/main/java/com/github/junrar/Archive.java

@@ -0,0 +1,583 @@
+/*
+ * Copyright (c) 2007 innoSysTec (R) GmbH, Germany. All rights reserved.
+ * Original author: Edmund Wagner
+ * Creation date: 22.05.2007
+ *
+ * Source: $HeadURL$
+ * Last changed: $LastChangedDate$
+ *
+ * the unrar licence applies to all junrar source and binary distributions
+ * you are not allowed to use this source to re-create the RAR compression
+ * algorithm
+ *
+ * Here some html entities which can be used for escaping javadoc tags:
+ * "&":  "&#038;" or "&amp;"
+ * "<":  "&#060;" or "&lt;"
+ * ">":  "&#062;" or "&gt;"
+ * "@":  "&#064;"
+ */
+package com.github.junrar;
+
+import java.io.Closeable;
+import java.io.File;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.io.PipedInputStream;
+import java.io.PipedOutputStream;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+import com.github.junrar.exception.RarException;
+import com.github.junrar.exception.RarException.RarExceptionType;
+import com.github.junrar.impl.FileVolumeManager;
+import com.github.junrar.io.IReadOnlyAccess;
+import com.github.junrar.rarfile.AVHeader;
+import com.github.junrar.rarfile.BaseBlock;
+import com.github.junrar.rarfile.BlockHeader;
+import com.github.junrar.rarfile.CommentHeader;
+import com.github.junrar.rarfile.EAHeader;
+import com.github.junrar.rarfile.EndArcHeader;
+import com.github.junrar.rarfile.FileHeader;
+import com.github.junrar.rarfile.MacInfoHeader;
+import com.github.junrar.rarfile.MainHeader;
+import com.github.junrar.rarfile.MarkHeader;
+import com.github.junrar.rarfile.ProtectHeader;
+import com.github.junrar.rarfile.SignHeader;
+import com.github.junrar.rarfile.SubBlockHeader;
+import com.github.junrar.rarfile.UnixOwnersHeader;
+import com.github.junrar.rarfile.UnrarHeadertype;
+import com.github.junrar.unpack.ComprDataIO;
+import com.github.junrar.unpack.Unpack;
+
+
+/**
+ * The Main Rar Class; represents a rar Archive
+ * 
+ * @author $LastChangedBy$
+ * @version $LastChangedRevision$
+ */
+public class Archive implements Closeable {
+	private static Logger logger = Logger.getLogger(Archive.class.getName());
+
+	private IReadOnlyAccess rof;
+
+	private final UnrarCallback unrarCallback;
+
+	private final ComprDataIO dataIO;
+
+	private final List<BaseBlock> headers = new ArrayList<BaseBlock>();
+
+	private MarkHeader markHead = null;
+
+	private MainHeader newMhd = null;
+
+	private Unpack unpack;
+
+	private int currentHeaderIndex;
+
+	/** Size of packed data in current file. */
+	private long totalPackedSize = 0L;
+
+	/** Number of bytes of compressed data read from current file. */
+	private long totalPackedRead = 0L;
+
+	private VolumeManager volumeManager;
+	private Volume volume;
+
+	public Archive(VolumeManager volumeManager) throws RarException,
+			IOException {
+		this(volumeManager, null);
+	}
+
+	/**
+	 * create a new archive object using the given {@link VolumeManager}
+	 * 
+	 * @param volumeManager
+	 *            the the {@link VolumeManager} that will provide volume stream
+	 *            data
+	 * @throws RarException
+	 */
+	public Archive(VolumeManager volumeManager, UnrarCallback unrarCallback)
+			throws RarException, IOException {
+		this.volumeManager = volumeManager;
+		this.unrarCallback = unrarCallback;
+
+		setVolume(this.volumeManager.nextArchive(this, null));
+		dataIO = new ComprDataIO(this);
+	}
+
+	public Archive(File firstVolume) throws RarException, IOException {
+		this(new FileVolumeManager(firstVolume), null);
+	}
+
+	public Archive(File firstVolume, UnrarCallback unrarCallback)
+			throws RarException, IOException {
+		this(new FileVolumeManager(firstVolume), unrarCallback);
+	}
+
+	// public File getFile() {
+	// return file;
+	// }
+	//
+	// void setFile(File file) throws IOException {
+	// this.file = file;
+	// setFile(new ReadOnlyAccessFile(file), file.length());
+	// }
+
+	private void setFile(IReadOnlyAccess file, long length) throws IOException {
+		totalPackedSize = 0L;
+		totalPackedRead = 0L;
+		close();
+		rof = file;
+		try {
+			readHeaders(length);
+		} catch (Exception e) {
+			logger.log(Level.WARNING,
+					"exception in archive constructor maybe file is encrypted "
+							+ "or currupt", e);
+			// ignore exceptions to allow exraction of working files in
+			// corrupt archive
+		}
+		// Calculate size of packed data
+		for (BaseBlock block : headers) {
+			if (block.getHeaderType() == UnrarHeadertype.FileHeader) {
+				totalPackedSize += ((FileHeader) block).getFullPackSize();
+			}
+		}
+		if (unrarCallback != null) {
+			unrarCallback.volumeProgressChanged(totalPackedRead,
+					totalPackedSize);
+		}
+	}
+
+	public void bytesReadRead(int count) {
+		if (count > 0) {
+			totalPackedRead += count;
+			if (unrarCallback != null) {
+				unrarCallback.volumeProgressChanged(totalPackedRead,
+						totalPackedSize);
+			}
+		}
+	}
+
+	public IReadOnlyAccess getRof() {
+		return rof;
+	}
+
+	/**
+	 * @return returns all file headers of the archive
+	 */
+	public List<FileHeader> getFileHeaders() {
+		List<FileHeader> list = new ArrayList<FileHeader>();
+		for (BaseBlock block : headers) {
+			if (block.getHeaderType().equals(UnrarHeadertype.FileHeader)) {
+				list.add((FileHeader) block);
+			}
+		}
+		return list;
+	}
+
+	public FileHeader nextFileHeader() {
+		int n = headers.size();
+		while (currentHeaderIndex < n) {
+			BaseBlock block = headers.get(currentHeaderIndex++);
+			if (block.getHeaderType() == UnrarHeadertype.FileHeader) {
+				return (FileHeader) block;
+			}
+		}
+		return null;
+	}
+
+	public UnrarCallback getUnrarCallback() {
+		return unrarCallback;
+	}
+
+	/**
+	 * 
+	 * @return whether the archive is encrypted
+	 */
+	public boolean isEncrypted() {
+		if (newMhd != null) {
+			return newMhd.isEncrypted();
+		} else {
+			throw new NullPointerException("mainheader is null");
+		}
+	}
+
+	/**
+	 * Read the headers of the archive
+	 * 
+	 * @param fileLength
+	 *            Length of file.
+	 * @throws RarException
+	 */
+	private void readHeaders(long fileLength) throws IOException, RarException {
+		markHead = null;
+		newMhd = null;
+		headers.clear();
+		currentHeaderIndex = 0;
+		int toRead = 0;
+
+		while (true) {
+			int size = 0;
+			long newpos = 0;
+			byte[] baseBlockBuffer = new byte[BaseBlock.BaseBlockSize];
+
+			long position = rof.getPosition();
+
+			// Weird, but is trying to read beyond the end of the file
+			if (position >= fileLength) {
+				break;
+			}
+
+			// logger.info("\n--------reading header--------");
+			size = rof.readFully(baseBlockBuffer, BaseBlock.BaseBlockSize);
+			if (size == 0) {
+				break;
+			}
+			BaseBlock block = new BaseBlock(baseBlockBuffer);
+
+			block.setPositionInFile(position);
+
+			switch (block.getHeaderType()) {
+
+			case MarkHeader:
+				markHead = new MarkHeader(block);
+				if (!markHead.isSignature()) {
+					throw new RarException(
+							RarException.RarExceptionType.badRarArchive);
+				}
+				headers.add(markHead);
+				// markHead.print();
+				break;
+
+			case MainHeader:
+				toRead = block.hasEncryptVersion() ? MainHeader.mainHeaderSizeWithEnc
+						: MainHeader.mainHeaderSize;
+				byte[] mainbuff = new byte[toRead];
+				rof.readFully(mainbuff, toRead);
+				MainHeader mainhead = new MainHeader(block, mainbuff);
+				headers.add(mainhead);
+				this.newMhd = mainhead;
+				if (newMhd.isEncrypted()) {
+					throw new RarException(
+							RarExceptionType.rarEncryptedException);
+				}
+				// mainhead.print();
+				break;
+
+			case SignHeader:
+				toRead = SignHeader.signHeaderSize;
+				byte[] signBuff = new byte[toRead];
+				rof.readFully(signBuff, toRead);
+				SignHeader signHead = new SignHeader(block, signBuff);
+				headers.add(signHead);
+				// logger.info("HeaderType: SignHeader");
+
+				break;
+
+			case AvHeader:
+				toRead = AVHeader.avHeaderSize;
+				byte[] avBuff = new byte[toRead];
+				rof.readFully(avBuff, toRead);
+				AVHeader avHead = new AVHeader(block, avBuff);
+				headers.add(avHead);
+				// logger.info("headertype: AVHeader");
+				break;
+
+			case CommHeader:
+				toRead = CommentHeader.commentHeaderSize;
+				byte[] commBuff = new byte[toRead];
+				rof.readFully(commBuff, toRead);
+				CommentHeader commHead = new CommentHeader(block, commBuff);
+				headers.add(commHead);
+				// logger.info("method: "+commHead.getUnpMethod()+"; 0x"+
+				// Integer.toHexString(commHead.getUnpMethod()));
+				newpos = commHead.getPositionInFile()
+						+ commHead.getHeaderSize();
+				rof.setPosition(newpos);
+
+				break;
+			case EndArcHeader:
+
+				toRead = 0;
+				if (block.hasArchiveDataCRC()) {
+					toRead += EndArcHeader.endArcArchiveDataCrcSize;
+				}
+				if (block.hasVolumeNumber()) {
+					toRead += EndArcHeader.endArcVolumeNumberSize;
+				}
+				EndArcHeader endArcHead;
+				if (toRead > 0) {
+					byte[] endArchBuff = new byte[toRead];
+					rof.readFully(endArchBuff, toRead);
+					endArcHead = new EndArcHeader(block, endArchBuff);
+					// logger.info("HeaderType: endarch\ndatacrc:"+
+					// endArcHead.getArchiveDataCRC());
+				} else {
+					// logger.info("HeaderType: endarch - no Data");
+					endArcHead = new EndArcHeader(block, null);
+				}
+				headers.add(endArcHead);
+				// logger.info("\n--------end header--------");
+				return;
+
+			default:
+				byte[] blockHeaderBuffer = new byte[BlockHeader.blockHeaderSize];
+				rof.readFully(blockHeaderBuffer, BlockHeader.blockHeaderSize);
+				BlockHeader blockHead = new BlockHeader(block,
+						blockHeaderBuffer);
+
+				switch (blockHead.getHeaderType()) {
+				case NewSubHeader:
+				case FileHeader:
+					toRead = blockHead.getHeaderSize()
+							- BlockHeader.BaseBlockSize
+							- BlockHeader.blockHeaderSize;
+					byte[] fileHeaderBuffer = new byte[toRead];
+					rof.readFully(fileHeaderBuffer, toRead);
+
+					FileHeader fh = new FileHeader(blockHead, fileHeaderBuffer);
+					headers.add(fh);
+					newpos = fh.getPositionInFile() + fh.getHeaderSize()
+							+ fh.getFullPackSize();
+					rof.setPosition(newpos);
+					break;
+
+				case ProtectHeader:
+					toRead = blockHead.getHeaderSize()
+							- BlockHeader.BaseBlockSize
+							- BlockHeader.blockHeaderSize;
+					byte[] protectHeaderBuffer = new byte[toRead];
+					rof.readFully(protectHeaderBuffer, toRead);
+					ProtectHeader ph = new ProtectHeader(blockHead,
+							protectHeaderBuffer);
+
+					newpos = ph.getPositionInFile() + ph.getHeaderSize()
+							+ ph.getDataSize();
+					rof.setPosition(newpos);
+					break;
+
+				case SubHeader: {
+					byte[] subHeadbuffer = new byte[SubBlockHeader.SubBlockHeaderSize];
+					rof.readFully(subHeadbuffer,
+							SubBlockHeader.SubBlockHeaderSize);
+					SubBlockHeader subHead = new SubBlockHeader(blockHead,
+							subHeadbuffer);
+					subHead.print();
+					switch (subHead.getSubType()) {
+					case MAC_HEAD: {
+						byte[] macHeaderbuffer = new byte[MacInfoHeader.MacInfoHeaderSize];
+						rof.readFully(macHeaderbuffer,
+								MacInfoHeader.MacInfoHeaderSize);
+						MacInfoHeader macHeader = new MacInfoHeader(subHead,
+								macHeaderbuffer);
+						macHeader.print();
+						headers.add(macHeader);
+
+						break;
+					}
+					// TODO implement other subheaders
+					case BEEA_HEAD:
+						break;
+					case EA_HEAD: {
+						byte[] eaHeaderBuffer = new byte[EAHeader.EAHeaderSize];
+						rof.readFully(eaHeaderBuffer, EAHeader.EAHeaderSize);
+						EAHeader eaHeader = new EAHeader(subHead,
+								eaHeaderBuffer);
+						eaHeader.print();
+						headers.add(eaHeader);
+
+						break;
+					}
+					case NTACL_HEAD:
+						break;
+					case STREAM_HEAD:
+						break;
+					case UO_HEAD:
+						toRead = subHead.getHeaderSize();
+						toRead -= BaseBlock.BaseBlockSize;
+						toRead -= BlockHeader.blockHeaderSize;
+						toRead -= SubBlockHeader.SubBlockHeaderSize;
+						byte[] uoHeaderBuffer = new byte[toRead];
+						rof.readFully(uoHeaderBuffer, toRead);
+						UnixOwnersHeader uoHeader = new UnixOwnersHeader(
+								subHead, uoHeaderBuffer);
+						uoHeader.print();
+						headers.add(uoHeader);
+						break;
+					default:
+						break;
+					}
+
+					break;
+				}
+				default:
+					logger.warning("Unknown Header");
+					throw new RarException(RarExceptionType.notRarArchive);
+
+				}
+			}
+			// logger.info("\n--------end header--------");
+		}
+	}
+
+	/**
+	 * Extract the file specified by the given header and write it to the
+	 * supplied output stream
+	 * 
+	 * @param header
+	 *            the header to be extracted
+	 * @param os
+	 *            the outputstream
+	 * @throws RarException
+	 */
+	public void extractFile(FileHeader hd, OutputStream os) throws RarException {
+		if (!headers.contains(hd)) {
+			throw new RarException(RarExceptionType.headerNotInArchive);
+		}
+		try {
+			doExtractFile(hd, os);
+		} catch (Exception e) {
+			if (e instanceof RarException) {
+				throw (RarException) e;
+			} else {
+				throw new RarException(e);
+			}
+		}
+	}
+
+	/**
+	 * Returns an {@link InputStream} that will allow to read the file and
+	 * stream it. Please note that this method will create a new Thread and an a
+	 * pair of Pipe streams.
+	 * 
+	 * @param header
+	 *            the header to be extracted
+	 * @throws RarException
+	 * @throws IOException
+	 *             if any IO error occur
+	 */
+	public InputStream getInputStream(final FileHeader hd) throws RarException,
+			IOException {
+		final PipedInputStream in = new PipedInputStream(32 * 1024);
+		final PipedOutputStream out = new PipedOutputStream(in);
+
+		// creates a new thread that will write data to the pipe. Data will be
+		// available in another InputStream, connected to the OutputStream.
+		new Thread(new Runnable() {
+			public void run() {
+				try {
+					extractFile(hd, out);
+				} catch (RarException e) {
+				} finally {
+					try {
+						out.close();
+					} catch (IOException e) {
+					}
+				}
+			}
+		}).start();
+
+		return in;
+	}
+
+	private void doExtractFile(FileHeader hd, OutputStream os)
+			throws RarException, IOException {
+		dataIO.init(os);
+		dataIO.init(hd);
+		dataIO.setUnpFileCRC(this.isOldFormat() ? 0 : 0xffFFffFF);
+		if (unpack == null) {
+			unpack = new Unpack(dataIO);
+		}
+		if (!hd.isSolid()) {
+			unpack.init(null);
+		}
+		unpack.setDestSize(hd.getFullUnpackSize());
+		try {
+			unpack.doUnpack(hd.getUnpVersion(), hd.isSolid());
+			// Verify file CRC
+			hd = dataIO.getSubHeader();
+			long actualCRC = hd.isSplitAfter() ? ~dataIO.getPackedCRC()
+					: ~dataIO.getUnpFileCRC();
+			int expectedCRC = hd.getFileCRC();
+			if (actualCRC != expectedCRC) {
+				throw new RarException(RarExceptionType.crcError);
+			}
+			// if (!hd.isSplitAfter()) {
+			// // Verify file CRC
+			// if(~dataIO.getUnpFileCRC() != hd.getFileCRC()){
+			// throw new RarException(RarExceptionType.crcError);
+			// }
+			// }
+		} catch (Exception e) {
+			unpack.cleanUp();
+			if (e instanceof RarException) {
+				// throw new RarException((RarException)e);
+				throw (RarException) e;
+			} else {
+				throw new RarException(e);
+			}
+		}
+	}
+
+	/**
+	 * @return returns the main header of this archive
+	 */
+	public MainHeader getMainHeader() {
+		return newMhd;
+	}
+
+	/**
+	 * @return whether the archive is old format
+	 */
+	public boolean isOldFormat() {
+		return markHead.isOldFormat();
+	}
+
+	/** Close the underlying compressed file. */
+	public void close() throws IOException {
+		if (rof != null) {
+			rof.close();
+			rof = null;
+		}
+		if (unpack != null) {
+			unpack.cleanUp();
+		}
+	}
+
+	/**
+	 * @return the volumeManager
+	 */
+	public VolumeManager getVolumeManager() {
+		return volumeManager;
+	}
+
+	/**
+	 * @param volumeManager
+	 *            the volumeManager to set
+	 */
+	public void setVolumeManager(VolumeManager volumeManager) {
+		this.volumeManager = volumeManager;
+	}
+
+	/**
+	 * @return the volume
+	 */
+	public Volume getVolume() {
+		return volume;
+	}
+
+	/**
+	 * @param volume
+	 *            the volume to set
+	 * @throws IOException
+	 */
+	public void setVolume(Volume volume) throws IOException {
+		this.volume = volume;
+		setFile(volume.getReadOnlyAccess(), volume.getLength());
+	}
+}

+ 56 - 0
org.fox.ttcomics/src/main/java/com/github/junrar/MVTest.java

@@ -0,0 +1,56 @@
+package com.github.junrar;
+
+import java.io.File;
+import java.io.FileNotFoundException;
+import java.io.FileOutputStream;
+import java.io.IOException;
+
+import com.github.junrar.exception.RarException;
+import com.github.junrar.impl.FileVolumeManager;
+import com.github.junrar.rarfile.FileHeader;
+
+
+public class MVTest {
+
+	/**
+	 * @param args
+	 */
+	public static void main(String[] args) {
+		String filename = "/home/rogiel/fs/home/ae721273-eade-45e7-8112-d14115ebae56/Village People - Y.M.C.A.mp3.part1.rar";
+		File f = new File(filename);
+		Archive a = null;
+		try {
+			a = new Archive(new FileVolumeManager(f));
+		} catch (RarException e) {
+			// TODO Auto-generated catch block
+			e.printStackTrace();
+		} catch (IOException e) {
+			// TODO Auto-generated catch block
+			e.printStackTrace();
+		}
+		if (a != null) {
+			a.getMainHeader().print();
+			FileHeader fh = a.nextFileHeader();
+			while (fh != null) {
+				try {
+					File out = new File("/home/rogiel/fs/test/"
+							+ fh.getFileNameString().trim());
+					System.out.println(out.getAbsolutePath());
+					FileOutputStream os = new FileOutputStream(out);
+					a.extractFile(fh, os);
+					os.close();
+				} catch (FileNotFoundException e) {
+					// TODO Auto-generated catch block
+					e.printStackTrace();
+				} catch (RarException e) {
+					// TODO Auto-generated catch block
+					e.printStackTrace();
+				} catch (IOException e) {
+					// TODO Auto-generated catch block
+					e.printStackTrace();
+				}
+				fh = a.nextFileHeader();
+			}
+		}
+	}
+}

+ 21 - 0
org.fox.ttcomics/src/main/java/com/github/junrar/UnrarCallback.java

@@ -0,0 +1,21 @@
+package com.github.junrar;
+
+
+/**
+ *
+ * @author alban
+ */
+public interface UnrarCallback {
+
+    /**
+     * Return <tt>true</tt> if the next volume is ready to be processed,
+     * <tt>false</tt> otherwise.
+     */
+    boolean isNextVolumeReady(Volume nextVolume);
+
+    /**
+     * This method is invoked each time the progress of the current
+     * volume changes.
+     */
+    void volumeProgressChanged(long current, long total);
+}

+ 44 - 0
org.fox.ttcomics/src/main/java/com/github/junrar/Volume.java

@@ -0,0 +1,44 @@
+/*
+ * This file is part of seedbox <github.com/seedbox>.
+ *
+ * seedbox is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * seedbox is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with seedbox.  If not, see <http://www.gnu.org/licenses/>.
+ */
+package com.github.junrar;
+
+import java.io.IOException;
+
+import com.github.junrar.io.IReadOnlyAccess;
+
+
+/**
+ * @author <a href="http://www.rogiel.com">Rogiel</a>
+ * 
+ */
+public interface Volume {
+	/**
+	 * @return the access
+	 * @throws IOException
+	 */
+	IReadOnlyAccess getReadOnlyAccess() throws IOException;
+
+	/**
+	 * @return the data length
+	 */
+	long getLength();
+	
+	/**
+	 * @return the archive this volume belongs to
+	 */
+	Archive getArchive();
+}

+ 28 - 0
org.fox.ttcomics/src/main/java/com/github/junrar/VolumeManager.java

@@ -0,0 +1,28 @@
+/*
+ * This file is part of seedbox <github.com/seedbox>.
+ *
+ * seedbox is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * seedbox is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with seedbox.  If not, see <http://www.gnu.org/licenses/>.
+ */
+package com.github.junrar;
+
+import java.io.IOException;
+
+/**
+ * @author <a href="http://www.rogiel.com">Rogiel</a>
+ * 
+ */
+public interface VolumeManager {
+	public Volume nextArchive(Archive archive, Volume lastVolume)
+			throws IOException;
+}

+ 145 - 0
org.fox.ttcomics/src/main/java/com/github/junrar/crc/RarCRC.java

@@ -0,0 +1,145 @@
+/*
+ * Copyright (c) 2007 innoSysTec (R) GmbH, Germany. All rights reserved.
+ * Original author: Edmund Wagner
+ * Creation date: 29.05.2007
+ *
+ * Source: $HeadURL$
+ * Last changed: $LastChangedDate$
+ *  
+ * the unrar licence applies to all junrar source and binary distributions 
+ * you are not allowed to use this source to re-create the RAR compression algorithm
+ * 
+ * Here some html entities which can be used for escaping javadoc tags:
+ * "&":  "&#038;" or "&amp;"
+ * "<":  "&#060;" or "&lt;"
+ * ">":  "&#062;" or "&gt;"
+ * "@":  "&#064;" 
+ */
+package com.github.junrar.crc;
+
+
+/**
+ * DOCUMENT ME
+ * 
+ * @author $LastChangedBy$
+ * @version $LastChangedRevision$
+ */
+public class RarCRC {
+	
+	private final static int crcTab[];
+    static {
+		crcTab = new int[256];
+		for (int i = 0; i < 256; i++) {
+			int c = i;
+			for (int j = 0; j < 8; j++){
+				if ((c & 1) !=0) {
+					c >>>= 1;
+					c ^= 0xEDB88320;
+				}
+                else{
+					c >>>= 1;
+				}
+			}
+			crcTab[i] = c;
+		}
+    }
+
+	private RarCRC() {
+	}
+
+	public static int checkCrc(int startCrc, byte[] data, int offset,
+            int count) {
+		int size = Math.min(data.length-offset,count);
+		// #if defined(LITTLE_ENDIAN) && defined(PRESENT_INT32) &&
+		// defined(ALLOW_NOT_ALIGNED_INT)
+		/*
+		for (int i = 0; (0 < size) && i < data.length - 8
+				&& ((data[i + 8] & 7) != 0); i++) {
+			startCrc = crcTab[(short) (startCrc ^ data[i]) & 0x00FF] ^ (startCrc >>> 8);
+			size--;
+		}
+		
+		for (int i = 0; size >= 8; i += 8) {
+			startCrc ^= data[i + 0] << 24;
+			startCrc ^= data[i + 1] << 16;
+			startCrc ^= data[i + 2] << 8;
+			startCrc ^= data[i + 3];
+
+			startCrc = crcTab[(short) startCrc & 0x00FF] ^ (startCrc >>> 8);
+			startCrc = crcTab[(short) startCrc & 0x00FF] ^ (startCrc >>> 8);
+			startCrc = crcTab[(short) startCrc & 0x00FF] ^ (startCrc >>> 8);
+			startCrc = crcTab[(short) startCrc & 0x00FF] ^ (startCrc >>> 8);
+
+			startCrc ^= data[i + 4] << 24;
+			startCrc ^= data[i + 5] << 16;
+			startCrc ^= data[i + 6] << 8;
+			startCrc ^= data[i + 7];
+			startCrc = crcTab[(short) startCrc & 0x00FF] ^ (startCrc >>> 8);
+			startCrc = crcTab[(short) startCrc & 0x00FF] ^ (startCrc >>> 8);
+			startCrc = crcTab[(short) startCrc & 0x00FF] ^ (startCrc >>> 8);
+			startCrc = crcTab[(short) startCrc & 0x00FF] ^ (startCrc >>> 8);
+			size -= 8;
+		}*/
+		
+		for (int i = 0; i < size; i++)
+		{
+/*
+			// (byte)(StartCRC^Data[I])
+			int pos = 0; // pos=0x00000000
+			pos |= startCrc; // pos=ffffffff
+			
+			pos ^= data[i]; // data[0]=0x73=115dec --> pos=140
+			System.out.println(Integer.toHexString(pos));
+			
+			// Only last 8 bit because CRCtab has length 256
+			pos = pos & 0x000000FF;
+			System.out.println("pos:"+pos);
+			//startCrc >>>= 8;
+			
+			
+			//StartCRC>>8
+			int temp =0;
+			temp|=startCrc;
+			temp >>>= 8;
+			System.out.println("temp:"+Integer.toHexString(temp));
+			
+			
+			startCrc = (crcTab[pos]^temp);
+			System.out.println("--"+Integer.toHexString(startCrc));*/
+			
+			startCrc=(crcTab[((int)((int)startCrc ^
+                    (int)data[offset+i]))&0xff]^(startCrc>>>8));
+			
+			//System.out.println(Integer.toHexString(startCrc));
+			
+			// Original code:
+			//StartCRC=CRCTab[(byte)(StartCRC^Data[I])]^(StartCRC>>8);
+		}
+		return (startCrc);
+	}
+
+	public static short checkOldCrc(short startCrc, byte[] data, int count) {
+        int n = Math.min(data.length, count);
+		for (int i = 0; i < n; i++) {
+			startCrc = (short) ((short) (startCrc + (short) (data[i]&0x00ff)) & -1);
+			startCrc = (short) (((startCrc << 1) | (startCrc >>> 15)) & -1);
+		}
+		return (startCrc);
+	}
+
+//	public static void main(String[] args)
+//	{
+//		RarCRC rc = new RarCRC();
+//		//byte[] data = { 0x72, 0x21, 0x1A, 0x07, 0x00};
+//		
+//		byte[] data = {0x73 ,0x00 ,0x00 ,0x0D ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00};
+//		
+//		int crc = 0x90CF;
+//		
+//
+//		int result = rc.checkCrc(0xFFFFffff, data,0,data.length);
+//		System.out.println("3: "+Integer.toHexString(~result&0xffff));
+//		
+//	}
+	
+}

+ 27 - 0
org.fox.ttcomics/src/main/java/com/github/junrar/crypt/Rijndael.java

@@ -0,0 +1,27 @@
+/*
+ * Copyright (c) 2007 innoSysTec (R) GmbH, Germany. All rights reserved.
+ * Original author: Edmund Wagner
+ * Creation date: 31.05.2007
+ *
+ * the unrar licence applies to all junrar source and binary distributions 
+ * you are not allowed to use this source to re-create the RAR compression algorithm
+ * Source: $HeadURL$
+ * Last changed: $LastChangedDate$
+ * 
+ * Here some html entities which can be used for escaping javadoc tags:
+ * "&":  "&#038;" or "&amp;"
+ * "<":  "&#060;" or "&lt;"
+ * ">":  "&#062;" or "&gt;"
+ * "@":  "&#064;" 
+ */
+package com.github.junrar.crypt;
+
+/**
+ * DOCUMENT ME
+ *
+ * @author $LastChangedBy$
+ * @version $LastChangedRevision$
+ */
+public class Rijndael {
+
+}

+ 73 - 0
org.fox.ttcomics/src/main/java/com/github/junrar/exception/RarException.java

@@ -0,0 +1,73 @@
+/*
+ * Copyright (c) 2007 innoSysTec (R) GmbH, Germany. All rights reserved.
+ * Original author: Edmund Wagner
+ * Creation date: 30.07.2007
+ *
+ * Source: $HeadURL$
+ * Last changed: $LastChangedDate$
+ * 
+ * the unrar licence applies to all junrar source and binary distributions 
+ * you are not allowed to use this source to re-create the RAR compression algorithm
+ * 
+ * Here some html entities which can be used for escaping javadoc tags:
+ * "&":  "&#038;" or "&amp;"
+ * "<":  "&#060;" or "&lt;"
+ * ">":  "&#062;" or "&gt;"
+ * "@":  "&#064;" 
+ */
+package com.github.junrar.exception;
+
+/**
+ * DOCUMENT ME
+ *
+ * @author $LastChangedBy$
+ * @version $LastChangedRevision$
+ */
+public class RarException extends Exception
+{
+	private static final long serialVersionUID = 1L;
+	private RarExceptionType type;
+	
+	public RarException(Exception e){
+		super(RarExceptionType.unkownError.name(),e);
+		this.type = RarExceptionType.unkownError;
+	}
+	
+	public RarException(RarException e)
+	{
+		
+		super(e.getMessage(),e);
+		this.type = e.getType();
+	}
+	
+	public RarException(RarExceptionType type){
+		super(type.name());
+		this.type = type;
+	}
+	
+	
+	
+	public enum RarExceptionType{
+		notImplementedYet,
+		crcError,
+		notRarArchive,
+		badRarArchive,
+		unkownError,
+		headerNotInArchive,
+		wrongHeaderType,
+		ioError,
+		rarEncryptedException ;
+	}
+
+
+
+	public RarExceptionType getType()
+	{
+		return type;
+	}
+
+	public void setType(RarExceptionType type)
+	{
+		this.type = type;
+	}
+}

+ 65 - 0
org.fox.ttcomics/src/main/java/com/github/junrar/impl/FileVolume.java

@@ -0,0 +1,65 @@
+/*
+ * This file is part of seedbox <github.com/seedbox>.
+ *
+ * seedbox is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * seedbox is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with seedbox.  If not, see <http://www.gnu.org/licenses/>.
+ */
+package com.github.junrar.impl;
+
+import java.io.File;
+import java.io.IOException;
+
+import com.github.junrar.Archive;
+import com.github.junrar.Volume;
+import com.github.junrar.io.IReadOnlyAccess;
+import com.github.junrar.io.ReadOnlyAccessFile;
+
+
+/**
+ * @author <a href="http://www.rogiel.com">Rogiel</a>
+ * 
+ */
+public class FileVolume implements Volume {
+	private final Archive archive;
+	private final File file;
+
+	/**
+	 * @param file
+	 */
+	public FileVolume(Archive archive, File file) {
+		this.archive = archive;
+		this.file = file;
+	}
+
+	@Override
+	public IReadOnlyAccess getReadOnlyAccess() throws IOException {
+		return new ReadOnlyAccessFile(file);
+	}
+
+	@Override
+	public long getLength() {
+		return file.length();
+	}
+
+	@Override
+	public Archive getArchive() {
+		return archive;
+	}
+
+	/**
+	 * @return the file
+	 */
+	public File getFile() {
+		return file;
+	}
+}

+ 54 - 0
org.fox.ttcomics/src/main/java/com/github/junrar/impl/FileVolumeManager.java

@@ -0,0 +1,54 @@
+/*
+ * This file is part of seedbox <github.com/seedbox>.
+ *
+ * seedbox is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * seedbox is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with seedbox.  If not, see <http://www.gnu.org/licenses/>.
+ */
+package com.github.junrar.impl;
+
+import java.io.File;
+import java.io.IOException;
+
+import com.github.junrar.Archive;
+import com.github.junrar.Volume;
+import com.github.junrar.VolumeManager;
+import com.github.junrar.util.VolumeHelper;
+
+
+/**
+ * @author <a href="http://www.rogiel.com">Rogiel</a>
+ * 
+ */
+public class FileVolumeManager implements VolumeManager {
+	private final File firstVolume;
+
+	public FileVolumeManager(File firstVolume) {
+		this.firstVolume = firstVolume;
+	}
+
+	@Override
+	public Volume nextArchive(Archive archive, Volume last)
+			throws IOException {
+		if (last == null)
+			return new FileVolume(archive, firstVolume);
+
+		FileVolume lastFileVolume = (FileVolume) last;
+		boolean oldNumbering = !archive.getMainHeader().isNewNumbering()
+				|| archive.isOldFormat();
+		String nextName = VolumeHelper.nextVolumeName(lastFileVolume.getFile()
+				.getAbsolutePath(), oldNumbering);
+		File nextVolume = new File(nextName);
+
+		return new FileVolume(archive, nextVolume);
+	}
+}

+ 61 - 0
org.fox.ttcomics/src/main/java/com/github/junrar/io/IReadOnlyAccess.java

@@ -0,0 +1,61 @@
+/*
+ * Copyright (c) 2007 innoSysTec (R) GmbH, Germany. All rights reserved.
+ * Original author: Edmund Wagner
+ * Creation date: 23.05.2007
+ *
+ * Source: $HeadURL$
+ * Last changed: $LastChangedDate$
+ * 
+ * the unrar licence applies to all junrar source and binary distributions 
+ * you are not allowed to use this source to re-create the RAR compression algorithm
+ * 
+ * Here some html entities which can be used for escaping javadoc tags:
+ * "&":  "&#038;" or "&amp;"
+ * "<":  "&#060;" or "&lt;"
+ * ">":  "&#062;" or "&gt;"
+ * "@":  "&#064;" 
+ */
+package com.github.junrar.io;
+
+import java.io.IOException;
+
+
+/**
+ * DOCUMENT ME
+ *
+ * @author $LastChangedBy$
+ * @version $LastChangedRevision$
+ */
+public interface IReadOnlyAccess {
+
+	/**
+	 * @return the current position in the file
+	 */
+	public long getPosition() throws IOException;
+		
+	/**
+	 * @param pos the position in the file
+	 * @return success ? true : false 
+	 */
+	public void setPosition(long pos) throws IOException;
+
+    /** Read a single byte of data. */
+    public int read() throws IOException;
+
+	/**
+     * Read up to <tt>count</tt> bytes to the specified buffer.
+     */
+    public int read(byte[] buffer, int off, int count) throws IOException;
+
+    /**
+     * Read exactly <tt>count</tt> bytes to the specified buffer.
+     *
+	 * @param buffer where to store the read data
+	 * @param count how many bytes to read
+	 * @return bytes read || -1 if  IO problem 
+	 */
+	public int readFully(byte[] buffer, int count) throws IOException;
+
+    /** Close this file. */
+    public void close() throws IOException;
+}

+ 59 - 0
org.fox.ttcomics/src/main/java/com/github/junrar/io/InputStreamReadOnlyAccessFile.java

@@ -0,0 +1,59 @@
+package com.github.junrar.io;
+
+import java.io.BufferedInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+
+
+
+
+/**
+ * InputStream based implementation of the <code>IReadOnlyAccess</code> interface.
+ * 
+ * @see http://rsbweb.nih.gov/ij/
+ * @author martinr
+ */
+public class InputStreamReadOnlyAccessFile implements IReadOnlyAccess {
+	private RandomAccessStream is;
+
+	/**
+	 * Create new instance.
+	 * 
+	 * @param is The input stream to wrap.
+	 */
+	public InputStreamReadOnlyAccessFile(final InputStream is) {
+		this.is = new RandomAccessStream(new BufferedInputStream(is));
+	}
+	
+	@Override
+	public long getPosition() throws IOException {
+		return is.getLongFilePointer();
+	}
+
+	@Override
+	public void setPosition(long pos) throws IOException {
+		is.seek(pos);
+	}
+
+	@Override
+	public int read() throws IOException {
+		return is.read();
+	}
+
+	@Override
+	public int read(byte[] buffer, int off, int count) throws IOException {
+		return is.read(buffer, off, count);
+	}
+
+	@Override
+	public int readFully(byte[] buffer, int count) throws IOException {
+		is.readFully(buffer, count);
+		return count;
+	}
+
+	@Override
+	public void close() throws IOException {
+		is.close();
+	}
+
+}

+ 203 - 0
org.fox.ttcomics/src/main/java/com/github/junrar/io/RandomAccessStream.java

@@ -0,0 +1,203 @@
+/*
+ * public domain as of http://rsbweb.nih.gov/ij/disclaimer.html
+ */
+package com.github.junrar.io;
+
+import java.io.*;
+import java.util.Vector;
+
+/**
+ * This is a class that uses a memory cache to allow seeking within an
+ * InputStream. Based on the JAI MemoryCacheSeekableStream class. Can also be
+ * constructed from a RandomAccessFile, which uses less memory since the memory
+ * cache is not required.
+ */
[email protected]("rawtypes")
+public final class RandomAccessStream extends InputStream {
+
+	private static final int BLOCK_SIZE = 512;
+	private static final int BLOCK_MASK = 511;
+	private static final int BLOCK_SHIFT = 9;
+
+	private InputStream src;
+	private RandomAccessFile ras;
+	private long pointer;
+	private Vector data;
+	private int length;
+	private boolean foundEOS;
+
+	/**
+	 * Constructs a RandomAccessStream from an InputStream. Seeking backwards is
+	 * supported using a memory cache.
+	 */
+	public RandomAccessStream(InputStream inputstream) {
+		pointer = 0L;
+		data = new Vector();
+		length = 0;
+		foundEOS = false;
+		src = inputstream;
+	}
+
+	/** Constructs a RandomAccessStream from an RandomAccessFile. */
+	public RandomAccessStream(RandomAccessFile ras) {
+		this.ras = ras;
+	}
+
+	public int getFilePointer() throws IOException {
+		if (ras != null)
+			return (int) ras.getFilePointer();
+		else
+			return (int) pointer;
+	}
+
+	public long getLongFilePointer() throws IOException {
+		if (ras != null)
+			return ras.getFilePointer();
+		else
+			return pointer;
+	}
+
+	public int read() throws IOException {
+		if (ras != null)
+			return ras.read();
+		long l = pointer + 1L;
+		long l1 = readUntil(l);
+		if (l1 >= l) {
+			byte abyte0[] = (byte[]) data
+					.elementAt((int) (pointer >> BLOCK_SHIFT));
+			return abyte0[(int) (pointer++ & BLOCK_MASK)] & 0xff;
+		} else
+			return -1;
+	}
+
+	public int read(byte[] bytes, int off, int len) throws IOException {
+		if (bytes == null)
+			throw new NullPointerException();
+		if (ras != null)
+			return ras.read(bytes, off, len);
+		if (off < 0 || len < 0 || off + len > bytes.length)
+			throw new IndexOutOfBoundsException();
+		if (len == 0)
+			return 0;
+		long l = readUntil(pointer + len);
+		if (l <= pointer)
+			return -1;
+		else {
+			byte abyte1[] = (byte[]) data
+					.elementAt((int) (pointer >> BLOCK_SHIFT));
+			int k = Math.min(len, BLOCK_SIZE - (int) (pointer & BLOCK_MASK));
+			System.arraycopy(abyte1, (int) (pointer & BLOCK_MASK), bytes, off,
+					k);
+			pointer += k;
+			return k;
+		}
+	}
+
+	public final void readFully(byte[] bytes) throws IOException {
+		readFully(bytes, bytes.length);
+	}
+
+	public final void readFully(byte[] bytes, int len) throws IOException {
+		int read = 0;
+		do {
+			int l = read(bytes, read, len - read);
+			if (l < 0)
+				break;
+			read += l;
+		} while (read < len);
+	}
+
+	@SuppressWarnings("unchecked")
+	private long readUntil(long l) throws IOException {
+		if (l < length)
+			return l;
+		if (foundEOS)
+			return length;
+		int i = (int) (l >> BLOCK_SHIFT);
+		int j = length >> BLOCK_SHIFT;
+		for (int k = j; k <= i; k++) {
+			byte abyte0[] = new byte[BLOCK_SIZE];
+			data.addElement(abyte0);
+			int i1 = BLOCK_SIZE;
+			int j1 = 0;
+			while (i1 > 0) {
+				int k1 = src.read(abyte0, j1, i1);
+				if (k1 == -1) {
+					foundEOS = true;
+					return length;
+				}
+				j1 += k1;
+				i1 -= k1;
+				length += k1;
+			}
+
+		}
+
+		return length;
+	}
+
+	public void seek(long loc) throws IOException {
+		if (ras != null) {
+			ras.seek(loc);
+			return;
+		}
+		if (loc < 0L)
+			pointer = 0L;
+		else
+			pointer = loc;
+	}
+
+	public void seek(int loc) throws IOException {
+		long lloc = ((long) loc) & 0xffffffffL;
+		if (ras != null) {
+			ras.seek(lloc);
+			return;
+		}
+		if (lloc < 0L)
+			pointer = 0L;
+		else
+			pointer = lloc;
+	}
+
+	public final int readInt() throws IOException {
+		int i = read();
+		int j = read();
+		int k = read();
+		int l = read();
+		if ((i | j | k | l) < 0)
+			throw new EOFException();
+		else
+			return (i << 24) + (j << 16) + (k << 8) + l;
+	}
+
+	public final long readLong() throws IOException {
+		return ((long) readInt() << 32) + ((long) readInt() & 0xffffffffL);
+	}
+
+	public final double readDouble() throws IOException {
+		return Double.longBitsToDouble(readLong());
+	}
+
+	public final short readShort() throws IOException {
+		int i = read();
+		int j = read();
+		if ((i | j) < 0)
+			throw new EOFException();
+		else
+			return (short) ((i << 8) + j);
+	}
+
+	public final float readFloat() throws IOException {
+		return Float.intBitsToFloat(readInt());
+	}
+
+	public void close() throws IOException {
+		if (ras != null)
+			ras.close();
+		else {
+			data.removeAllElements();
+			src.close();
+		}
+	}
+
+}

+ 305 - 0
org.fox.ttcomics/src/main/java/com/github/junrar/io/Raw.java

@@ -0,0 +1,305 @@
+/*
+ * Copyright (c) 2007 innoSysTec (R) GmbH, Germany. All rights reserved.
+ * Original author: Edmund Wagner
+ * Creation date: 18.06.2007
+ *
+ * Source: $HeadURL$
+ * Last changed: $LastChangedDate$
+ * 
+ * the unrar licence applies to all junrar source and binary distributions 
+ * you are not allowed to use this source to re-create the RAR compression algorithm
+ * 
+ * Here some html entities which can be used for escaping javadoc tags:
+ * "&":  "&#038;" or "&amp;"
+ * "<":  "&#060;" or "&lt;"
+ * ">":  "&#062;" or "&gt;"
+ * "@":  "&#064;" 
+ */
+package com.github.junrar.io;
+
+/**
+ * Read / write numbers to a byte[] regarding the endianness of the array
+ * 
+ * @author $LastChangedBy$
+ * @version $LastChangedRevision$
+ */
+public class Raw {
+    /**
+     * Read a short value from the byte array at the given position (Big Endian)
+     * 
+     * @param array
+     *            the array to read from
+     * @param pos
+     *            the position
+     * @return the value
+     */
+    public static final short readShortBigEndian(byte[] array, int pos) {
+	short temp = 0;
+	temp |= array[pos] & 0xff;
+	temp <<= 8;
+	temp |= array[pos + 1] & 0xff;
+	return temp;
+    }
+
+    /**
+     * Read a int value from the byte array at the given position (Big Endian)
+     * 
+     * @param array
+     *            the array to read from
+     * @param pos
+     *            the offset
+     * @return the value
+     */
+    public static final int readIntBigEndian(byte[] array, int pos) {
+	int temp = 0;
+	temp |= array[pos] & 0xff;
+	temp <<= 8;
+	temp |= array[pos + 1] & 0xff;
+	temp <<= 8;
+	temp |= array[pos + 2] & 0xff;
+	temp <<= 8;
+	temp |= array[pos + 3] & 0xff;
+	return temp;
+    }
+
+    /**
+     * Read a long value from the byte array at the given position (Big Endian)
+     * 
+     * @param array
+     *            the array to read from
+     * @param pos
+     *            the offset
+     * @return the value
+     */
+    public static final long readLongBigEndian(byte[] array, int pos) {
+	int temp = 0;
+	temp |= array[pos] & 0xff;
+	temp <<= 8;
+	temp |= array[pos + 1] & 0xff;
+	temp <<= 8;
+	temp |= array[pos + 2] & 0xff;
+	temp <<= 8;
+	temp |= array[pos + 3] & 0xff;
+	temp <<= 8;
+	temp |= array[pos + 4] & 0xff;
+	temp <<= 8;
+	temp |= array[pos + 5] & 0xff;
+	temp <<= 8;
+	temp |= array[pos + 6] & 0xff;
+	temp <<= 8;
+	temp |= array[pos + 7] & 0xff;
+	return temp;
+    }
+
+    /**
+     * Read a short value from the byte array at the given position (little
+     * Endian)
+     * 
+     * @param array
+     *            the array to read from
+     * @param pos
+     *            the offset
+     * @return the value
+     */
+    public static final short readShortLittleEndian(byte[] array, int pos) {
+	short result = 0;
+	result += array[pos + 1] & 0xff;
+	result <<= 8;
+	result += array[pos] & 0xff;
+	return result;
+    }
+
+    /**
+     * Read an int value from the byte array at the given position (little
+     * Endian)
+     * 
+     * @param array
+     *            the array to read from
+     * @param pos
+     *            the offset
+     * @return the value
+     */
+    public static final int readIntLittleEndian(byte[] array, int pos) {
+	return ((array[pos + 3] & 0xff) << 24)
+		| ((array[pos + 2] & 0xff) << 16)
+		| ((array[pos + 1] & 0xff) << 8) | ((array[pos] & 0xff));
+    }
+
+    /**
+     * Read an long value(unsigned int) from the byte array at the given
+     * position (little Endian)
+     * 
+     * @param array
+     * @param pos
+     * @return
+     */
+    public static final long readIntLittleEndianAsLong(byte[] array, int pos) {
+	return (((long) array[pos + 3] & 0xff) << 24)
+		| (((long) array[pos + 2] & 0xff) << 16)
+		| (((long) array[pos + 1] & 0xff) << 8)
+		| (((long) array[pos] & 0xff));
+    }
+
+    /**
+     * Read a long value from the byte array at the given position (little
+     * Endian)
+     * 
+     * @param array
+     *            the array to read from
+     * @param pos
+     *            the offset
+     * @return the value
+     */
+    public static final long readLongLittleEndian(byte[] array, int pos) {
+	int temp = 0;
+	temp |= array[pos + 7] & 0xff;
+	temp <<= 8;
+	temp |= array[pos + 6] & 0xff;
+	temp <<= 8;
+	temp |= array[pos + 5] & 0xff;
+	temp <<= 8;
+	temp |= array[pos + 4] & 0xff;
+	temp <<= 8;
+	temp |= array[pos + 3] & 0xff;
+	temp <<= 8;
+	temp |= array[pos + 2] & 0xff;
+	temp <<= 8;
+	temp |= array[pos + 1] & 0xff;
+	temp <<= 8;
+	temp |= array[pos];
+	return temp;
+    }
+
+    /**
+     * Write a short value into the byte array at the given position (Big
+     * endian)
+     * 
+     * @param array
+     *            the array
+     * @param pos
+     *            the offset
+     * @param value
+     *            the value to write
+     */
+    public static final void writeShortBigEndian(byte[] array, int pos,
+	    short value) {
+	array[pos] = (byte) (value >>> 8);
+	array[pos + 1] = (byte) (value & 0xFF);
+
+    }
+
+    /**
+     * Write an int value into the byte array at the given position (Big endian)
+     * 
+     * @param array
+     *            the array
+     * @param pos
+     *            the offset
+     * @param value
+     *            the value to write
+     */
+    public static final void writeIntBigEndian(byte[] array, int pos, int value) {
+	array[pos] = (byte) ((value >>> 24) & 0xff);
+	array[pos + 1] = (byte) ((value >>> 16) & 0xff);
+	array[pos + 2] = (byte) ((value >>> 8) & 0xff);
+	array[pos + 3] = (byte) ((value) & 0xff);
+
+    }
+
+    /**
+     * Write a long value into the byte array at the given position (Big endian)
+     * 
+     * @param array
+     *            the array
+     * @param pos
+     *            the offset
+     * @param value
+     *            the value to write
+     */
+    public static final void writeLongBigEndian(byte[] array, int pos,
+	    long value) {
+	array[pos] = (byte) (value >>> 56);
+	array[pos + 1] = (byte) (value >>> 48);
+	array[pos + 2] = (byte) (value >>> 40);
+	array[pos + 3] = (byte) (value >>> 32);
+	array[pos + 4] = (byte) (value >>> 24);
+	array[pos + 5] = (byte) (value >>> 16);
+	array[pos + 6] = (byte) (value >>> 8);
+	array[pos + 7] = (byte) (value & 0xFF);
+
+    }
+
+    /**
+     * Write a short value into the byte array at the given position (little
+     * endian)
+     * 
+     * @param array
+     *            the array
+     * @param pos
+     *            the offset
+     * @param value
+     *            the value to write
+     */
+    public static final void writeShortLittleEndian(byte[] array, int pos,
+	    short value) {
+	array[pos + 1] = (byte) (value >>> 8);
+	array[pos] = (byte) (value & 0xFF);
+
+    }
+
+    /**
+     * Increment a short value at the specified position by the specified amount
+     * (little endian).
+     */
+    public static final void incShortLittleEndian(byte[] array, int pos, int dv) {
+	int c = ((array[pos] & 0xff) + (dv & 0xff)) >>> 8;
+	array[pos] += dv & 0xff;
+	if ((c > 0) || ((dv & 0xff00) != 0)) {
+	    array[pos + 1] += ((dv >>> 8) & 0xff) + c;
+	}
+    }
+
+    /**
+     * Write an int value into the byte array at the given position (little
+     * endian)
+     * 
+     * @param array
+     *            the array
+     * @param pos
+     *            the offset
+     * @param value
+     *            the value to write
+     */
+    public static final void writeIntLittleEndian(byte[] array, int pos,
+	    int value) {
+	array[pos + 3] = (byte) (value >>> 24);
+	array[pos + 2] = (byte) (value >>> 16);
+	array[pos + 1] = (byte) (value >>> 8);
+	array[pos] = (byte) (value & 0xFF);
+
+    }
+
+    /**
+     * Write a long value into the byte array at the given position (little
+     * endian)
+     * 
+     * @param array
+     *            the array
+     * @param pos
+     *            the offset
+     * @param value
+     *            the value to write
+     */
+    public static final void writeLongLittleEndian(byte[] array, int pos,
+	    long value) {
+	array[pos + 7] = (byte) (value >>> 56);
+	array[pos + 6] = (byte) (value >>> 48);
+	array[pos + 5] = (byte) (value >>> 40);
+	array[pos + 4] = (byte) (value >>> 32);
+	array[pos + 3] = (byte) (value >>> 24);
+	array[pos + 2] = (byte) (value >>> 16);
+	array[pos + 1] = (byte) (value >>> 8);
+	array[pos] = (byte) (value & 0xFF);
+
+    }
+}

+ 90 - 0
org.fox.ttcomics/src/main/java/com/github/junrar/io/ReadOnlyAccessByteArray.java

@@ -0,0 +1,90 @@
+/*
+ * Copyright (c) 2007 innoSysTec (R) GmbH, Germany. All rights reserved.
+ * Original author: Edmund Wagner
+ * Creation date: 30.05.2007
+ *
+ * Source: $HeadURL$
+ * Last changed: $LastChangedDate$
+ * 
+ * the unrar licence applies to all junrar source and binary distributions 
+ * you are not allowed to use this source to re-create the RAR compression algorithm
+ * 
+ * Here some html entities which can be used for escaping javadoc tags:
+ * "&":  "&#038;" or "&amp;"
+ * "<":  "&#060;" or "&lt;"
+ * ">":  "&#062;" or "&gt;"
+ * "@":  "&#064;" 
+ */
+package com.github.junrar.io;
+
+import java.io.EOFException;
+import java.io.IOException;
+
+/**
+ * A File like access to a byte array.
+ * (seek and read certain number of bytes)
+ *
+ * @author $LastChangedBy$
+ * @version $LastChangedRevision$
+ */
+public class ReadOnlyAccessByteArray implements IReadOnlyAccess{
+
+	private int positionInFile;
+	private byte[] file;
+	
+	/**
+	 * Initialize with byte[ ]
+	 * @param file the file given as byte array
+	 */
+	public ReadOnlyAccessByteArray(byte[] file){
+		if(file == null){
+			throw new NullPointerException("file must not be null!!");
+		}
+		this.file = file;
+		this.positionInFile = 0;
+	}
+
+    public long getPosition() throws IOException {
+		return positionInFile;
+	}
+
+	public void setPosition(long pos) throws IOException {
+		if (pos < file.length && pos >= 0){
+			this.positionInFile = (int)pos;
+		}
+        else{
+			throw new EOFException();
+		}
+	}
+
+    /** Read a single byte of data. */
+    public int read() throws IOException {
+        return file[positionInFile++];
+    }
+
+	/**
+     * Read up to <tt>count</tt> bytes to the specified buffer.
+     */
+    public int read(byte[] buffer, int off, int count) throws IOException {
+        int read = Math.min(count, file.length-positionInFile);
+        System.arraycopy(file, positionInFile, buffer, off, read);
+        positionInFile += read;
+        return read;
+    }
+
+	public int readFully(byte[] buffer, int count) throws IOException {
+		if(buffer == null ){
+			throw new NullPointerException("buffer must not be null");
+		}
+		if(count == 0){
+			throw new IllegalArgumentException("cannot read 0 bytes ;-)");
+		}
+		int read = Math.min(count, file.length-(int)positionInFile-1);	
+		System.arraycopy(file, (int)positionInFile, buffer, 0, read );
+		positionInFile+=read;
+		return read;
+	}
+
+    public void close() throws IOException {
+    }
+}

+ 55 - 0
org.fox.ttcomics/src/main/java/com/github/junrar/io/ReadOnlyAccessFile.java

@@ -0,0 +1,55 @@
+/*
+ * Copyright (c) 2007 innoSysTec (R) GmbH, Germany. All rights reserved.
+ * Original author: Edmund Wagner
+ * Creation date: 23.05.2007
+ *
+ * Source: $HeadURL$
+ * Last changed: $LastChangedDate$
+ * 
+ * the unrar licence applies to all junrar source and binary distributions 
+ * you are not allowed to use this source to re-create the RAR compression algorithm
+ * 
+ * Here some html entities which can be used for escaping javadoc tags:
+ * "&":  "&#038;" or "&amp;"
+ * "<":  "&#060;" or "&lt;"
+ * ">":  "&#062;" or "&gt;"
+ * "@":  "&#064;" 
+ */
+package com.github.junrar.io;
+
+import java.io.File;
+import java.io.FileNotFoundException;
+import java.io.IOException;
+import java.io.RandomAccessFile;
+
+/**
+ * DOCUMENT ME
+ *
+ * @author $LastChangedBy$
+ * @version $LastChangedRevision$
+ */
+public class ReadOnlyAccessFile extends RandomAccessFile
+        implements IReadOnlyAccess{
+
+	/**
+	 * @param file the file
+	 * @throws FileNotFoundException
+	 */
+	public ReadOnlyAccessFile(File file) throws FileNotFoundException {
+		super(file, "r");
+	}
+
+	public int readFully(byte[] buffer, int count) throws IOException {
+        assert (count > 0) : count;
+        this.readFully(buffer, 0, count);
+        return count;
+    }
+
+	public long getPosition() throws IOException {
+        return this.getFilePointer();
+	}
+
+	public void setPosition(long pos) throws IOException {
+        this.seek(pos);
+	}
+}

+ 81 - 0
org.fox.ttcomics/src/main/java/com/github/junrar/io/ReadOnlyAccessInputStream.java

@@ -0,0 +1,81 @@
+/*
+ * Copyright (c) 2007 innoSysTec (R) GmbH, Germany. All rights reserved.
+ * Original author: Edmund Wagner
+ * Creation date: 26.06.2007
+ *
+ * Source: $HeadURL$
+ * Last changed: $LastChangedDate$
+ * 
+ * the unrar licence applies to all junrar source and binary distributions 
+ * you are not allowed to use this source to re-create the RAR compression
+ * algorithm
+ * 
+ * Here some html entities which can be used for escaping javadoc tags:
+ * "&":  "&#038;" or "&amp;"
+ * "<":  "&#060;" or "&lt;"
+ * ">":  "&#062;" or "&gt;"
+ * "@":  "&#064;" 
+ */
+package com.github.junrar.io;
+
+import java.io.IOException;
+import java.io.InputStream;
+
+/**
+ * DOCUMENT ME
+ *
+ * @author $LastChangedBy$
+ * @version $LastChangedRevision$
+ */
+public class ReadOnlyAccessInputStream extends InputStream {
+	private IReadOnlyAccess file;
+	
+	private long curPos;
+	private final long startPos;
+	private final long endPos;
+	
+	public ReadOnlyAccessInputStream(IReadOnlyAccess file, long startPos,
+            long endPos) throws IOException {
+		super();
+		this.file = file;
+		this.startPos = startPos;
+		curPos = startPos;
+		this.endPos = endPos;
+		file.setPosition(curPos);
+	}
+
+	@Override
+	public int read() throws IOException {
+        if (curPos == endPos) {
+            return -1;
+        }
+        else {
+            int b = file.read();
+            curPos++;
+            return b;
+        }
+	}
+
+	@Override
+	public int read(byte[] b, int off, int len) throws IOException {
+        if (len == 0) {
+            return 0;
+        }
+        if (curPos == endPos) {
+            return -1;
+        }
+        int bytesRead = file.read(b, off,
+                (int)Math.min(len, endPos - curPos));
+        curPos += bytesRead;
+        return bytesRead;
+	}
+
+	@Override
+	public int read(byte[] b) throws IOException {
+        return read(b, 0, b.length);
+	}
+//
+//    public void close() throws IOException {
+//        file.close();
+//    }
+}

+ 66 - 0
org.fox.ttcomics/src/main/java/com/github/junrar/rarfile/AVHeader.java

@@ -0,0 +1,66 @@
+/*
+ * Copyright (c) 2007 innoSysTec (R) GmbH, Germany. All rights reserved.
+ * Original author: Edmund Wagner
+ * Creation date: 24.05.2007
+ *
+ * Source: $HeadURL$
+ * Last changed: $LastChangedDate$
+ * 
+ * 
+ * the unrar licence applies to all junrar source and binary distributions 
+ * you are not allowed to use this source to re-create the RAR compression algorithm
+ *
+ * Here some html entities which can be used for escaping javadoc tags:
+ * "&":  "&#038;" or "&amp;"
+ * "<":  "&#060;" or "&lt;"
+ * ">":  "&#062;" or "&gt;"
+ * "@":  "&#064;" 
+ */
+package com.github.junrar.rarfile;
+
+import com.github.junrar.io.Raw;
+
+/**
+ * extended version info header
+ *
+ * @author $LastChangedBy$
+ * @version $LastChangedRevision$
+ */
+public class AVHeader extends BaseBlock {
+	
+	public static final int avHeaderSize = 7;
+	
+	private byte unpackVersion;
+	private byte method;
+	private byte avVersion;
+	private int avInfoCRC;
+	
+	public AVHeader(BaseBlock bb, byte[] avHeader){
+		super(bb);
+		
+		int pos =0;
+		unpackVersion |= avHeader[pos]&0xff;
+		pos++;
+		method |= avHeader[pos]&0xff;
+		pos++;
+		avVersion |= avHeader[pos]&0xff;
+		pos++;
+		avInfoCRC = Raw.readIntLittleEndian(avHeader, pos);
+	}
+	
+	public int getAvInfoCRC() {
+		return avInfoCRC;
+	}
+	
+	public byte getAvVersion() {
+		return avVersion;
+	}
+	
+	public byte getMethod() {
+		return method;
+	}
+	
+	public byte getUnpackVersion() {
+		return unpackVersion;
+	}
+}

+ 179 - 0
org.fox.ttcomics/src/main/java/com/github/junrar/rarfile/BaseBlock.java

@@ -0,0 +1,179 @@
+/*
+ * Copyright (c) 2007 innoSysTec (R) GmbH, Germany. All rights reserved.
+ * Original author: Edmund Wagner
+ * Creation date: 22.05.2007
+ *
+ * Source: $HeadURL$
+ * Last changed: $LastChangedDate$
+ * 
+ * 
+ * the unrar licence applies to all junrar source and binary distributions 
+ * you are not allowed to use this source to re-create the RAR compression algorithm
+ *
+ * Here some html entities which can be used for escaping javadoc tags:
+ * "&":  "&#038;" or "&amp;"
+ * "<":  "&#060;" or "&lt;"
+ * ">":  "&#062;" or "&gt;"
+ * "@":  "&#064;" 
+ */
+package com.github.junrar.rarfile;
+
+import com.github.junrar.io.Raw;
+
+
+
+/**
+ * Base class of all rar headers
+ *
+ * @author $LastChangedBy$
+ * @version $LastChangedRevision$
+ */
+public class BaseBlock{
+	
+	//Log //logger = LogFactory.getLog(BaseBlock.class.getName());
+	
+	public static final short BaseBlockSize = 7;
+	
+	//TODO move somewhere else
+	
+	public static final short MHD_VOLUME = 0x0001;
+	public static final short MHD_COMMENT = 0x0002;
+	public static final short MHD_LOCK = 0x0004;
+	public static final short MHD_SOLID = 0x0008;
+	public static final short MHD_PACK_COMMENT = 0x0010;
+	public static final short MHD_NEWNUMBERING = 0x0010;
+	public static final short MHD_AV = 0x0020;
+	public static final short MHD_PROTECT = 0x0040;
+	public static final short MHD_PASSWORD = 0x0080;
+	public static final short MHD_FIRSTVOLUME = 0x0100;
+	public static final short MHD_ENCRYPTVER = 0x0200;
+	
+	
+	public static final short LHD_SPLIT_BEFORE =  0x0001;
+	public static final short LHD_SPLIT_AFTER  =  0x0002;
+	public static final short LHD_PASSWORD     =  0x0004;
+	public static final short LHD_COMMENT      =  0x0008;
+	public static final short LHD_SOLID        =  0x0010;
+
+	public static final short LHD_WINDOWMASK   =  0x00e0;
+	public static final short LHD_WINDOW64     =  0x0000;
+	public static final short LHD_WINDOW128    =  0x0020;
+	public static final short LHD_WINDOW256    =  0x0040;
+	public static final short LHD_WINDOW512    =  0x0060;
+	public static final short LHD_WINDOW1024   =  0x0080;
+	public static final short LHD_WINDOW2048   =  0x00a0;
+	public static final short LHD_WINDOW4096   =  0x00c0;
+	public static final short LHD_DIRECTORY    =  0x00e0;
+
+	public static final short LHD_LARGE        =  0x0100;
+	public static final short LHD_UNICODE      =  0x0200;
+	public static final short LHD_SALT         =  0x0400;
+	public static final short LHD_VERSION      =  0x0800;
+	public static final short LHD_EXTTIME      =  0x1000;
+	public static final short LHD_EXTFLAGS     =  0x2000;
+
+	public static final short SKIP_IF_UNKNOWN  =  0x4000;
+	public static final short LONG_BLOCK 	   = -0x8000;
+
+	public static final short EARC_NEXT_VOLUME =  0x0001;
+	public static final short EARC_DATACRC     =  0x0002;
+	public static final short EARC_REVSPACE    =  0x0004;
+	public static final short EARC_VOLNUMBER   =  0x0008;
+	
+	
+	protected long positionInFile;
+	
+	protected short headCRC = 0;
+	protected byte headerType = 0;
+	protected short flags = 0;
+	protected short headerSize = 0 ;
+
+	/**
+	 * 
+	 */
+	public BaseBlock(){
+		
+	}
+	
+	public BaseBlock(BaseBlock bb){
+		this.flags = bb.getFlags();
+    	this.headCRC = bb.getHeadCRC();
+    	this.headerType = bb.getHeaderType().getHeaderByte();
+    	this.headerSize = bb.getHeaderSize();
+    	this.positionInFile = bb.getPositionInFile();
+	}
+	public BaseBlock(byte[] baseBlockHeader){
+		
+		int pos = 0;
+		this.headCRC = Raw.readShortLittleEndian(baseBlockHeader, pos);
+		pos+=2;
+		this.headerType |= baseBlockHeader[pos]&0xff;
+		pos++;
+		this.flags = Raw.readShortLittleEndian(baseBlockHeader, pos);
+		pos+=2;
+		this.headerSize = Raw.readShortLittleEndian(baseBlockHeader, pos);
+	}
+	
+	
+	public boolean hasArchiveDataCRC(){
+		return (this.flags & EARC_DATACRC)!=0;
+	}
+	
+	public boolean hasVolumeNumber(){
+		return (this.flags & EARC_VOLNUMBER)!=0;
+	}
+	
+	public boolean hasEncryptVersion(){
+		return (flags & MHD_ENCRYPTVER)!=0;
+	}
+	
+	/**