├── .github
└── workflows
│ └── maven.yml
├── .gitignore
├── .travis.yml
├── LICENSE
├── README.adoc
├── examples
├── archive
│ ├── README.md
│ ├── pom.xml
│ ├── src
│ │ └── main
│ │ │ └── java
│ │ │ └── com
│ │ │ └── github
│ │ │ └── stephenc
│ │ │ └── javaisotools
│ │ │ └── examples
│ │ │ └── archive
│ │ │ ├── IsoCreation.java
│ │ │ └── Main.java
│ └── test directory
│ │ └── test.txt
└── extract
│ ├── README.md
│ ├── pom.xml
│ ├── src
│ └── main
│ │ └── java
│ │ └── com
│ │ └── github
│ │ └── stephenc
│ │ └── javaisotools
│ │ └── examples
│ │ └── archive
│ │ ├── Main.java
│ │ └── ReadIso.java
│ └── test.iso
├── iso9660-ant-tasks
├── pom.xml
└── src
│ ├── it
│ ├── basic
│ │ ├── build.xml
│ │ ├── pom.xml
│ │ ├── src
│ │ │ └── iso
│ │ │ │ └── root
│ │ │ │ ├── a.txt
│ │ │ │ └── b.txt
│ │ └── verify.bsh
│ └── settings.xml
│ └── main
│ ├── java
│ └── com
│ │ └── github
│ │ └── stephenc
│ │ └── javaisotools
│ │ └── ant
│ │ └── IsoTask.java
│ └── resources
│ └── com
│ └── github
│ └── stephenc
│ └── javaisotools
│ └── ant
│ └── antlib.xml
├── iso9660-maven-plugin
├── pom.xml
└── src
│ ├── it
│ ├── basic
│ │ ├── pom.xml
│ │ ├── src
│ │ │ └── main
│ │ │ │ └── resources
│ │ │ │ └── README.txt
│ │ └── verify.bsh
│ ├── long
│ │ ├── pom.xml
│ │ ├── src
│ │ │ └── main
│ │ │ │ └── resources
│ │ │ │ └── 012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345.txt
│ │ └── verify.bsh
│ ├── settings.xml
│ └── truncate
│ │ ├── invoker.properties
│ │ ├── pom.xml
│ │ ├── src
│ │ └── main
│ │ │ └── resources
│ │ │ └── 012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345.txt
│ │ └── verify.bsh
│ ├── main
│ ├── java
│ │ └── com
│ │ │ └── github
│ │ │ └── stephenc
│ │ │ └── javaisotools
│ │ │ └── maven
│ │ │ ├── ArchiveEntryDataReference.java
│ │ │ ├── FilePermission.java
│ │ │ ├── Iso9660Archiver.java
│ │ │ ├── Iso9660ArchiverException.java
│ │ │ └── PackageMojo.java
│ └── resources
│ │ └── META-INF
│ │ └── plexus
│ │ └── components.xml
│ └── test
│ └── java
│ └── com
│ └── github
│ └── stephenc
│ └── javaisotools
│ └── maven
│ └── Iso9660ArchiverTest.java
├── iso9660-vfs-impl
├── pom.xml
└── src
│ └── main
│ ├── java
│ └── com
│ │ └── github
│ │ └── stephenc
│ │ └── javaisotools
│ │ └── vfs
│ │ └── provider
│ │ └── iso
│ │ ├── IsoFileObject.java
│ │ ├── IsoFileProvider.java
│ │ └── IsoFileSystem.java
│ └── resources
│ └── META-INF
│ └── vfs-providers.xml
├── iso9660-writer
├── ISOtest.java
├── README.txt
├── build.xml
├── clear.sh
├── makerd.sh
├── perf.sh
├── perf.txt
├── pom.xml
├── run.sh
└── src
│ ├── main
│ └── java
│ │ └── com
│ │ └── github
│ │ └── stephenc
│ │ └── javaisotools
│ │ ├── eltorito
│ │ └── impl
│ │ │ ├── ElToritoConfig.java
│ │ │ ├── ElToritoFactory.java
│ │ │ ├── ElToritoHandler.java
│ │ │ └── ElToritoLayoutHelper.java
│ │ ├── iso9660
│ │ ├── BootConfig.java
│ │ ├── ConfigException.java
│ │ ├── FilenameDataReference.java
│ │ ├── ISO9660Directory.java
│ │ ├── ISO9660DirectoryIterator.java
│ │ ├── ISO9660File.java
│ │ ├── ISO9660HierarchyObject.java
│ │ ├── ISO9660RootDirectory.java
│ │ ├── ISOFileSet.java
│ │ ├── ISOTask.java
│ │ ├── LayoutHelper.java
│ │ ├── NamingConventions.java
│ │ ├── PartitionConfig.java
│ │ ├── StandardConfig.java
│ │ ├── StandardHandler.java
│ │ ├── impl
│ │ │ ├── CreateISO.java
│ │ │ ├── FileElement.java
│ │ │ ├── FileHandler.java
│ │ │ ├── ISO9660Config.java
│ │ │ ├── ISO9660Constants.java
│ │ │ ├── ISO9660DateDataReference.java
│ │ │ ├── ISO9660DirectoryRecord.java
│ │ │ ├── ISO9660Element.java
│ │ │ ├── ISO9660Factory.java
│ │ │ ├── ISO9660FilenameDataReference.java
│ │ │ ├── ISO9660Handler.java
│ │ │ ├── ISO9660LayoutHelper.java
│ │ │ ├── ISO9660NamingConventions.java
│ │ │ ├── ISO9660PathTableRecord.java
│ │ │ ├── ISO9660RockRidgeFactory.java
│ │ │ ├── ISO9660ShortDateDataReference.java
│ │ │ ├── ISOImageFileHandler.java
│ │ │ ├── LogicalSectorElement.java
│ │ │ └── LogicalSectorPaddingHandler.java
│ │ ├── sabre
│ │ │ └── impl
│ │ │ │ ├── BothShortDataReference.java
│ │ │ │ ├── BothWordDataReference.java
│ │ │ │ ├── EmptyByteArrayDataReference.java
│ │ │ │ ├── LSBFShortDataReference.java
│ │ │ │ └── LSBFWordDataReference.java
│ │ └── volumedescriptors
│ │ │ ├── BootRecord.java
│ │ │ ├── ISO9660VolumeDescriptor.java
│ │ │ ├── PrimaryVolumeDescriptor.java
│ │ │ ├── StandardVolumeDescriptor.java
│ │ │ ├── SupplementaryVolumeDescriptor.java
│ │ │ ├── VolumeDescriptorSetTerminator.java
│ │ │ └── VolumePartitionDescriptor.java
│ │ ├── joliet
│ │ └── impl
│ │ │ ├── JolietConfig.java
│ │ │ ├── JolietFilenameDataReference.java
│ │ │ ├── JolietHandler.java
│ │ │ ├── JolietLayoutHelper.java
│ │ │ └── JolietNamingConventions.java
│ │ └── rockridge
│ │ └── impl
│ │ ├── POSIXFileMode.java
│ │ ├── POSIXFileModesFactory.java
│ │ ├── RRIPFactory.java
│ │ ├── RockRidgeConfig.java
│ │ ├── RockRidgeFilenameDataReference.java
│ │ ├── RockRidgeLayoutHelper.java
│ │ ├── RockRidgeNamingConventions.java
│ │ ├── SUSPFactory.java
│ │ ├── SystemUseEntryElement.java
│ │ └── SystemUseEntryHandler.java
│ └── test
│ ├── java
│ └── com
│ │ └── github
│ │ └── stephenc
│ │ └── javaisotools
│ │ └── iso9660
│ │ └── impl
│ │ └── CreateISOTest.java
│ └── resources
│ └── test.properties
├── loop-fs-api
├── CREDITS
├── pom.xml
└── src
│ └── main
│ └── java
│ └── com
│ └── github
│ └── stephenc
│ └── javaisotools
│ └── loopfs
│ └── api
│ ├── FileEntry.java
│ ├── FileSystem.java
│ └── LoopFileSystemException.java
├── loop-fs-iso-impl
├── pom.xml
└── src
│ ├── main
│ └── java
│ │ └── com
│ │ └── github
│ │ └── stephenc
│ │ └── javaisotools
│ │ └── loopfs
│ │ └── iso9660
│ │ ├── Constants.java
│ │ ├── EntryInputStream.java
│ │ ├── EntryIterator.java
│ │ ├── Iso9660FileEntry.java
│ │ ├── Iso9660FileSystem.java
│ │ ├── Iso9660VolumeDescriptorSet.java
│ │ └── Util.java
│ └── test
│ ├── images
│ ├── iso
│ │ └── test1.iso
│ └── raw
│ │ └── test1
│ │ └── root
│ │ ├── a.txt
│ │ └── b.txt
│ ├── java
│ └── com
│ │ └── github
│ │ └── stephenc
│ │ └── javaisotools
│ │ └── loopfs
│ │ └── iso9660
│ │ └── Iso9660FileSystemTest.java
│ └── resources
│ └── test.properties
├── loop-fs-spi
├── pom.xml
└── src
│ └── main
│ └── java
│ └── com
│ └── github
│ └── stephenc
│ └── javaisotools
│ └── loopfs
│ ├── spi
│ ├── AbstractBlockFileSystem.java
│ ├── AbstractFileSystem.java
│ ├── SeekableInput.java
│ ├── SeekableInputFile.java
│ ├── SeekableInputFileHadoop.java
│ └── VolumeDescriptorSet.java
│ └── util
│ ├── BigEndian.java
│ └── LittleEndian.java
├── loop-fs-udf-impl
├── pom.xml
└── src
│ └── main
│ └── java
│ └── com
│ └── github
│ └── stephenc
│ └── javaisotools
│ └── loopfs
│ └── udf
│ ├── Constants.java
│ ├── UDFFileEntry.java
│ ├── UDFFileSystem.java
│ └── UDFVolumeDescriptorSet.java
├── pom.xml
└── sabre
├── pom.xml
└── src
└── main
└── java
└── com
└── github
└── stephenc
└── javaisotools
├── sabre
├── ContentHandler.java
├── DataReference.java
├── DataReferenceHelper.java
├── Element.java
├── Fixup.java
├── FixupListener.java
├── HandlerException.java
├── StreamHandler.java
├── StructureHandler.java
├── VariableDataReference.java
├── impl
│ ├── ByteArrayDataReference.java
│ ├── ByteDataReference.java
│ ├── ChainingStreamHandler.java
│ ├── CopyingStreamHandler.java
│ ├── DWordDataReference.java
│ ├── DebugStreamHandler.java
│ ├── FileDataReference.java
│ ├── FileFixup.java
│ ├── IntegerArrayDataReference.java
│ ├── LongElement.java
│ ├── SerializingAtomHandler.java
│ ├── ShortDataReference.java
│ ├── ThreeByteDataReference.java
│ ├── URLDataReference.java
│ ├── WordDataReference.java
│ └── XMLAtomHandler.java
├── io
│ └── LimitingInputStream.java
└── util
│ └── SingleFileFixupList.java
└── udflib
├── SabreUDFElement.java
├── SabreUDFElementFactory.java
├── SabreUDFImageBuilder.java
├── UDFImageBuilder.java
├── UDFImageBuilderAntTask.java
├── UDFImageBuilderFile.java
├── UDFLayoutInformation.java
├── UDFRevision.java
├── UDFTest.java
├── handler
├── DescriptorTagHandler.java
├── PaddingHandler.java
├── SerializationHandler.java
├── UDF102Handler.java
├── UDF201Handler.java
└── UDF260Handler.java
├── structures
├── AnchorVolumeDescriptorPointer.java
├── CharSpec.java
├── EntityID.java
├── Extend_ad.java
├── ExtendedFileEntry.java
├── FileEntry.java
├── FileIdentifierDescriptor.java
├── FileSetDescriptor.java
├── IcbTag.java
├── ImplementationUseVolumeDescriptor.java
├── LVInformation.java
├── Lb_addr.java
├── LogicalVolumeDescriptor.java
├── LogicalVolumeHeaderDescriptor.java
├── LogicalVolumeIntegrityDescriptor.java
├── Long_ad.java
├── PartitionDescriptor.java
├── PartitionHeaderDescriptor.java
├── PartitionMapType1.java
├── PartitionMapType2.java
├── PrimaryVolumeDescriptor.java
├── ReservedArea.java
├── Short_ad.java
├── SpaceBitmapDescriptor.java
├── Tag.java
├── TerminatingDescriptor.java
├── Timestamp.java
├── UnallocatedSpaceDescriptor.java
├── VolumeDescriptorSequenceItem.java
├── VolumeRecognitionSequence.java
└── VolumeStructureDescriptor.java
└── tools
├── BinaryTools.java
├── Checksum.java
├── OSTAIdentifierTranslation.java
├── OSTAUnicode.java
├── Permissions.java
└── UniqueIdDisposer.java
/.github/workflows/maven.yml:
--------------------------------------------------------------------------------
1 | # This workflow will build a Java project with Maven
2 | # For more information see: https://help.github.com/actions/language-and-framework-guides/building-and-testing-java-with-maven
3 |
4 | name: Java CI with Maven
5 |
6 | on:
7 | push:
8 | branches: [ main ]
9 | pull_request:
10 | branches: [ main ]
11 |
12 | jobs:
13 | build:
14 |
15 | runs-on: ubuntu-latest
16 |
17 | steps:
18 | - uses: actions/checkout@v2
19 | - name: Set up JDK 1.8
20 | uses: actions/setup-java@v1
21 | with:
22 | java-version: 1.8
23 | - name: Build with Maven
24 | run: mvn -B verify --file pom.xml
25 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | build
2 | target
3 | *.iml
4 | *.ipr
5 | *.iws
6 | .idea
7 | .project
8 | .settings
9 | .classpath
10 |
--------------------------------------------------------------------------------
/.travis.yml:
--------------------------------------------------------------------------------
1 | language: java
--------------------------------------------------------------------------------
/README.adoc:
--------------------------------------------------------------------------------
1 | = java-iso-tools
2 |
3 | This project provides a number of tools for manipulating iso9660 filesystems natively within Java.
4 |
5 | image:https://img.shields.io/badge/project%20status-unmaintained-red[Project Status]
6 | image:https://img.shields.io/maven-central/v/com.github.stephenc.java-iso-tools/java-iso-tools-parent[Maven Central Latest Version]
7 | image:https://github.com/stephenc/java-iso-tools/workflows/Java%20CI%20with%20Maven/badge.svg[Java CI with Maven]
8 |
9 | == Project status
10 |
11 | I (link:https://github.com/stephenc[@stephenc]) am not actively maintaining this repository.
12 | Because the Maven Central publishing of this is tied to my personal account, I cannot transfer the project to somebody else without changing the GroupId.
13 |
14 | If somebody wants to take responsibility for vetting pull requests, etc I am happy to give them commit permissions and I can set up something to allow periodic releases.
15 |
16 | NOTE: If somebody wants to take over as an offical fork at the a new GroupId, create a pull request against this README with a pointer to the fork.
17 | If, after 3 months there are more thumbs up from users than thumbs down, I will merge the pull request for the fork with the most "votes".
18 |
19 | If nobody steps forward, do not expect any new releases or any work on the open issues.
20 |
21 | == Getting started quickly
22 |
23 | Visit link:https://mvnrepository.com/artifact/com.github.stephenc.java-iso-tools[mvnrepository.com], select the parts you need for your project, and then add that to your build system via Gradle, Maven, or other.
24 |
25 | == Building from source
26 |
27 | These instructions will get you a copy of the project up and running on your local machine for development and testing purposes.
28 | See deployment for notes on how to deploy the project on a live system.
29 |
30 | === Prerequisites
31 |
32 | * Maven
33 | * JDK
34 |
35 | === Installing
36 |
37 | Assuming you already have a working JDK and maven install.
38 |
39 | Compiling
40 |
41 | [source,bash]
42 | ----
43 | mvn compile
44 | ----
45 |
46 | == Running the tests
47 |
48 | NOTE: There are some default tests
49 |
50 | Use maven to run existing unit tests
51 |
52 | [source,bash]
53 | ----
54 | mvn test
55 | ----
56 |
57 | To run all tests including the Maven plugin integration tests:
58 |
59 | [source,bash]
60 | ----
61 | mvn verify
62 | ----
63 |
--------------------------------------------------------------------------------
/examples/archive/README.md:
--------------------------------------------------------------------------------
1 | This example shows how to create an virtual ISO, add files to it, then save it to a file.
2 |
--------------------------------------------------------------------------------
/examples/archive/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 | 4.0.0
6 |
7 |
8 | com.github.stephenc.java-iso-tools
9 | java-iso-tools-parent
10 | 2.0.1
11 |
12 |
13 | archive
14 | Example of Archiving
15 | 1.0-SNAPSHOT
16 |
17 |
18 |
19 | com.github.stephenc.java-iso-tools
20 | iso9660-maven-plugin
21 | 2.0.0
22 |
23 |
24 |
25 |
--------------------------------------------------------------------------------
/examples/archive/src/main/java/com/github/stephenc/javaisotools/examples/archive/Main.java:
--------------------------------------------------------------------------------
1 | package com.github.stephenc.javaisotools.examples.archive;
2 |
3 | import java.io.File;
4 |
5 | public class Main {
6 |
7 | public static void main(String[] args) {
8 | //Create a new root of our disc
9 | IsoCreation sampleCreation = new IsoCreation();
10 | //Add our files, you have to give a directory to use the recusively adding function
11 | sampleCreation.insertFile(new File("test directory"));
12 | //This is the base iso9660 standard file system
13 | sampleCreation.setIsoConfig("test");
14 | //To quote wikipedia "Rock Ridge is an extension to the ISO 9660 volume format, commonly used on CD-ROM and
15 | // DVD media, which adds POSIX file system semantics."
16 | sampleCreation.setRockConfig();
17 | //This is another extension to the standard after Windows 95 to add support for longer filenames
18 | sampleCreation.setJolietConfig("test");
19 | //El Torito is boot information for the disc
20 | sampleCreation.setElToritoConfig();
21 | //Finalize and save our ISO
22 | sampleCreation.finalizeDisc(new File("test.iso"));
23 | }
24 | }
25 |
--------------------------------------------------------------------------------
/examples/archive/test directory/test.txt:
--------------------------------------------------------------------------------
1 | test
2 |
--------------------------------------------------------------------------------
/examples/extract/README.md:
--------------------------------------------------------------------------------
1 | This is an example of how to Read an iso and store the files into a folder.
2 |
--------------------------------------------------------------------------------
/examples/extract/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 | 4.0.0
6 |
7 |
8 | com.github.stephenc.java-iso-tools
9 | java-iso-tools-parent
10 | 2.0.1
11 |
12 |
13 | extract
14 | Example of Archiving
15 | 1.0-SNAPSHOT
16 |
17 |
18 |
19 | com.github.stephenc.java-iso-tools
20 | loop-fs-iso-impl
21 | 2.0.1
22 |
23 |
24 |
25 |
--------------------------------------------------------------------------------
/examples/extract/src/main/java/com/github/stephenc/javaisotools/examples/archive/Main.java:
--------------------------------------------------------------------------------
1 | package com.github.stephenc.javaisotools.examples.archive;
2 |
3 | import java.io.File;
4 |
5 | public class Main {
6 |
7 | public static void main(String[] args) {
8 | ReadIso tempIso = new ReadIso(new File("test.iso"), new File("test directory"));
9 | }
10 | }
11 |
--------------------------------------------------------------------------------
/examples/extract/src/main/java/com/github/stephenc/javaisotools/examples/archive/ReadIso.java:
--------------------------------------------------------------------------------
1 | package com.github.stephenc.javaisotools.examples.archive;
2 |
3 | import java.io.File;
4 | import java.io.IOException;
5 | import java.nio.file.Files;
6 |
7 | import com.github.stephenc.javaisotools.loopfs.iso9660.Iso9660FileEntry;
8 | import com.github.stephenc.javaisotools.loopfs.iso9660.Iso9660FileSystem;
9 |
10 | /***
11 | * This is a adaptation of https://github.com/danveloper/provisioning-gradle-plugin/blob/master/src/main/groovy/
12 | * gradle/plugins/provisioning/tasks/image/ImageAssemblyTask.groovy
13 | */
14 |
15 | public class ReadIso {
16 | Iso9660FileSystem discFs;
17 |
18 | public ReadIso(File isoToRead, File saveLocation) {
19 |
20 | try {
21 | //Give the file and mention if this is treated as a read only file.
22 | discFs = new Iso9660FileSystem(isoToRead, true);
23 | } catch (IOException e) {
24 | e.printStackTrace();
25 | }
26 |
27 | //Make our saving folder if it does not exist
28 | if (!saveLocation.exists()) {
29 | saveLocation.mkdirs();
30 | }
31 |
32 | //Go through each file on the disc and save it.
33 | for (Iso9660FileEntry singleFile : discFs) {
34 | if (singleFile.isDirectory()) {
35 | new File(saveLocation, singleFile.getPath()).mkdirs();
36 | } else {
37 | File tempFile = new File(saveLocation, singleFile.getPath());
38 | try {
39 | //This is java 7, sorry if that is too new for some people
40 | Files.copy(discFs.getInputStream(singleFile), tempFile.toPath());
41 | } catch (IOException e) {
42 | e.printStackTrace();
43 | }
44 | }
45 | }
46 | }
47 | }
48 |
--------------------------------------------------------------------------------
/examples/extract/test.iso:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/stephenc/java-iso-tools/334caa435f58ebaa8a5f69eefc2e5ac247c0d6c2/examples/extract/test.iso
--------------------------------------------------------------------------------
/iso9660-ant-tasks/src/it/basic/build.xml:
--------------------------------------------------------------------------------
1 |
2 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
--------------------------------------------------------------------------------
/iso9660-ant-tasks/src/it/basic/src/iso/root/a.txt:
--------------------------------------------------------------------------------
1 | Hello
--------------------------------------------------------------------------------
/iso9660-ant-tasks/src/it/basic/src/iso/root/b.txt:
--------------------------------------------------------------------------------
1 | Goodbye
--------------------------------------------------------------------------------
/iso9660-ant-tasks/src/it/basic/verify.bsh:
--------------------------------------------------------------------------------
1 | import java.io.*;
2 | import org.codehaus.plexus.util.FileUtils;
3 |
4 | try
5 | {
6 | File buildDir = new File( basedir, "build" );
7 | File isoFile = new File( buildDir, "smoke-test.iso");
8 | if ( !isoFile.isFile()) {
9 | System.err.println( isoFile.getAbsolutePath() + " file was not created" );
10 | return false;
11 | }
12 | }
13 | catch( Throwable t )
14 | {
15 | t.printStackTrace();
16 | return false;
17 | }
18 |
19 | return true;
20 |
--------------------------------------------------------------------------------
/iso9660-ant-tasks/src/it/settings.xml:
--------------------------------------------------------------------------------
1 |
2 |
19 |
20 |
21 |
22 |
23 | *
24 | localRepository
25 | file:///@localRepository@
26 |
27 |
28 |
29 |
--------------------------------------------------------------------------------
/iso9660-ant-tasks/src/main/resources/com/github/stephenc/javaisotools/ant/antlib.xml:
--------------------------------------------------------------------------------
1 |
2 |
19 |
20 |
21 |
22 |
--------------------------------------------------------------------------------
/iso9660-maven-plugin/src/it/basic/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
19 |
20 |
22 | 4.0.0
23 |
24 | integration-test
25 | basic
26 | 1.2-SNAPSHOT
27 | ISO9660 Maven Plugin
28 | iso
29 |
30 |
31 |
32 |
33 |
34 | org.apache.maven.plugins
35 | maven-install-plugin
36 | 2.3.1
37 |
38 |
39 | org.apache.maven.plugins
40 | maven-resources-plugin
41 | 2.4.2
42 |
43 |
44 | org.apache.maven.plugins
45 | maven-deploy-plugin
46 | 2.8.2
47 |
48 |
49 |
50 |
51 |
52 | @project.groupId@
53 | @project.artifactId@
54 | @project.version@
55 | true
56 |
57 |
58 |
59 |
60 |
61 | Foobar Ltd
62 |
63 |
64 |
65 |
--------------------------------------------------------------------------------
/iso9660-maven-plugin/src/it/basic/src/main/resources/README.txt:
--------------------------------------------------------------------------------
1 | Some content
--------------------------------------------------------------------------------
/iso9660-maven-plugin/src/it/basic/verify.bsh:
--------------------------------------------------------------------------------
1 | import java.io.*;
2 | import org.codehaus.plexus.util.FileUtils;
3 |
4 | try
5 | {
6 | File buildDir = new File( basedir, "target" );
7 | File isoFile = new File( buildDir, "basic-1.2-SNAPSHOT.iso");
8 | if ( !isoFile.isFile()) {
9 | System.err.println( isoFile.getAbsolutePath() + " file was not created" );
10 | return false;
11 | }
12 | }
13 | catch( Throwable t )
14 | {
15 | t.printStackTrace();
16 | return false;
17 | }
18 |
19 | return true;
20 |
--------------------------------------------------------------------------------
/iso9660-maven-plugin/src/it/long/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
19 |
20 |
22 | 4.0.0
23 |
24 | integration-test
25 | long
26 | 1.2-SNAPSHOT
27 | ISO9660 Maven Plugin
28 | iso
29 |
30 |
31 |
32 |
33 |
34 | org.apache.maven.plugins
35 | maven-install-plugin
36 | 2.3.1
37 |
38 |
39 | org.apache.maven.plugins
40 | maven-resources-plugin
41 | 2.4.2
42 |
43 |
44 | org.apache.maven.plugins
45 | maven-deploy-plugin
46 | 2.8.2
47 |
48 |
49 |
50 |
51 |
52 | @project.groupId@
53 | @project.artifactId@
54 | @project.version@
55 | true
56 |
57 | Long Joliet
58 | Long Joliet
59 | false
60 | 110
61 |
62 |
63 |
64 |
65 |
66 |
67 | Foobar Ltd
68 |
69 |
70 |
71 |
--------------------------------------------------------------------------------
/iso9660-maven-plugin/src/it/long/src/main/resources/012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345.txt:
--------------------------------------------------------------------------------
1 | File with name 110 characters long
--------------------------------------------------------------------------------
/iso9660-maven-plugin/src/it/long/verify.bsh:
--------------------------------------------------------------------------------
1 | import java.io.*;
2 | import java.util.*;
3 | import org.codehaus.plexus.util.FileUtils;
4 | import com.github.stephenc.javaisotools.loopfs.iso9660.*;
5 |
6 | File buildDir = new File( basedir, "target" );
7 | File isoFile = new File( buildDir, "long-1.2-SNAPSHOT.iso");
8 |
9 | /* Check that the ISO is generated */
10 | try
11 | {
12 | if (!isoFile.isFile()) {
13 | System.err.println( isoFile.getAbsolutePath() + " file was not created" );
14 | return false;
15 | }
16 | }
17 | catch( Throwable t )
18 | {
19 | t.printStackTrace();
20 | return false;
21 | }
22 |
23 | /* Check that the ISO has the right files in it */
24 | Iso9660FileSystem fs = new Iso9660FileSystem(isoFile, true);
25 |
26 | Set files = new TreeSet();
27 |
28 | for (Iterator i = fs.iterator(); i.hasNext();)
29 | {
30 | Iso9660FileEntry e = (Iso9660FileEntry)i.next();
31 |
32 | files.add(e.getName());
33 | }
34 |
35 | if (!files.contains("012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345.txt"))
36 | {
37 | System.err.println("Could not find file with really long name");
38 |
39 | System.err.println("Found only " + files);
40 |
41 | return false;
42 | }
43 |
44 | return true;
45 |
--------------------------------------------------------------------------------
/iso9660-maven-plugin/src/it/settings.xml:
--------------------------------------------------------------------------------
1 |
2 |
19 |
20 |
21 |
22 |
23 | mrm-maven-plugin
24 | Mock Repository Manager
25 | @repository.proxy.url@
26 | *
27 |
28 |
29 |
30 |
31 | it-repo
32 |
33 | true
34 |
35 |
36 |
37 | snapshots
38 | @repository.proxy.url@
39 |
40 | true
41 | ignore
42 | never
43 |
44 |
45 | true
46 | ignore
47 | always
48 |
49 |
50 |
51 |
52 |
53 | snapshots
54 | @repository.proxy.url@
55 |
56 | true
57 | ignore
58 | never
59 |
60 |
61 | true
62 | ignore
63 | always
64 |
65 |
66 |
67 |
68 |
69 |
70 |
--------------------------------------------------------------------------------
/iso9660-maven-plugin/src/it/truncate/invoker.properties:
--------------------------------------------------------------------------------
1 | invoker.buildResult = failure
2 |
--------------------------------------------------------------------------------
/iso9660-maven-plugin/src/it/truncate/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
19 |
20 |
22 | 4.0.0
23 |
24 | integration-test
25 | truncate
26 | 1.2-SNAPSHOT
27 | ISO9660 Maven Plugin
28 | iso
29 |
30 |
31 |
32 |
33 |
34 | org.apache.maven.plugins
35 | maven-install-plugin
36 | 2.3.1
37 |
38 |
39 | org.apache.maven.plugins
40 | maven-resources-plugin
41 | 2.4.2
42 |
43 |
44 | org.apache.maven.plugins
45 | maven-deploy-plugin
46 | 2.8.2
47 |
48 |
49 |
50 |
51 |
52 | @project.groupId@
53 | @project.artifactId@
54 | @project.version@
55 | true
56 |
57 | Fail Joliet
58 | Fail Joliet
59 | false
60 | true
61 |
62 |
63 |
64 |
65 |
66 |
67 | Foobar Ltd
68 |
69 |
70 |
--------------------------------------------------------------------------------
/iso9660-maven-plugin/src/it/truncate/src/main/resources/012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345.txt:
--------------------------------------------------------------------------------
1 | File with name 110 characters long
--------------------------------------------------------------------------------
/iso9660-maven-plugin/src/it/truncate/verify.bsh:
--------------------------------------------------------------------------------
1 | return true;
2 |
--------------------------------------------------------------------------------
/iso9660-maven-plugin/src/main/java/com/github/stephenc/javaisotools/maven/ArchiveEntryDataReference.java:
--------------------------------------------------------------------------------
1 | package com.github.stephenc.javaisotools.maven;
2 |
3 | import java.io.IOException;
4 | import java.io.InputStream;
5 |
6 | import org.codehaus.plexus.archiver.ArchiveEntry;
7 |
8 | import com.github.stephenc.javaisotools.sabre.DataReference;
9 |
10 | public class ArchiveEntryDataReference implements DataReference {
11 |
12 | private final ArchiveEntry entry;
13 |
14 | public ArchiveEntryDataReference(ArchiveEntry entry) {
15 | this.entry = entry;
16 | }
17 |
18 | public long getLength() {
19 | return entry.getResource().getSize();
20 | }
21 |
22 | public InputStream createInputStream() throws IOException {
23 | return entry.getInputStream();
24 | }
25 |
26 | }
27 |
--------------------------------------------------------------------------------
/iso9660-maven-plugin/src/main/java/com/github/stephenc/javaisotools/maven/FilePermission.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2013 Brad BARCLAY.
3 | *
4 | * This library is free software; you can redistribute it and/or
5 | * modify it under the terms of the GNU Lesser General Public
6 | * License as published by the Free Software Foundation; either
7 | * version 2.1 of the License, or (at your option) any later version.
8 | *
9 | * This library is distributed in the hope that it will be useful,
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 | * Lesser General Public License for more details.
13 | *
14 | * You should have received a copy of the GNU Lesser General Public
15 | * License along with this library; if not, write to the Free Software
16 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
17 | */
18 |
19 | package com.github.stephenc.javaisotools.maven;
20 |
21 | /**
22 | *
23 | * @author yaztromo
24 | */
25 | public class FilePermission {
26 | public String filePattern;
27 | public String permission;
28 |
29 | public String getFilePattern() {
30 | return filePattern;
31 | }
32 |
33 | public void setFilePattern(String filePattern) {
34 | this.filePattern = filePattern;
35 | }
36 |
37 | public String getPermission() {
38 | return permission;
39 | }
40 |
41 | public void setPermission(String permission) {
42 | this.permission = permission;
43 | }
44 |
45 | public int getPermissionAsInt() throws NumberFormatException {
46 | return Integer.decode(permission);
47 | }
48 | }
49 |
--------------------------------------------------------------------------------
/iso9660-maven-plugin/src/main/java/com/github/stephenc/javaisotools/maven/Iso9660ArchiverException.java:
--------------------------------------------------------------------------------
1 | package com.github.stephenc.javaisotools.maven;
2 |
3 | import org.codehaus.plexus.archiver.ArchiverException;
4 |
5 | @SuppressWarnings("serial")
6 | public class Iso9660ArchiverException extends ArchiverException {
7 | private final Type type;
8 |
9 | public Iso9660ArchiverException(Type type, String message) {
10 | super(message);
11 | this.type = type;
12 | }
13 |
14 | Type getType() {
15 | return type;
16 | }
17 |
18 | public enum Type {
19 | MissingDestination, DestinationNotAFile, DestinationReadOnly, UnsupportedEntryType
20 | }
21 | }
22 |
--------------------------------------------------------------------------------
/iso9660-maven-plugin/src/main/resources/META-INF/plexus/components.xml:
--------------------------------------------------------------------------------
1 |
2 |
19 |
20 |
21 |
22 |
23 | org.apache.maven.lifecycle.mapping.LifecycleMapping
24 | iso
25 | org.apache.maven.lifecycle.mapping.DefaultLifecycleMapping
26 |
27 |
28 | org.apache.maven.plugins:maven-resources-plugin:resources
29 | com.github.stephenc.java-iso-tools:iso9660-maven-plugin:iso
30 | org.apache.maven.plugins:maven-install-plugin:install
31 | org.apache.maven.plugins:maven-deploy-plugin:deploy
32 |
33 |
34 |
35 |
36 | org.codehaus.plexus.archiver.Archiver
37 | iso
38 | com.github.stephenc.javaisotools.maven.Iso9660Archiver
39 |
40 | iso
41 | iso
42 |
43 | per-lookup
44 |
45 |
46 |
47 |
--------------------------------------------------------------------------------
/iso9660-maven-plugin/src/test/java/com/github/stephenc/javaisotools/maven/Iso9660ArchiverTest.java:
--------------------------------------------------------------------------------
1 | package com.github.stephenc.javaisotools.maven;
2 |
3 | import static org.junit.Assert.*;
4 |
5 | import java.io.IOException;
6 |
7 | import org.codehaus.plexus.archiver.ArchiverException;
8 | import org.junit.Test;
9 |
10 | public class Iso9660ArchiverTest {
11 |
12 | @Test
13 | public void mustHaveDestination() throws ArchiverException, IOException {
14 | try {
15 | new Iso9660Archiver().execute();
16 |
17 | fail("Should have noticed the destination was missing");
18 | } catch (Iso9660ArchiverException e) {
19 | assertEquals(Iso9660ArchiverException.Type.MissingDestination,
20 | e.getType());
21 | }
22 | }
23 |
24 | @Test
25 | public void testGetArchiveType() {
26 | assertEquals("iso9660", new Iso9660Archiver().getArchiveType());
27 | }
28 |
29 | }
30 |
--------------------------------------------------------------------------------
/iso9660-vfs-impl/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
19 |
20 |
21 | 4.0.0
22 |
23 |
24 | com.github.stephenc.java-iso-tools
25 | java-iso-tools-parent
26 | 2.1.1-SNAPSHOT
27 |
28 |
29 | iso9660-vfs-impl
30 | Iso9660 Commons VFS Implementation
31 | commons-vfs provider implementation for loop-fs.
32 |
33 |
34 |
35 | jdidion
36 | John Didion
37 | jdidion@loudeye.com
38 |
39 |
40 |
41 |
42 |
43 | commons-logging
44 | commons-logging
45 | 1.0.4
46 |
47 |
48 | commons-vfs
49 | commons-vfs
50 | 1.0
51 |
52 |
53 | com.github.stephenc.java-iso-tools
54 | loop-fs-iso-impl
55 | 2.1.1-SNAPSHOT
56 |
57 |
58 |
59 |
60 |
--------------------------------------------------------------------------------
/iso9660-vfs-impl/src/main/java/com/github/stephenc/javaisotools/vfs/provider/iso/IsoFileProvider.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2010. Stephen Connolly.
3 | * Copyright (c) 2006-2007. loopy project (http://loopy.sourceforge.net).
4 | *
5 | * This library is free software; you can redistribute it and/or
6 | * modify it under the terms of the GNU Lesser General Public
7 | * License as published by the Free Software Foundation; either
8 | * version 2.1 of the License, or (at your option) any later version.
9 | *
10 | * This library is distributed in the hope that it will be useful,
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 | * Lesser General Public License for more details.
14 | *
15 | * You should have received a copy of the GNU Lesser General Public
16 | * License along with this library; if not, write to the Free Software
17 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
18 | */
19 |
20 | package com.github.stephenc.javaisotools.vfs.provider.iso;
21 |
22 | import java.util.Arrays;
23 | import java.util.Collection;
24 |
25 | import org.apache.commons.vfs.Capability;
26 | import org.apache.commons.vfs.FileName;
27 | import org.apache.commons.vfs.FileObject;
28 | import org.apache.commons.vfs.FileSystem;
29 | import org.apache.commons.vfs.FileSystemException;
30 | import org.apache.commons.vfs.FileSystemOptions;
31 | import org.apache.commons.vfs.FileType;
32 | import org.apache.commons.vfs.provider.AbstractLayeredFileProvider;
33 | import org.apache.commons.vfs.provider.LayeredFileName;
34 |
35 | /**
36 | * Implementation of {@link org.apache.commons.vfs.provider.FileProvider} for ISO9660 (.iso) files. Currently, .iso
37 | * files are read-only.
38 | */
39 | public class IsoFileProvider extends AbstractLayeredFileProvider {
40 |
41 | public static final Collection capabilities = Arrays.asList(new Capability[]{
42 | Capability.GET_LAST_MODIFIED,
43 | Capability.GET_TYPE,
44 | Capability.LIST_CHILDREN,
45 | Capability.READ_CONTENT,
46 | Capability.URI,
47 | Capability.VIRTUAL
48 | });
49 |
50 | public Collection getCapabilities() {
51 | return IsoFileProvider.capabilities;
52 | }
53 |
54 | protected FileSystem doCreateFileSystem(final String scheme, final FileObject file,
55 | final FileSystemOptions fileSystemOptions)
56 | throws FileSystemException {
57 | final FileName rootName = new LayeredFileName(
58 | scheme, file.getName(), FileName.ROOT_PATH, FileType.FOLDER);
59 | return new IsoFileSystem(rootName, file, fileSystemOptions);
60 | }
61 | }
--------------------------------------------------------------------------------
/iso9660-vfs-impl/src/main/resources/META-INF/vfs-providers.xml:
--------------------------------------------------------------------------------
1 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
--------------------------------------------------------------------------------
/iso9660-writer/README.txt:
--------------------------------------------------------------------------------
1 | WHAT IT IS
2 | ==========
3 |
4 | These files and directories represent the test cases I used to do some
5 | performance tests with JIIC (Java ISO Image Creator) and mkisofs. The
6 | tests were made on Kubuntu 6.06.1 using kernel parameter
7 | ramdisk_size=524288 (512 MB ramdisk).
8 |
9 |
10 | PREREQUISITES
11 | =============
12 |
13 | To complete the test suite, get the following files from the respective
14 | web sites:
15 |
16 | tomsrtbt-2.0.103.ElTorito.288.img (for El Torito tests)
17 | http://www.toms.net/rb/download.html
18 |
19 | linux-2.6.20.tar.bz2 (use "ant linux-extract" to extract)
20 | http://kernel.org/pub/linux/kernel/v2.6/linux-2.6.20.tar.bz2
21 |
22 | eldream/ed_1024.avi (Elephants Dream)
23 | http://orange.blender.org/download
24 |
25 |
26 | FILES
27 | =====
28 |
29 | build.xml
30 | Ant build script with various test targets
31 |
32 | clear.sh
33 | Shell script that removes *.iso from ramdisk
34 |
35 | Copyright.txt
36 | Copyright information (test case setup; Tux image)
37 |
38 | iso9660.jar
39 | JIIC classes (the actual program)
40 |
41 | ISOtest.class
42 | ISOtest class (test program)
43 |
44 | makerd.sh
45 | Shell script to setup a ramdisk. Adapt user (jens) as needed.
46 |
47 | perf.sh
48 | Shell script for easy execution of tests.
49 | 1st parameter: program configuration to run
50 | 2nd parameter: file or directory to record
51 |
52 | run.sh
53 | Example performance test script. Adapt CONFIG, WHAT and calls as needed.
54 |
55 | sabre.jar
56 | SABRE classes (requirement for the actual program)
57 |
58 |
59 | ISOtest USAGE
60 | =============
61 |
62 | If run without parameters, ISOtest uses some default tests, including
63 | the test directory. If at least one parameter is specified, it is
64 | interpreted as the output filename. If more than one parameter is
65 | specified, the default tests are disabled and each additional parameter
66 | is interpreted as a file or directory to be recorded. The only
67 | exceptions are the strings --disable-eltorito, --disable-rockridge and
68 | --disable-joliet which disable one of the extensions, respectively.
--------------------------------------------------------------------------------
/iso9660-writer/clear.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 |
3 | rm -f /mnt/rd/*.iso
4 |
--------------------------------------------------------------------------------
/iso9660-writer/makerd.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 |
3 | sudo mke2fs -m 0 /dev/ram0
4 | sudo mkdir -p /mnt/rd
5 | sudo mount /dev/ram0 /mnt/rd
6 | sudo chown jens.jens /mnt/rd
7 | cd /mnt/rd
8 | ls -la
9 |
--------------------------------------------------------------------------------
/iso9660-writer/perf.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 |
3 | DEST=/mnt/rd
4 |
5 | case $1 in
6 | "mjr")
7 | time mkisofs -J -R -o $DEST/$2-mkisofs.iso $2 2>/dev/null ;;
8 | "mr")
9 | time mkisofs -R -o $DEST/$2-mkisofs.iso $2 2>/dev/null ;;
10 | "mj")
11 | time mkisofs -J -o $DEST/$2-mkisofs.iso $2 2>/dev/null ;;
12 | "m")
13 | time mkisofs -o $DEST/$2-mkisofs.iso $2 2>/dev/null ;;
14 | "ijr")
15 | time java -cp sabre.jar:iso9660.jar:. ISOtest $DEST/$2.iso --disable-eltorito $2 2>/dev/null ;;
16 | "ir")
17 | time java -cp sabre.jar:iso9660.jar:. ISOtest $DEST/$2.iso --disable-eltorito --disable-joliet $2 2>/dev/null ;;
18 | "ij")
19 | time java -cp sabre.jar:iso9660.jar:. ISOtest $DEST/$2.iso --disable-eltorito --disable-rockridge $2 2>/dev/null ;;
20 | "i")
21 | time java -cp sabre.jar:iso9660.jar:. ISOtest $DEST/$2.iso --disable-eltorito --disable-rockridge --disable-joliet $2 2>/dev/null ;;
22 | *)
23 | echo "Usage: $0 mjr|mr|mj|m|ijr|ir|ij|i "
24 | echo "Example: $0 mjr eldream -> mkisofs; Joliet, Rock Ridge; eldream"
25 | ;;
26 | esac
27 |
--------------------------------------------------------------------------------
/iso9660-writer/perf.txt:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/stephenc/java-iso-tools/334caa435f58ebaa8a5f69eefc2e5ac247c0d6c2/iso9660-writer/perf.txt
--------------------------------------------------------------------------------
/iso9660-writer/run.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 |
3 | ./makerd.sh
4 |
5 | function perf {
6 | ./clear.sh
7 | ./perf.sh $CONFIG $WHAT
8 | read
9 | }
10 |
11 | export CONFIG=ijr
12 | export WHAT=minimal
13 |
14 | perf
15 |
16 | perf
17 | perf
18 | perf
19 | perf
20 | perf
21 |
--------------------------------------------------------------------------------
/iso9660-writer/src/main/java/com/github/stephenc/javaisotools/eltorito/impl/ElToritoLayoutHelper.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2010. Stephen Connolly.
3 | * Copyright (C) 2007. Jens Hatlak
4 | *
5 | * This library is free software; you can redistribute it and/or
6 | * modify it under the terms of the GNU Lesser General Public
7 | * License as published by the Free Software Foundation; either
8 | * version 2.1 of the License, or (at your option) any later version.
9 | *
10 | * This library is distributed in the hope that it will be useful,
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 | * Lesser General Public License for more details.
14 | *
15 | * You should have received a copy of the GNU Lesser General Public
16 | * License along with this library; if not, write to the Free Software
17 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
18 | */
19 |
20 | package com.github.stephenc.javaisotools.eltorito.impl;
21 |
22 | import java.io.UnsupportedEncodingException;
23 |
24 | import com.github.stephenc.javaisotools.iso9660.FilenameDataReference;
25 | import com.github.stephenc.javaisotools.iso9660.LayoutHelper;
26 | import com.github.stephenc.javaisotools.sabre.HandlerException;
27 | import com.github.stephenc.javaisotools.sabre.StreamHandler;
28 | import com.github.stephenc.javaisotools.iso9660.ISO9660Directory;
29 | import com.github.stephenc.javaisotools.iso9660.ISO9660File;
30 |
31 | public class ElToritoLayoutHelper extends LayoutHelper {
32 |
33 | public ElToritoLayoutHelper(StreamHandler streamHandler) {
34 | super(streamHandler, null, null);
35 | }
36 |
37 | public FilenameDataReference getFilenameDataReference(ISO9660Directory dir)
38 | throws HandlerException {
39 | return null;
40 | }
41 |
42 | public FilenameDataReference getFilenameDataReference(ISO9660File file)
43 | throws HandlerException {
44 | return null;
45 | }
46 |
47 | public byte[] pad(String string, int targetByteLength) throws HandlerException {
48 | byte[] bytes = new byte[targetByteLength];
49 | byte[] original;
50 |
51 | try {
52 | original = string.getBytes("ISO-8859-1"); // ISO Latin 1
53 | for (int i = 0; i < original.length; i++) {
54 | bytes[i] = original[i];
55 | }
56 | for (int i = original.length; i < bytes.length; i++) {
57 | bytes[i] = 0;
58 | }
59 | } catch (UnsupportedEncodingException e) {
60 | e.printStackTrace();
61 | }
62 |
63 | return bytes;
64 | }
65 | }
66 |
--------------------------------------------------------------------------------
/iso9660-writer/src/main/java/com/github/stephenc/javaisotools/iso9660/BootConfig.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2010. Stephen Connolly.
3 | * Copyright (C) 2007. Jens Hatlak
4 | *
5 | * This library is free software; you can redistribute it and/or
6 | * modify it under the terms of the GNU Lesser General Public
7 | * License as published by the Free Software Foundation; either
8 | * version 2.1 of the License, or (at your option) any later version.
9 | *
10 | * This library is distributed in the hope that it will be useful,
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 | * Lesser General Public License for more details.
14 | *
15 | * You should have received a copy of the GNU Lesser General Public
16 | * License along with this library; if not, write to the Free Software
17 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
18 | */
19 |
20 | package com.github.stephenc.javaisotools.iso9660;
21 |
22 | public abstract class BootConfig {
23 |
24 | private String bootSystemId, bootId;
25 |
26 | public BootConfig(String bootSystemId, String bootId) {
27 | this.bootSystemId = bootSystemId;
28 | this.bootId = bootId;
29 | }
30 |
31 | public BootConfig() {
32 | this("", "");
33 | }
34 |
35 | /**
36 | * Boot System Identifier
37 | *
38 | * @param bootSystemId Identifier for the system that can act upon the Boot System Use field
39 | */
40 | public void setBootSystemId(String bootSystemId) {
41 | this.bootSystemId = bootSystemId;
42 | }
43 |
44 | /**
45 | * Active Boot System Identifier
46 | *
47 | * @return Active Boot System identifier
48 | */
49 | public String getBootSystemId() {
50 | return bootSystemId;
51 | }
52 |
53 | /**
54 | * Boot Identifier
55 | *
56 | * @param bootId Boot identifier
57 | */
58 | public void setBootId(String bootId) {
59 | this.bootId = bootId;
60 | }
61 |
62 | /**
63 | * Active Boot Identifier
64 | *
65 | * @return Active Boot identifier
66 | */
67 | public String getBootId() {
68 | return bootId;
69 | }
70 | }
71 |
--------------------------------------------------------------------------------
/iso9660-writer/src/main/java/com/github/stephenc/javaisotools/iso9660/ConfigException.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2010. Stephen Connolly.
3 | * Copyright (C) 2007. Jens Hatlak
4 | *
5 | * This library is free software; you can redistribute it and/or
6 | * modify it under the terms of the GNU Lesser General Public
7 | * License as published by the Free Software Foundation; either
8 | * version 2.1 of the License, or (at your option) any later version.
9 | *
10 | * This library is distributed in the hope that it will be useful,
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 | * Lesser General Public License for more details.
14 | *
15 | * You should have received a copy of the GNU Lesser General Public
16 | * License along with this library; if not, write to the Free Software
17 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
18 | */
19 |
20 | package com.github.stephenc.javaisotools.iso9660;
21 |
22 | public class ConfigException extends Exception {
23 |
24 | private static final long serialVersionUID = -6845620304573548666L;
25 |
26 | public ConfigException(Object config, String string) {
27 | super(config.getClass().getName() + ": " + string);
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/iso9660-writer/src/main/java/com/github/stephenc/javaisotools/iso9660/FilenameDataReference.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2010. Stephen Connolly.
3 | * Copyright (C) 2007. Jens Hatlak
4 | *
5 | * This library is free software; you can redistribute it and/or
6 | * modify it under the terms of the GNU Lesser General Public
7 | * License as published by the Free Software Foundation; either
8 | * version 2.1 of the License, or (at your option) any later version.
9 | *
10 | * This library is distributed in the hope that it will be useful,
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 | * Lesser General Public License for more details.
14 | *
15 | * You should have received a copy of the GNU Lesser General Public
16 | * License along with this library; if not, write to the Free Software
17 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
18 | */
19 |
20 | package com.github.stephenc.javaisotools.iso9660;
21 |
22 | import java.io.IOException;
23 | import java.io.InputStream;
24 |
25 | import com.github.stephenc.javaisotools.sabre.DataReference;
26 | import com.github.stephenc.javaisotools.sabre.HandlerException;
27 |
28 | public abstract class FilenameDataReference implements DataReference {
29 |
30 | private String name;
31 |
32 | public FilenameDataReference(ISO9660Directory dir) throws HandlerException {
33 | setName(dir.getName());
34 | }
35 |
36 | public FilenameDataReference(ISO9660File file) throws HandlerException {
37 | setName(file.getFullName());
38 | }
39 |
40 | public FilenameDataReference(String name) {
41 | setName(name);
42 | }
43 |
44 | public void setName(String name) {
45 | this.name = name;
46 | }
47 |
48 | public String getName() {
49 | return name;
50 | }
51 |
52 | public abstract long getLength();
53 |
54 | public abstract InputStream createInputStream() throws IOException;
55 | }
56 |
--------------------------------------------------------------------------------
/iso9660-writer/src/main/java/com/github/stephenc/javaisotools/iso9660/ISO9660HierarchyObject.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2010. Stephen Connolly.
3 | * Copyright (C) 2007. Jens Hatlak
4 | *
5 | * This library is free software; you can redistribute it and/or
6 | * modify it under the terms of the GNU Lesser General Public
7 | * License as published by the Free Software Foundation; either
8 | * version 2.1 of the License, or (at your option) any later version.
9 | *
10 | * This library is distributed in the hope that it will be useful,
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 | * Lesser General Public License for more details.
14 | *
15 | * You should have received a copy of the GNU Lesser General Public
16 | * License along with this library; if not, write to the Free Software
17 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
18 | */
19 |
20 | package com.github.stephenc.javaisotools.iso9660;
21 |
22 | public interface ISO9660HierarchyObject extends Cloneable, Comparable {
23 |
24 | /**
25 | * Returns the name of the hierarchy object
26 | *
27 | * @return Name
28 | */
29 | public String getName();
30 |
31 | /**
32 | * Returns the root of the directory hierarchy
33 | *
34 | * @return Root
35 | */
36 | public ISO9660RootDirectory getRoot();
37 |
38 | /**
39 | * Returns whether the hierarchy object is a directory
40 | *
41 | * @return Whether this is a directory
42 | */
43 | public boolean isDirectory();
44 |
45 | /**
46 | * Set the name of the hierarchy object
47 | *
48 | * @param name Name
49 | */
50 | public void setName(String name);
51 |
52 | /**
53 | * Returns the parent directory of this hierarchy object
54 | *
55 | * @return Parent directory
56 | */
57 | public ISO9660Directory getParentDirectory();
58 |
59 | /**
60 | * Returns the path from the root to this hierarchy object with each path component separated by File.separator so
61 | * that its length represents the ISO 9660 path length
62 | *
63 | * @return Path
64 | */
65 | public String getISOPath();
66 |
67 | /**
68 | * Returns an Object identifying this hierarchy object
69 | *
70 | * @return Identifying Object
71 | */
72 | public Object getID();
73 | }
74 |
--------------------------------------------------------------------------------
/iso9660-writer/src/main/java/com/github/stephenc/javaisotools/iso9660/ISOFileSet.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2010. Stephen Connolly.
3 | * Copyright (C) 2007. Jens Hatlak
4 | *
5 | * This library is free software; you can redistribute it and/or
6 | * modify it under the terms of the GNU Lesser General Public
7 | * License as published by the Free Software Foundation; either
8 | * version 2.1 of the License, or (at your option) any later version.
9 | *
10 | * This library is distributed in the hope that it will be useful,
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 | * Lesser General Public License for more details.
14 | *
15 | * You should have received a copy of the GNU Lesser General Public
16 | * License along with this library; if not, write to the Free Software
17 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
18 | */
19 |
20 | package com.github.stephenc.javaisotools.iso9660;
21 |
22 | import org.apache.tools.ant.types.FileSet;
23 |
24 | public class ISOFileSet extends FileSet {
25 |
26 | private String prefix = "";
27 |
28 | public void setPrefix(String prefix) {
29 | this.prefix = prefix;
30 | }
31 |
32 | public String getPrefix() {
33 | return prefix;
34 | }
35 | }
36 |
--------------------------------------------------------------------------------
/iso9660-writer/src/main/java/com/github/stephenc/javaisotools/iso9660/LayoutHelper.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2010. Stephen Connolly.
3 | * Copyright (C) 2007. Jens Hatlak
4 | *
5 | * This library is free software; you can redistribute it and/or
6 | * modify it under the terms of the GNU Lesser General Public
7 | * License as published by the Free Software Foundation; either
8 | * version 2.1 of the License, or (at your option) any later version.
9 | *
10 | * This library is distributed in the hope that it will be useful,
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 | * Lesser General Public License for more details.
14 | *
15 | * You should have received a copy of the GNU Lesser General Public
16 | * License along with this library; if not, write to the Free Software
17 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
18 | */
19 |
20 | package com.github.stephenc.javaisotools.iso9660;
21 |
22 | import com.github.stephenc.javaisotools.iso9660.impl.ISO9660Constants;
23 | import com.github.stephenc.javaisotools.sabre.HandlerException;
24 | import com.github.stephenc.javaisotools.sabre.StreamHandler;
25 |
26 | public abstract class LayoutHelper {
27 |
28 | private StreamHandler streamHandler;
29 | private ISO9660RootDirectory root;
30 | private NamingConventions namingConventions;
31 |
32 | public LayoutHelper(StreamHandler streamHandler, ISO9660RootDirectory root, NamingConventions namingConventions) {
33 | this.streamHandler = streamHandler;
34 | this.root = root;
35 | this.namingConventions = namingConventions;
36 | }
37 |
38 | public ISO9660RootDirectory getRoot() {
39 | return root;
40 | }
41 |
42 | public int getCurrentLocation() throws HandlerException {
43 | long position = streamHandler.mark();
44 | int location = (int) (position / ISO9660Constants.LOGICAL_BLOCK_SIZE);
45 | return location;
46 | }
47 |
48 | public int getDifferenceTo(long position) throws HandlerException {
49 | return (int) ((streamHandler.mark() - position));
50 | }
51 |
52 | public NamingConventions getNamingConventions() {
53 | return namingConventions;
54 | }
55 |
56 | public abstract FilenameDataReference getFilenameDataReference(ISO9660Directory dir) throws HandlerException;
57 |
58 | public abstract FilenameDataReference getFilenameDataReference(ISO9660File file) throws HandlerException;
59 |
60 | public abstract byte[] pad(String string, int targetByteLength) throws HandlerException;
61 | }
62 |
--------------------------------------------------------------------------------
/iso9660-writer/src/main/java/com/github/stephenc/javaisotools/iso9660/PartitionConfig.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2010. Stephen Connolly.
3 | * Copyright (C) 2007. Jens Hatlak
4 | *
5 | * This library is free software; you can redistribute it and/or
6 | * modify it under the terms of the GNU Lesser General Public
7 | * License as published by the Free Software Foundation; either
8 | * version 2.1 of the License, or (at your option) any later version.
9 | *
10 | * This library is distributed in the hope that it will be useful,
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 | * Lesser General Public License for more details.
14 | *
15 | * You should have received a copy of the GNU Lesser General Public
16 | * License along with this library; if not, write to the Free Software
17 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
18 | */
19 |
20 | package com.github.stephenc.javaisotools.iso9660;
21 |
22 | public class PartitionConfig {
23 |
24 | private String systemId, volumePartitionId;
25 |
26 | public PartitionConfig(String bootSystemId, String volumePartitionId) {
27 | this.systemId = bootSystemId;
28 | this.volumePartitionId = volumePartitionId;
29 | }
30 |
31 | public PartitionConfig() {
32 | this("", "");
33 | }
34 |
35 | /**
36 | * System Identifier
37 | *
38 | * @param systemId System identifier string
39 | */
40 | public void setSystemId(String systemId) {
41 | this.systemId = systemId;
42 | }
43 |
44 | /**
45 | * Active System Identifier
46 | *
47 | * @return System identifier string
48 | */
49 | public String getSystemId() {
50 | return systemId;
51 | }
52 |
53 | /**
54 | * Volume Partition Identifier
55 | *
56 | * @param volumePartitionId Active Volume Partition identifier string
57 | */
58 | public void setVolumePartitionId(String volumePartitionId) {
59 | this.volumePartitionId = volumePartitionId;
60 | }
61 |
62 | /**
63 | * Active Volume Partition Identifier
64 | *
65 | * @return Active Volume Partition identifier string
66 | */
67 | public String getVolumePartitionId() {
68 | return volumePartitionId;
69 | }
70 | }
71 |
--------------------------------------------------------------------------------
/iso9660-writer/src/main/java/com/github/stephenc/javaisotools/iso9660/StandardHandler.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2010. Stephen Connolly.
3 | * Copyright (C) 2007. Jens Hatlak
4 | *
5 | * This library is free software; you can redistribute it and/or
6 | * modify it under the terms of the GNU Lesser General Public
7 | * License as published by the Free Software Foundation; either
8 | * version 2.1 of the License, or (at your option) any later version.
9 | *
10 | * This library is distributed in the hope that it will be useful,
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 | * Lesser General Public License for more details.
14 | *
15 | * You should have received a copy of the GNU Lesser General Public
16 | * License along with this library; if not, write to the Free Software
17 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
18 | */
19 |
20 | package com.github.stephenc.javaisotools.iso9660;
21 |
22 | import java.util.Iterator;
23 |
24 | import com.github.stephenc.javaisotools.sabre.HandlerException;
25 | import com.github.stephenc.javaisotools.sabre.StreamHandler;
26 | import com.github.stephenc.javaisotools.sabre.impl.ChainingStreamHandler;
27 |
28 | public class StandardHandler extends ChainingStreamHandler {
29 |
30 | private ISO9660Directory root;
31 | private StandardConfig config;
32 |
33 | public StandardHandler(StreamHandler streamHandler, ISO9660Directory root, StandardConfig config) {
34 | super(streamHandler, streamHandler);
35 | this.root = root;
36 | this.config = config;
37 | }
38 |
39 | public void checkMetadataFiles() throws HandlerException {
40 | // Add files to Root Directory (if not already present)
41 | for (ISO9660File file : config.getFiles()) {
42 | // Metadata Files must conform to 8+3 naming scheme
43 | if (file != null && !root.getFiles().contains(file)) {
44 | file.enforce8plus3(true);
45 | root.addFile(file);
46 | }
47 | }
48 | }
49 | }
50 |
--------------------------------------------------------------------------------
/iso9660-writer/src/main/java/com/github/stephenc/javaisotools/iso9660/impl/FileElement.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2010. Stephen Connolly.
3 | * Copyright (C) 2007. Jens Hatlak
4 | *
5 | * This library is free software; you can redistribute it and/or
6 | * modify it under the terms of the GNU Lesser General Public
7 | * License as published by the Free Software Foundation; either
8 | * version 2.1 of the License, or (at your option) any later version.
9 | *
10 | * This library is distributed in the hope that it will be useful,
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 | * Lesser General Public License for more details.
14 | *
15 | * You should have received a copy of the GNU Lesser General Public
16 | * License along with this library; if not, write to the Free Software
17 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
18 | */
19 |
20 | package com.github.stephenc.javaisotools.iso9660.impl;
21 |
22 | import com.github.stephenc.javaisotools.iso9660.ISO9660File;
23 |
24 | public class FileElement extends LogicalSectorElement {
25 |
26 | private ISO9660File file;
27 |
28 | public FileElement(ISO9660File file) {
29 | super("FILE");
30 | this.file = file;
31 | }
32 |
33 | public ISO9660File getFile() {
34 | return file;
35 | }
36 | }
37 |
--------------------------------------------------------------------------------
/iso9660-writer/src/main/java/com/github/stephenc/javaisotools/iso9660/impl/FileHandler.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2010. Stephen Connolly.
3 | * Copyright (C) 2007. Jens Hatlak
4 | *
5 | * This library is free software; you can redistribute it and/or
6 | * modify it under the terms of the GNU Lesser General Public
7 | * License as published by the Free Software Foundation; either
8 | * version 2.1 of the License, or (at your option) any later version.
9 | *
10 | * This library is distributed in the hope that it will be useful,
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 | * Lesser General Public License for more details.
14 | *
15 | * You should have received a copy of the GNU Lesser General Public
16 | * License along with this library; if not, write to the Free Software
17 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
18 | */
19 |
20 | package com.github.stephenc.javaisotools.iso9660.impl;
21 |
22 | import java.util.Iterator;
23 | import java.util.List;
24 | import java.util.Vector;
25 |
26 | import com.github.stephenc.javaisotools.iso9660.ISO9660Directory;
27 | import com.github.stephenc.javaisotools.iso9660.ISO9660File;
28 | import com.github.stephenc.javaisotools.iso9660.ISO9660RootDirectory;
29 | import com.github.stephenc.javaisotools.sabre.HandlerException;
30 | import com.github.stephenc.javaisotools.sabre.StreamHandler;
31 | import com.github.stephenc.javaisotools.sabre.impl.FileDataReference;
32 | import com.github.stephenc.javaisotools.sabre.Element;
33 | import com.github.stephenc.javaisotools.sabre.impl.ChainingStreamHandler;
34 |
35 | public class FileHandler extends ChainingStreamHandler {
36 |
37 | private ISO9660RootDirectory root;
38 |
39 | public FileHandler(StreamHandler streamHandler, ISO9660RootDirectory root) {
40 | super(streamHandler, streamHandler);
41 | this.root = root;
42 | }
43 |
44 | public void startElement(Element element) throws HandlerException {
45 | if (element instanceof ISO9660Element) {
46 | String id = (String) element.getId();
47 | process(id);
48 | }
49 | super.startElement(element);
50 | }
51 |
52 | private void process(String id) throws HandlerException {
53 | if (id.equals("FCA")) {
54 | doFCA();
55 | }
56 | }
57 |
58 | private void doFCA() throws HandlerException {
59 | doFCADirs(root);
60 |
61 | Iterator it = root.sortedIterator();
62 | while (it.hasNext()) {
63 | ISO9660Directory dir = it.next();
64 | doFCADirs(dir);
65 | }
66 | }
67 |
68 | private void doFCADirs(ISO9660Directory dir) throws HandlerException {
69 | for (ISO9660File file : dir.getFiles()) {
70 | doFile(file);
71 | }
72 | }
73 |
74 | private void doFile(ISO9660File file) throws HandlerException {
75 | super.startElement(new FileElement(file));
76 |
77 | data(file.getDataReference());
78 |
79 | super.endElement();
80 | }
81 | }
82 |
--------------------------------------------------------------------------------
/iso9660-writer/src/main/java/com/github/stephenc/javaisotools/iso9660/impl/ISO9660Element.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2010. Stephen Connolly.
3 | * Copyright (C) 2007. Jens Hatlak
4 | *
5 | * This library is free software; you can redistribute it and/or
6 | * modify it under the terms of the GNU Lesser General Public
7 | * License as published by the Free Software Foundation; either
8 | * version 2.1 of the License, or (at your option) any later version.
9 | *
10 | * This library is distributed in the hope that it will be useful,
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 | * Lesser General Public License for more details.
14 | *
15 | * You should have received a copy of the GNU Lesser General Public
16 | * License along with this library; if not, write to the Free Software
17 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
18 | */
19 |
20 | package com.github.stephenc.javaisotools.iso9660.impl;
21 |
22 | import com.github.stephenc.javaisotools.sabre.Element;
23 |
24 | public class ISO9660Element extends Element {
25 |
26 | /* Examples:
27 | * VDS, PTA, DRA, FCA
28 | */
29 | private String id;
30 |
31 | public ISO9660Element(String id) {
32 | this.id = id;
33 | }
34 |
35 | public Object getId() {
36 | return id;
37 | }
38 | }
39 |
--------------------------------------------------------------------------------
/iso9660-writer/src/main/java/com/github/stephenc/javaisotools/iso9660/impl/ISO9660FilenameDataReference.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2010. Stephen Connolly.
3 | * Copyright (C) 2007. Jens Hatlak
4 | *
5 | * This library is free software; you can redistribute it and/or
6 | * modify it under the terms of the GNU Lesser General Public
7 | * License as published by the Free Software Foundation; either
8 | * version 2.1 of the License, or (at your option) any later version.
9 | *
10 | * This library is distributed in the hope that it will be useful,
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 | * Lesser General Public License for more details.
14 | *
15 | * You should have received a copy of the GNU Lesser General Public
16 | * License along with this library; if not, write to the Free Software
17 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
18 | */
19 |
20 | package com.github.stephenc.javaisotools.iso9660.impl;
21 |
22 | import java.io.ByteArrayInputStream;
23 | import java.io.IOException;
24 | import java.io.InputStream;
25 |
26 | import com.github.stephenc.javaisotools.iso9660.FilenameDataReference;
27 | import com.github.stephenc.javaisotools.iso9660.ISO9660File;
28 | import com.github.stephenc.javaisotools.iso9660.ISO9660Directory;
29 | import com.github.stephenc.javaisotools.sabre.HandlerException;
30 |
31 | public class ISO9660FilenameDataReference extends FilenameDataReference {
32 |
33 | public ISO9660FilenameDataReference(ISO9660Directory dir) throws HandlerException {
34 | super(dir);
35 | }
36 |
37 | public ISO9660FilenameDataReference(ISO9660File file) throws HandlerException {
38 | super(file);
39 | }
40 |
41 | public long getLength() {
42 | return getName().length();
43 | }
44 |
45 | public InputStream createInputStream() throws IOException {
46 | return new ByteArrayInputStream(getName().getBytes("ISO-8859-1"));
47 | }
48 | }
49 |
--------------------------------------------------------------------------------
/iso9660-writer/src/main/java/com/github/stephenc/javaisotools/iso9660/impl/ISO9660LayoutHelper.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2010. Stephen Connolly.
3 | * Copyright (C) 2007. Jens Hatlak
4 | *
5 | * This library is free software; you can redistribute it and/or
6 | * modify it under the terms of the GNU Lesser General Public
7 | * License as published by the Free Software Foundation; either
8 | * version 2.1 of the License, or (at your option) any later version.
9 | *
10 | * This library is distributed in the hope that it will be useful,
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 | * Lesser General Public License for more details.
14 | *
15 | * You should have received a copy of the GNU Lesser General Public
16 | * License along with this library; if not, write to the Free Software
17 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
18 | */
19 |
20 | package com.github.stephenc.javaisotools.iso9660.impl;
21 |
22 | import java.io.UnsupportedEncodingException;
23 |
24 | import com.github.stephenc.javaisotools.iso9660.FilenameDataReference;
25 | import com.github.stephenc.javaisotools.iso9660.ISO9660Directory;
26 | import com.github.stephenc.javaisotools.iso9660.ISO9660File;
27 | import com.github.stephenc.javaisotools.iso9660.LayoutHelper;
28 | import com.github.stephenc.javaisotools.sabre.HandlerException;
29 | import com.github.stephenc.javaisotools.iso9660.ISO9660RootDirectory;
30 | import com.github.stephenc.javaisotools.sabre.StreamHandler;
31 |
32 | public class ISO9660LayoutHelper extends LayoutHelper {
33 |
34 | public ISO9660LayoutHelper(StreamHandler streamHandler, ISO9660RootDirectory root) {
35 | super(streamHandler, root, new ISO9660NamingConventions());
36 | }
37 |
38 | public FilenameDataReference getFilenameDataReference(ISO9660Directory dir) throws HandlerException {
39 | return new ISO9660FilenameDataReference(dir);
40 | }
41 |
42 | public FilenameDataReference getFilenameDataReference(ISO9660File file) throws HandlerException {
43 | return new ISO9660FilenameDataReference(file);
44 | }
45 |
46 | public byte[] pad(String string, int targetByteLength) throws HandlerException {
47 | byte[] bytes = new byte[targetByteLength];
48 | byte[] original = null;
49 | int length = 0;
50 |
51 | try {
52 | if (string != null) {
53 | original = string.getBytes("ISO-8859-1"); // ISO Latin 1
54 | length = original.length;
55 | }
56 | for (int i = 0; i < length; i++) {
57 | bytes[i] = original[i];
58 | }
59 | for (int i = length; i < bytes.length; i++) {
60 | bytes[i] = 0x20;
61 | }
62 | } catch (UnsupportedEncodingException e) {
63 | e.printStackTrace();
64 | }
65 |
66 | return bytes;
67 | }
68 | }
69 |
--------------------------------------------------------------------------------
/iso9660-writer/src/main/java/com/github/stephenc/javaisotools/iso9660/impl/LogicalSectorElement.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2010. Stephen Connolly.
3 | * Copyright (C) 2007. Jens Hatlak
4 | *
5 | * This library is free software; you can redistribute it and/or
6 | * modify it under the terms of the GNU Lesser General Public
7 | * License as published by the Free Software Foundation; either
8 | * version 2.1 of the License, or (at your option) any later version.
9 | *
10 | * This library is distributed in the hope that it will be useful,
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 | * Lesser General Public License for more details.
14 | *
15 | * You should have received a copy of the GNU Lesser General Public
16 | * License along with this library; if not, write to the Free Software
17 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
18 | */
19 |
20 | package com.github.stephenc.javaisotools.iso9660.impl;
21 |
22 | import com.github.stephenc.javaisotools.sabre.Element;
23 |
24 | public class LogicalSectorElement extends Element {
25 |
26 | /* Examples:
27 | * BR, PVD, SVD, VPD, VDST,
28 | * PT, DR, CA,
29 | * CATALOG, IMAGE
30 | */
31 | private String id;
32 |
33 | public LogicalSectorElement(String id) {
34 | this.id = id;
35 | }
36 |
37 | public Object getId() {
38 | return id;
39 | }
40 | }
41 |
--------------------------------------------------------------------------------
/iso9660-writer/src/main/java/com/github/stephenc/javaisotools/iso9660/sabre/impl/BothShortDataReference.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2010. Stephen Connolly.
3 | * Copyright (C) 2007. Jens Hatlak
4 | *
5 | * This library is free software; you can redistribute it and/or
6 | * modify it under the terms of the GNU Lesser General Public
7 | * License as published by the Free Software Foundation; either
8 | * version 2.1 of the License, or (at your option) any later version.
9 | *
10 | * This library is distributed in the hope that it will be useful,
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 | * Lesser General Public License for more details.
14 | *
15 | * You should have received a copy of the GNU Lesser General Public
16 | * License along with this library; if not, write to the Free Software
17 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
18 | */
19 |
20 | package com.github.stephenc.javaisotools.iso9660.sabre.impl;
21 |
22 | import java.io.ByteArrayInputStream;
23 | import java.io.IOException;
24 | import java.io.InputStream;
25 |
26 | import com.github.stephenc.javaisotools.sabre.DataReference;
27 |
28 | public class BothShortDataReference implements DataReference {
29 |
30 | private long value = 0;
31 |
32 | public BothShortDataReference(long value) {
33 | this.value = value;
34 | }
35 |
36 | public long getLength() {
37 | return 4;
38 | }
39 |
40 | public InputStream createInputStream() throws IOException {
41 | byte[] buffer = new byte[4];
42 |
43 | // MSB first (Big Endian)
44 | buffer[2] = (byte) ((this.value & 0xFF00) >> 8);
45 | buffer[3] = (byte) (this.value & 0x00FF);
46 |
47 | // LSB first (Little Endian)
48 | buffer[1] = buffer[2];
49 | buffer[0] = buffer[3];
50 |
51 | return new ByteArrayInputStream(buffer);
52 | }
53 |
54 | }
55 |
--------------------------------------------------------------------------------
/iso9660-writer/src/main/java/com/github/stephenc/javaisotools/iso9660/sabre/impl/BothWordDataReference.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2010. Stephen Connolly.
3 | * Copyright (C) 2007. Jens Hatlak
4 | *
5 | * This library is free software; you can redistribute it and/or
6 | * modify it under the terms of the GNU Lesser General Public
7 | * License as published by the Free Software Foundation; either
8 | * version 2.1 of the License, or (at your option) any later version.
9 | *
10 | * This library is distributed in the hope that it will be useful,
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 | * Lesser General Public License for more details.
14 | *
15 | * You should have received a copy of the GNU Lesser General Public
16 | * License along with this library; if not, write to the Free Software
17 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
18 | */
19 |
20 | package com.github.stephenc.javaisotools.iso9660.sabre.impl;
21 |
22 | import java.io.ByteArrayInputStream;
23 | import java.io.IOException;
24 | import java.io.InputStream;
25 |
26 | import com.github.stephenc.javaisotools.sabre.DataReference;
27 |
28 | public class BothWordDataReference implements DataReference {
29 |
30 | private long value = 0;
31 |
32 | public BothWordDataReference(long value) {
33 | this.value = value;
34 | }
35 |
36 | public long getLength() {
37 | return 8;
38 | }
39 |
40 | public InputStream createInputStream() throws IOException {
41 | byte[] buffer = new byte[8];
42 |
43 | // MSB first (Big Endian)
44 | buffer[4] = (byte) ((this.value & 0xFF000000) >> 24);
45 | buffer[5] = (byte) ((this.value & 0x00FF0000) >> 16);
46 | buffer[6] = (byte) ((this.value & 0x0000FF00) >> 8);
47 | buffer[7] = (byte) (this.value & 0x000000FF);
48 |
49 | // LSB first (Little Endian)
50 | buffer[3] = buffer[4];
51 | buffer[2] = buffer[5];
52 | buffer[1] = buffer[6];
53 | buffer[0] = buffer[7];
54 |
55 | return new ByteArrayInputStream(buffer);
56 | }
57 | }
58 |
--------------------------------------------------------------------------------
/iso9660-writer/src/main/java/com/github/stephenc/javaisotools/iso9660/sabre/impl/EmptyByteArrayDataReference.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2010. Stephen Connolly.
3 | * Copyright (C) 2007. Jens Hatlak
4 | *
5 | * This library is free software; you can redistribute it and/or
6 | * modify it under the terms of the GNU Lesser General Public
7 | * License as published by the Free Software Foundation; either
8 | * version 2.1 of the License, or (at your option) any later version.
9 | *
10 | * This library is distributed in the hope that it will be useful,
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 | * Lesser General Public License for more details.
14 | *
15 | * You should have received a copy of the GNU Lesser General Public
16 | * License along with this library; if not, write to the Free Software
17 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
18 | */
19 |
20 | package com.github.stephenc.javaisotools.iso9660.sabre.impl;
21 |
22 | import java.io.ByteArrayInputStream;
23 | import java.io.IOException;
24 | import java.io.InputStream;
25 |
26 | import com.github.stephenc.javaisotools.sabre.DataReference;
27 |
28 | public class EmptyByteArrayDataReference implements DataReference {
29 |
30 | private int length = 0;
31 |
32 | public EmptyByteArrayDataReference(int length) {
33 | this.length = length;
34 | }
35 |
36 | public long getLength() {
37 | return length;
38 | }
39 |
40 | public InputStream createInputStream() throws IOException {
41 | byte[] buffer = null;
42 |
43 | buffer = new byte[length];
44 | for (int i = 0; i < length; i++) {
45 | buffer[i] = 0;
46 | }
47 |
48 | return new ByteArrayInputStream(buffer);
49 | }
50 | }
51 |
--------------------------------------------------------------------------------
/iso9660-writer/src/main/java/com/github/stephenc/javaisotools/iso9660/sabre/impl/LSBFShortDataReference.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2010. Stephen Connolly.
3 | * Copyright (C) 2007. Jens Hatlak
4 | *
5 | * This library is free software; you can redistribute it and/or
6 | * modify it under the terms of the GNU Lesser General Public
7 | * License as published by the Free Software Foundation; either
8 | * version 2.1 of the License, or (at your option) any later version.
9 | *
10 | * This library is distributed in the hope that it will be useful,
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 | * Lesser General Public License for more details.
14 | *
15 | * You should have received a copy of the GNU Lesser General Public
16 | * License along with this library; if not, write to the Free Software
17 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
18 | */
19 |
20 | package com.github.stephenc.javaisotools.iso9660.sabre.impl;
21 |
22 | import java.io.ByteArrayInputStream;
23 | import java.io.IOException;
24 | import java.io.InputStream;
25 |
26 | import com.github.stephenc.javaisotools.sabre.DataReference;
27 |
28 | public class LSBFShortDataReference implements DataReference {
29 |
30 | private long value = 0;
31 |
32 | public LSBFShortDataReference(long value) {
33 | this.value = value;
34 | }
35 |
36 | public long getLength() {
37 | return 2;
38 | }
39 |
40 | public InputStream createInputStream() throws IOException {
41 | byte[] buffer = new byte[2];
42 |
43 | // LSB first (Little Endian)
44 | buffer[0] = (byte) (this.value & 0x000000FF);
45 | buffer[1] = (byte) ((this.value & 0x0000FF00) >> 8);
46 |
47 | return new ByteArrayInputStream(buffer);
48 | }
49 |
50 | }
51 |
--------------------------------------------------------------------------------
/iso9660-writer/src/main/java/com/github/stephenc/javaisotools/iso9660/sabre/impl/LSBFWordDataReference.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2010. Stephen Connolly.
3 | * Copyright (C) 2007. Jens Hatlak
4 | *
5 | * This library is free software; you can redistribute it and/or
6 | * modify it under the terms of the GNU Lesser General Public
7 | * License as published by the Free Software Foundation; either
8 | * version 2.1 of the License, or (at your option) any later version.
9 | *
10 | * This library is distributed in the hope that it will be useful,
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 | * Lesser General Public License for more details.
14 | *
15 | * You should have received a copy of the GNU Lesser General Public
16 | * License along with this library; if not, write to the Free Software
17 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
18 | */
19 |
20 | package com.github.stephenc.javaisotools.iso9660.sabre.impl;
21 |
22 | import java.io.ByteArrayInputStream;
23 | import java.io.IOException;
24 | import java.io.InputStream;
25 |
26 | import com.github.stephenc.javaisotools.sabre.DataReference;
27 |
28 | public class LSBFWordDataReference implements DataReference {
29 |
30 | private long value = 0;
31 |
32 | public LSBFWordDataReference(long value) {
33 | this.value = value;
34 | }
35 |
36 | public long getLength() {
37 | return 4;
38 | }
39 |
40 | public InputStream createInputStream() throws IOException {
41 | byte[] buffer = new byte[4];
42 |
43 | // LSB first (Little Endian)
44 | buffer[0] = (byte) (this.value & 0x000000FF);
45 | buffer[1] = (byte) ((this.value & 0x0000FF00) >> 8);
46 | buffer[2] = (byte) ((this.value & 0x00FF0000) >> 16);
47 | buffer[3] = (byte) ((this.value & 0xFF000000) >> 24);
48 |
49 | return new ByteArrayInputStream(buffer);
50 | }
51 |
52 | }
53 |
--------------------------------------------------------------------------------
/iso9660-writer/src/main/java/com/github/stephenc/javaisotools/iso9660/volumedescriptors/BootRecord.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2010. Stephen Connolly.
3 | * Copyright (C) 2007. Jens Hatlak
4 | *
5 | * This library is free software; you can redistribute it and/or
6 | * modify it under the terms of the GNU Lesser General Public
7 | * License as published by the Free Software Foundation; either
8 | * version 2.1 of the License, or (at your option) any later version.
9 | *
10 | * This library is distributed in the hope that it will be useful,
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 | * Lesser General Public License for more details.
14 | *
15 | * You should have received a copy of the GNU Lesser General Public
16 | * License along with this library; if not, write to the Free Software
17 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
18 | */
19 |
20 | package com.github.stephenc.javaisotools.iso9660.volumedescriptors;
21 |
22 | import com.github.stephenc.javaisotools.sabre.HandlerException;
23 | import com.github.stephenc.javaisotools.sabre.impl.ByteArrayDataReference;
24 | import com.github.stephenc.javaisotools.iso9660.BootConfig;
25 | import com.github.stephenc.javaisotools.iso9660.LayoutHelper;
26 | import com.github.stephenc.javaisotools.iso9660.impl.ISO9660Constants;
27 | import com.github.stephenc.javaisotools.sabre.StreamHandler;
28 |
29 | public class BootRecord extends ISO9660VolumeDescriptor {
30 |
31 | private String bootSystemId, bootId;
32 |
33 | public BootRecord(StreamHandler streamHandler, LayoutHelper helper) {
34 | super(streamHandler, ISO9660Constants.BR_TYPE, helper);
35 | this.bootSystemId = this.bootId = "";
36 | }
37 |
38 | public void setBootId(String bootId) {
39 | this.bootId = bootId;
40 | }
41 |
42 | public void setBootSystemId(String bootSystemId) {
43 | this.bootSystemId = bootSystemId;
44 | }
45 |
46 | public void setMetadata(BootConfig config) {
47 | setBootSystemId(config.getBootSystemId());
48 | setBootId(config.getBootId());
49 | }
50 |
51 | public void doBR() throws HandlerException {
52 | // Volume Descriptor Type: Boot
53 | streamHandler.data(getType());
54 |
55 | // Standard Identifier
56 | streamHandler.data(getStandardId());
57 |
58 | // Volume Descriptor Version
59 | streamHandler.data(getVDVersion());
60 |
61 | // Boot System Identifier: 32 bytes
62 | streamHandler.data(getBootSystemId());
63 |
64 | // Boot Identifier: 32 bytes
65 | streamHandler.data(getBootId());
66 |
67 | // Boot System Use: handle externally
68 | }
69 |
70 | private ByteArrayDataReference getBootSystemId() throws HandlerException {
71 | byte[] bytes = helper.pad(bootSystemId, 32);
72 | return new ByteArrayDataReference(bytes);
73 | }
74 |
75 | private ByteArrayDataReference getBootId() throws HandlerException {
76 | byte[] bytes = helper.pad(bootId, 32);
77 | return new ByteArrayDataReference(bytes);
78 | }
79 | }
80 |
--------------------------------------------------------------------------------
/iso9660-writer/src/main/java/com/github/stephenc/javaisotools/iso9660/volumedescriptors/ISO9660VolumeDescriptor.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2010. Stephen Connolly.
3 | * Copyright (C) 2007. Jens Hatlak
4 | *
5 | * This library is free software; you can redistribute it and/or
6 | * modify it under the terms of the GNU Lesser General Public
7 | * License as published by the Free Software Foundation; either
8 | * version 2.1 of the License, or (at your option) any later version.
9 | *
10 | * This library is distributed in the hope that it will be useful,
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 | * Lesser General Public License for more details.
14 | *
15 | * You should have received a copy of the GNU Lesser General Public
16 | * License along with this library; if not, write to the Free Software
17 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
18 | */
19 |
20 | package com.github.stephenc.javaisotools.iso9660.volumedescriptors;
21 |
22 | import com.github.stephenc.javaisotools.iso9660.LayoutHelper;
23 | import com.github.stephenc.javaisotools.iso9660.impl.ISO9660Constants;
24 | import com.github.stephenc.javaisotools.sabre.impl.ByteArrayDataReference;
25 | import com.github.stephenc.javaisotools.sabre.impl.ByteDataReference;
26 | import com.github.stephenc.javaisotools.sabre.StreamHandler;
27 |
28 | public abstract class ISO9660VolumeDescriptor {
29 |
30 | StreamHandler streamHandler;
31 | int type;
32 | LayoutHelper helper;
33 |
34 | public ISO9660VolumeDescriptor(StreamHandler streamHandler, int type, LayoutHelper helper) {
35 | this.streamHandler = streamHandler;
36 | this.type = type;
37 | this.helper = helper;
38 | }
39 |
40 | ByteDataReference getType() {
41 | return new ByteDataReference(type);
42 | }
43 |
44 | ByteArrayDataReference getStandardId() {
45 | return new ByteArrayDataReference(ISO9660Constants.STD_ID.getBytes());
46 | }
47 |
48 | ByteDataReference getVDVersion() {
49 | return new ByteDataReference(ISO9660Constants.VDV);
50 | }
51 | }
52 |
--------------------------------------------------------------------------------
/iso9660-writer/src/main/java/com/github/stephenc/javaisotools/iso9660/volumedescriptors/PrimaryVolumeDescriptor.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2010. Stephen Connolly.
3 | * Copyright (C) 2007. Jens Hatlak
4 | *
5 | * This library is free software; you can redistribute it and/or
6 | * modify it under the terms of the GNU Lesser General Public
7 | * License as published by the Free Software Foundation; either
8 | * version 2.1 of the License, or (at your option) any later version.
9 | *
10 | * This library is distributed in the hope that it will be useful,
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 | * Lesser General Public License for more details.
14 | *
15 | * You should have received a copy of the GNU Lesser General Public
16 | * License along with this library; if not, write to the Free Software
17 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
18 | */
19 |
20 | package com.github.stephenc.javaisotools.iso9660.volumedescriptors;
21 |
22 | import java.util.HashMap;
23 |
24 | import com.github.stephenc.javaisotools.iso9660.impl.ISO9660Constants;
25 | import com.github.stephenc.javaisotools.sabre.Fixup;
26 | import com.github.stephenc.javaisotools.sabre.StreamHandler;
27 | import com.github.stephenc.javaisotools.sabre.impl.ThreeByteDataReference;
28 | import com.github.stephenc.javaisotools.iso9660.LayoutHelper;
29 | import com.github.stephenc.javaisotools.sabre.HandlerException;
30 | import com.github.stephenc.javaisotools.sabre.impl.ByteDataReference;
31 |
32 | public class PrimaryVolumeDescriptor extends StandardVolumeDescriptor {
33 |
34 | public PrimaryVolumeDescriptor(StreamHandler streamHandler, LayoutHelper helper) {
35 | super(streamHandler, ISO9660Constants.PVD_TYPE, helper);
36 | }
37 |
38 | public HashMap doPVD() throws HandlerException {
39 | HashMap memory = doStandardVD();
40 |
41 | // Set Volume Flags to 0 (Unused Field)
42 | Fixup volumeFlags = (Fixup) memory.get("volumeFlagsFixup");
43 | volumeFlags.data(new ByteDataReference(0));
44 | volumeFlags.close();
45 | memory.remove("volumeFlagsFixup");
46 |
47 | // Set Escape Sequences to all 0 (Unused Field)
48 | Fixup escapeSequences = (Fixup) memory.get("escapeSequencesFixup");
49 | escapeSequences.data(new ThreeByteDataReference(0));
50 | escapeSequences.close();
51 | memory.remove("escapeSequencesFixup");
52 |
53 | return memory;
54 | }
55 | }
56 |
--------------------------------------------------------------------------------
/iso9660-writer/src/main/java/com/github/stephenc/javaisotools/iso9660/volumedescriptors/SupplementaryVolumeDescriptor.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2010. Stephen Connolly.
3 | * Copyright (C) 2007. Jens Hatlak
4 | *
5 | * This library is free software; you can redistribute it and/or
6 | * modify it under the terms of the GNU Lesser General Public
7 | * License as published by the Free Software Foundation; either
8 | * version 2.1 of the License, or (at your option) any later version.
9 | *
10 | * This library is distributed in the hope that it will be useful,
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 | * Lesser General Public License for more details.
14 | *
15 | * You should have received a copy of the GNU Lesser General Public
16 | * License along with this library; if not, write to the Free Software
17 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
18 | */
19 |
20 | package com.github.stephenc.javaisotools.iso9660.volumedescriptors;
21 |
22 | import java.util.HashMap;
23 |
24 | import com.github.stephenc.javaisotools.iso9660.LayoutHelper;
25 | import com.github.stephenc.javaisotools.iso9660.impl.ISO9660Constants;
26 | import com.github.stephenc.javaisotools.sabre.HandlerException;
27 | import com.github.stephenc.javaisotools.sabre.StreamHandler;
28 |
29 | public class SupplementaryVolumeDescriptor extends StandardVolumeDescriptor {
30 |
31 | public SupplementaryVolumeDescriptor(StreamHandler streamHandler, LayoutHelper helper) {
32 | super(streamHandler, ISO9660Constants.SVD_TYPE, helper);
33 | }
34 |
35 | public HashMap doSVD() throws HandlerException {
36 | return doStandardVD();
37 | }
38 | }
39 |
--------------------------------------------------------------------------------
/iso9660-writer/src/main/java/com/github/stephenc/javaisotools/iso9660/volumedescriptors/VolumeDescriptorSetTerminator.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2010. Stephen Connolly.
3 | * Copyright (C) 2007. Jens Hatlak
4 | *
5 | * This library is free software; you can redistribute it and/or
6 | * modify it under the terms of the GNU Lesser General Public
7 | * License as published by the Free Software Foundation; either
8 | * version 2.1 of the License, or (at your option) any later version.
9 | *
10 | * This library is distributed in the hope that it will be useful,
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 | * Lesser General Public License for more details.
14 | *
15 | * You should have received a copy of the GNU Lesser General Public
16 | * License along with this library; if not, write to the Free Software
17 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
18 | */
19 |
20 | package com.github.stephenc.javaisotools.iso9660.volumedescriptors;
21 |
22 | import com.github.stephenc.javaisotools.iso9660.LayoutHelper;
23 | import com.github.stephenc.javaisotools.iso9660.impl.ISO9660Constants;
24 | import com.github.stephenc.javaisotools.sabre.StreamHandler;
25 | import com.github.stephenc.javaisotools.sabre.HandlerException;
26 |
27 | public class VolumeDescriptorSetTerminator extends ISO9660VolumeDescriptor {
28 |
29 | public VolumeDescriptorSetTerminator(StreamHandler streamHandler, LayoutHelper helper) {
30 | super(streamHandler, ISO9660Constants.VDST_TYPE, helper);
31 | }
32 |
33 | public void doVDST() throws HandlerException {
34 | // Volume Descriptor Type: Primary
35 | streamHandler.data(getType());
36 |
37 | // Standard Identifier
38 | streamHandler.data(getStandardId());
39 |
40 | // Volume Descriptor Version
41 | streamHandler.data(getVDVersion());
42 | }
43 | }
44 |
--------------------------------------------------------------------------------
/iso9660-writer/src/main/java/com/github/stephenc/javaisotools/joliet/impl/JolietFilenameDataReference.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2010. Stephen Connolly.
3 | * Copyright (C) 2007. Jens Hatlak
4 | *
5 | * This library is free software; you can redistribute it and/or
6 | * modify it under the terms of the GNU Lesser General Public
7 | * License as published by the Free Software Foundation; either
8 | * version 2.1 of the License, or (at your option) any later version.
9 | *
10 | * This library is distributed in the hope that it will be useful,
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 | * Lesser General Public License for more details.
14 | *
15 | * You should have received a copy of the GNU Lesser General Public
16 | * License along with this library; if not, write to the Free Software
17 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
18 | */
19 |
20 | package com.github.stephenc.javaisotools.joliet.impl;
21 |
22 | import java.io.ByteArrayInputStream;
23 | import java.io.IOException;
24 | import java.io.InputStream;
25 |
26 | import com.github.stephenc.javaisotools.iso9660.ISO9660Directory;
27 | import com.github.stephenc.javaisotools.iso9660.FilenameDataReference;
28 | import com.github.stephenc.javaisotools.iso9660.ISO9660File;
29 | import com.github.stephenc.javaisotools.sabre.HandlerException;
30 |
31 | public class JolietFilenameDataReference extends FilenameDataReference {
32 |
33 | public JolietFilenameDataReference(ISO9660Directory dir) throws HandlerException {
34 | super(dir);
35 | }
36 |
37 | public JolietFilenameDataReference(ISO9660File file) throws HandlerException {
38 | super(file);
39 | }
40 |
41 | public long getLength() {
42 | return getName().length() * 2;
43 | }
44 |
45 | public InputStream createInputStream() throws IOException {
46 | return new ByteArrayInputStream(getName().getBytes("UTF-16BE")); // UCS-2
47 | }
48 | }
49 |
--------------------------------------------------------------------------------
/iso9660-writer/src/main/java/com/github/stephenc/javaisotools/rockridge/impl/RockRidgeFilenameDataReference.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2010. Stephen Connolly.
3 | * Copyright (C) 2007. Jens Hatlak
4 | *
5 | * This library is free software; you can redistribute it and/or
6 | * modify it under the terms of the GNU Lesser General Public
7 | * License as published by the Free Software Foundation; either
8 | * version 2.1 of the License, or (at your option) any later version.
9 | *
10 | * This library is distributed in the hope that it will be useful,
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 | * Lesser General Public License for more details.
14 | *
15 | * You should have received a copy of the GNU Lesser General Public
16 | * License along with this library; if not, write to the Free Software
17 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
18 | */
19 |
20 | package com.github.stephenc.javaisotools.rockridge.impl;
21 |
22 | import java.io.ByteArrayInputStream;
23 | import java.io.IOException;
24 | import java.io.InputStream;
25 |
26 | import com.github.stephenc.javaisotools.iso9660.ISO9660File;
27 | import com.github.stephenc.javaisotools.sabre.HandlerException;
28 | import com.github.stephenc.javaisotools.iso9660.FilenameDataReference;
29 | import com.github.stephenc.javaisotools.iso9660.ISO9660Directory;
30 |
31 | public class RockRidgeFilenameDataReference extends FilenameDataReference {
32 |
33 | public RockRidgeFilenameDataReference(ISO9660Directory dir) throws HandlerException {
34 | super(dir);
35 | }
36 |
37 | public RockRidgeFilenameDataReference(ISO9660File file) throws HandlerException {
38 | super(file);
39 | setName(file.getName());
40 | }
41 |
42 | public RockRidgeFilenameDataReference(String part) throws HandlerException {
43 | super(part);
44 | }
45 |
46 | public long getLength() {
47 | return getName().length();
48 | }
49 |
50 | public InputStream createInputStream() throws IOException {
51 | return new ByteArrayInputStream(getName().getBytes("ISO-8859-1"));
52 | }
53 | }
54 |
--------------------------------------------------------------------------------
/iso9660-writer/src/main/java/com/github/stephenc/javaisotools/rockridge/impl/SystemUseEntryElement.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2010. Stephen Connolly.
3 | * Copyright (C) 2007. Jens Hatlak
4 | *
5 | * This library is free software; you can redistribute it and/or
6 | * modify it under the terms of the GNU Lesser General Public
7 | * License as published by the Free Software Foundation; either
8 | * version 2.1 of the License, or (at your option) any later version.
9 | *
10 | * This library is distributed in the hope that it will be useful,
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 | * Lesser General Public License for more details.
14 | *
15 | * You should have received a copy of the GNU Lesser General Public
16 | * License along with this library; if not, write to the Free Software
17 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
18 | */
19 |
20 | package com.github.stephenc.javaisotools.rockridge.impl;
21 |
22 | import com.github.stephenc.javaisotools.sabre.Element;
23 |
24 | public class SystemUseEntryElement extends Element {
25 |
26 | private String signature;
27 | private int version;
28 |
29 | public SystemUseEntryElement(String signature, int version) {
30 | this.signature = signature;
31 | this.version = version;
32 | }
33 |
34 | public byte[] getSignatureWord() {
35 | if (signature != null) {
36 | return signature.getBytes();
37 | }
38 | return null;
39 | }
40 |
41 | public int getVersion() {
42 | return version;
43 | }
44 |
45 | public Object getId() {
46 | return signature;
47 | }
48 | }
49 |
--------------------------------------------------------------------------------
/iso9660-writer/src/test/resources/test.properties:
--------------------------------------------------------------------------------
1 | #
2 | # Copyright (c) 2010. Stephen Connolly
3 | #
4 | # This library is free software; you can redistribute it and/or
5 | # modify it under the terms of the GNU Lesser General Public
6 | # License as published by the Free Software Foundation; either
7 | # version 2.1 of the License, or (at your option) any later version.
8 | #
9 | # This library is distributed in the hope that it will be useful,
10 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 | # Lesser General Public License for more details.
13 | #
14 | # You should have received a copy of the GNU Lesser General Public
15 | # License along with this library; if not, write to the Free Software
16 | # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
17 | #
18 |
19 | work-directory ${project.build.directory}/test-work
--------------------------------------------------------------------------------
/loop-fs-api/CREDITS:
--------------------------------------------------------------------------------
1 | loopy is based on the file system code from JNode (www.jnode.org). Thanks to the JNode developers for doing a lot of
2 | hard work :)
--------------------------------------------------------------------------------
/loop-fs-api/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
19 |
20 |
21 |
22 | java-iso-tools-parent
23 | com.github.stephenc.java-iso-tools
24 | 2.1.1-SNAPSHOT
25 |
26 | 4.0.0
27 |
28 | loop-fs-api
29 |
30 | Loop-back File System API
31 |
32 |
33 | jdidion
34 | John Didion
35 | jdidion@loudeye.com
36 |
37 |
38 | stephenc
39 | Stephen Connolly
40 |
41 |
42 |
43 |
44 |
--------------------------------------------------------------------------------
/loop-fs-api/src/main/java/com/github/stephenc/javaisotools/loopfs/api/FileEntry.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2010. Stephen Connolly.
3 | * Copyright (c) 2006-2007. loopy project (http://loopy.sourceforge.net).
4 | *
5 | * This library is free software; you can redistribute it and/or
6 | * modify it under the terms of the GNU Lesser General Public
7 | * License as published by the Free Software Foundation; either
8 | * version 2.1 of the License, or (at your option) any later version.
9 | *
10 | * This library is distributed in the hope that it will be useful,
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 | * Lesser General Public License for more details.
14 | *
15 | * You should have received a copy of the GNU Lesser General Public
16 | * License along with this library; if not, write to the Free Software
17 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
18 | */
19 |
20 | package com.github.stephenc.javaisotools.loopfs.api;
21 |
22 | /**
23 | * An entry in a loop-fs file system. Paths within the file system are unix-like ("/" separated hierarchy of folders and
24 | * files).
25 | */
26 | public interface FileEntry {
27 |
28 | /**
29 | * Returns the entry name (the last entry of the path).
30 | *
31 | * @return the entry name
32 | */
33 | String getName();
34 |
35 | /**
36 | * Returns the relative entry path. The path does NOT begin with any separators.
37 | *
38 | * @return the entry path
39 | */
40 | String getPath();
41 |
42 | /**
43 | * Returns the last modified time for this entry, in milliseconds.
44 | *
45 | * @return the last modified time
46 | */
47 | long getLastModifiedTime();
48 |
49 | /**
50 | * Returns whether this entry represents a directory.
51 | *
52 | * @return true if this entry represents a directory, otherwise false.
53 | */
54 | boolean isDirectory();
55 |
56 | /**
57 | * Returns the size, in bytes, of the data represented by this entry.
58 | *
59 | * @return the entry size
60 | */
61 | long getSize();
62 | }
--------------------------------------------------------------------------------
/loop-fs-api/src/main/java/com/github/stephenc/javaisotools/loopfs/api/FileSystem.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2010. Stephen Connolly.
3 | * Copyright (c) 2006-2007. loopy project (http://loopy.sourceforge.net).
4 | *
5 | * This library is free software; you can redistribute it and/or
6 | * modify it under the terms of the GNU Lesser General Public
7 | * License as published by the Free Software Foundation; either
8 | * version 2.1 of the License, or (at your option) any later version.
9 | *
10 | * This library is distributed in the hope that it will be useful,
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 | * Lesser General Public License for more details.
14 | *
15 | * You should have received a copy of the GNU Lesser General Public
16 | * License along with this library; if not, write to the Free Software
17 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
18 | */
19 |
20 | package com.github.stephenc.javaisotools.loopfs.api;
21 |
22 | import java.io.Closeable;
23 | import java.io.IOException;
24 | import java.io.InputStream;
25 | import java.util.Enumeration;
26 |
27 | /**
28 | * A loop-fs file system, which is deserialize-only and consists of zero or more entries. The data for each entry can be
29 | * retrieved using {@link #getInputStream(FileEntry)}.
30 | */
31 | public interface FileSystem extends Iterable, Closeable {
32 |
33 | /**
34 | * Returns an input stream that reads the data for the given entry.
35 | *
36 | * @param entry the FileEntry
37 | *
38 | * @return an input stream that reads the contents of the given entry
39 | */
40 | InputStream getInputStream(T entry);
41 |
42 | /**
43 | * Returns whether or not this FileSystem has been closed.
44 | *
45 | * @return true if {@link FileSystem#close()} has been called on this * FileSystem, otherwise false.
46 | */
47 | boolean isClosed();
48 | }
--------------------------------------------------------------------------------
/loop-fs-api/src/main/java/com/github/stephenc/javaisotools/loopfs/api/LoopFileSystemException.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2010. Stephen Connolly.
3 | * Copyright (c) 2006-2007. loopy project (http://loopy.sourceforge.net).
4 | *
5 | * This library is free software; you can redistribute it and/or
6 | * modify it under the terms of the GNU Lesser General Public
7 | * License as published by the Free Software Foundation; either
8 | * version 2.1 of the License, or (at your option) any later version.
9 | *
10 | * This library is distributed in the hope that it will be useful,
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 | * Lesser General Public License for more details.
14 | *
15 | * You should have received a copy of the GNU Lesser General Public
16 | * License along with this library; if not, write to the Free Software
17 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
18 | */
19 |
20 | package com.github.stephenc.javaisotools.loopfs.api;
21 |
22 | import java.io.IOException;
23 |
24 | /**
25 | * General loop-fs exception.
26 | */
27 | public class LoopFileSystemException extends IOException {
28 |
29 | public LoopFileSystemException() {
30 | }
31 |
32 | public LoopFileSystemException(final String message) {
33 | super(message);
34 | }
35 |
36 | public LoopFileSystemException(final Throwable cause) {
37 | super(cause);
38 | }
39 |
40 | public LoopFileSystemException(final String message, final Throwable cause) {
41 | super(message, cause);
42 | }
43 | }
--------------------------------------------------------------------------------
/loop-fs-iso-impl/src/main/java/com/github/stephenc/javaisotools/loopfs/iso9660/Constants.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2010. Stephen Connolly.
3 | * Copyright (c) 2006-2007. loopy project (http://loopy.sourceforge.net).
4 | *
5 | * This library is free software; you can redistribute it and/or
6 | * modify it under the terms of the GNU Lesser General Public
7 | * License as published by the Free Software Foundation; either
8 | * version 2.1 of the License, or (at your option) any later version.
9 | *
10 | * This library is distributed in the hope that it will be useful,
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 | * Lesser General Public License for more details.
14 | *
15 | * You should have received a copy of the GNU Lesser General Public
16 | * License along with this library; if not, write to the Free Software
17 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
18 | */
19 |
20 | package com.github.stephenc.javaisotools.loopfs.iso9660;
21 |
22 | public interface Constants {
23 |
24 | /**
25 | * ISO sector size. This does not include the 288 bytes reserved for synchronization, header, and EC on CD-ROMs
26 | * because this information is not used in .iso files.
27 | */
28 | int DEFAULT_BLOCK_SIZE = 2 * 1024;
29 |
30 | /**
31 | * The number of reserved sectors at the beginning of the file.
32 | */
33 | int RESERVED_SECTORS = 16;
34 |
35 | /**
36 | * The number of reserved bytes at the beginning of the file.
37 | */
38 | int RESERVED_BYTES = RESERVED_SECTORS * DEFAULT_BLOCK_SIZE;
39 |
40 | /**
41 | * Default character encoding.
42 | */
43 | String DEFAULT_ENCODING = "US-ASCII";
44 | }
--------------------------------------------------------------------------------
/loop-fs-iso-impl/src/test/images/iso/test1.iso:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/stephenc/java-iso-tools/334caa435f58ebaa8a5f69eefc2e5ac247c0d6c2/loop-fs-iso-impl/src/test/images/iso/test1.iso
--------------------------------------------------------------------------------
/loop-fs-iso-impl/src/test/images/raw/test1/root/a.txt:
--------------------------------------------------------------------------------
1 | Hello
--------------------------------------------------------------------------------
/loop-fs-iso-impl/src/test/images/raw/test1/root/b.txt:
--------------------------------------------------------------------------------
1 | Goodbye
--------------------------------------------------------------------------------
/loop-fs-iso-impl/src/test/resources/test.properties:
--------------------------------------------------------------------------------
1 | #
2 | # Copyright (c) 2010. Stephen Connolly.
3 | #
4 | # This library is free software; you can redistribute it and/or
5 | # modify it under the terms of the GNU Lesser General Public
6 | # License as published by the Free Software Foundation; either
7 | # version 2.1 of the License, or (at your option) any later version.
8 | #
9 | # This library is distributed in the hope that it will be useful,
10 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 | # Lesser General Public License for more details.
13 | #
14 | # You should have received a copy of the GNU Lesser General Public
15 | # License along with this library; if not, write to the Free Software
16 | # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
17 | #
18 |
19 | source-image ${basedir}/src/test/images/iso/test1.iso
20 | source-root ${basedir}/src/test/images/raw/test1
--------------------------------------------------------------------------------
/loop-fs-spi/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
19 |
20 |
21 |
22 | java-iso-tools-parent
23 | com.github.stephenc.java-iso-tools
24 | 2.1.1-SNAPSHOT
25 |
26 | 4.0.0
27 |
28 | loop-fs-spi
29 |
30 | Loop-back File System SPI
31 |
32 |
33 |
34 | jdidion
35 | John Didion
36 | jdidion@loudeye.com
37 |
38 |
39 | stephenc
40 | Stephen Connolly
41 |
42 |
43 |
44 |
45 |
46 | com.github.stephenc.java-iso-tools
47 | loop-fs-api
48 | 2.1.1-SNAPSHOT
49 |
50 |
51 | org.apache.hadoop
52 | hadoop-client
53 | 2.6.0
54 |
55 |
56 |
57 |
--------------------------------------------------------------------------------
/loop-fs-spi/src/main/java/com/github/stephenc/javaisotools/loopfs/spi/SeekableInput.java:
--------------------------------------------------------------------------------
1 | package com.github.stephenc.javaisotools.loopfs.spi;
2 |
3 | import java.io.IOException;
4 | import java.io.RandomAccessFile;
5 |
6 | /**
7 | * SeekableInput is an interface to abstract from using only Files as the pass-in to File Systems,
8 | * this allows for any SeekableInput to be used instead.
9 | */
10 | public interface SeekableInput {
11 |
12 | /**
13 | * @see java.io.RandomAccessFile#seek(long)
14 | */
15 | void seek(long pos) throws IOException;
16 |
17 | /**
18 | * @see java.io.RandomAccessFile#read(byte[], int, int)
19 | */
20 | int read(byte[] b, int off, int len) throws IOException;
21 |
22 | /**
23 | * @see RandomAccessFile#close()
24 | */
25 | void close() throws IOException;
26 | }
27 |
--------------------------------------------------------------------------------
/loop-fs-spi/src/main/java/com/github/stephenc/javaisotools/loopfs/spi/SeekableInputFile.java:
--------------------------------------------------------------------------------
1 | package com.github.stephenc.javaisotools.loopfs.spi;
2 |
3 | import java.io.File;
4 | import java.io.FileNotFoundException;
5 | import java.io.IOException;
6 | import java.io.RandomAccessFile;
7 |
8 | /**
9 | * A Seekable Input File which wraps around a File object
10 | */
11 | public class SeekableInputFile implements SeekableInput {
12 |
13 | private RandomAccessFile channel;
14 |
15 | public SeekableInputFile(File file) throws IOException {
16 | if (!file.exists()) {
17 | throw new FileNotFoundException("File does not exist: " + file);
18 | }
19 | this.channel = new RandomAccessFile(file, "r");
20 | }
21 |
22 | public void seek(long pos) throws IOException {
23 | this.channel.seek(pos);
24 | }
25 |
26 | public int read(byte[] b, int off, int len) throws IOException {
27 | return this.channel.read(b, off, len);
28 | }
29 |
30 | public void close() throws IOException {
31 | this.channel.close();
32 | }
33 | }
34 |
--------------------------------------------------------------------------------
/loop-fs-spi/src/main/java/com/github/stephenc/javaisotools/loopfs/spi/SeekableInputFileHadoop.java:
--------------------------------------------------------------------------------
1 | package com.github.stephenc.javaisotools.loopfs.spi;
2 |
3 | import org.apache.hadoop.fs.FSDataInputStream;
4 |
5 | import java.io.IOException;
6 | import java.io.InputStream;
7 |
8 | /**
9 | * A Seekable Input File to work with Apache Hadoop HDFS
10 | */
11 | public class SeekableInputFileHadoop implements SeekableInput {
12 |
13 | private FSDataInputStream channel;
14 |
15 | public SeekableInputFileHadoop(InputStream is) throws IOException {
16 | this.channel = new FSDataInputStream(is);
17 | }
18 |
19 | public void seek(long pos) throws IOException {
20 | this.channel.seek(pos);
21 | }
22 |
23 | public int read(byte[] b, int off, int len) throws IOException {
24 | return this.channel.read(b, off, len);
25 | }
26 |
27 | public void close() throws IOException {
28 | this.channel.close();
29 | }
30 | }
31 |
--------------------------------------------------------------------------------
/loop-fs-spi/src/main/java/com/github/stephenc/javaisotools/loopfs/spi/VolumeDescriptorSet.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2010. Stephen Connolly.
3 | * Copyright (c) 2006-2007. loopy project (http://loopy.sourceforge.net).
4 | *
5 | * This library is free software; you can redistribute it and/or
6 | * modify it under the terms of the GNU Lesser General Public
7 | * License as published by the Free Software Foundation; either
8 | * version 2.1 of the License, or (at your option) any later version.
9 | *
10 | * This library is distributed in the hope that it will be useful,
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 | * Lesser General Public License for more details.
14 | *
15 | * You should have received a copy of the GNU Lesser General Public
16 | * License along with this library; if not, write to the Free Software
17 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
18 | */
19 |
20 | package com.github.stephenc.javaisotools.loopfs.spi;
21 |
22 | import java.io.IOException;
23 |
24 | import com.github.stephenc.javaisotools.loopfs.api.FileEntry;
25 |
26 | /**
27 | * Contains all the volume descriptors for a block file system.
28 | */
29 | public interface VolumeDescriptorSet {
30 |
31 | /**
32 | * Load a volume descriptor from the specified byte array.
33 | *
34 | * @param volumeDescriptor the volume descriptor to deserialize
35 | *
36 | * @return true if the volume descriptor is a terminator
37 | *
38 | * @throws IOException if there is an error deserializing the volume descriptor
39 | */
40 | boolean deserialize(byte[] volumeDescriptor) throws IOException;
41 |
42 | /**
43 | * Returns the root file entry for the file system.
44 | *
45 | * @return the root file entry for the file system
46 | */
47 | T getRootEntry();
48 | }
49 |
--------------------------------------------------------------------------------
/loop-fs-spi/src/main/java/com/github/stephenc/javaisotools/loopfs/util/BigEndian.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2010. Stephen Connolly.
3 | * Copyright (c) 2006-2007. loopy project (http://loopy.sourceforge.net).
4 | *
5 | * This library is free software; you can redistribute it and/or
6 | * modify it under the terms of the GNU Lesser General Public
7 | * License as published by the Free Software Foundation; either
8 | * version 2.1 of the License, or (at your option) any later version.
9 | *
10 | * This library is distributed in the hope that it will be useful,
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 | * Lesser General Public License for more details.
14 | *
15 | * You should have received a copy of the GNU Lesser General Public
16 | * License along with this library; if not, write to the Free Software
17 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
18 | */
19 |
20 | package com.github.stephenc.javaisotools.loopfs.util;
21 |
22 | /**
23 | * Big endian (MSB first) conversion methods.
24 | */
25 | public class BigEndian {
26 |
27 | /**
28 | * Gets a 16-bit unsigned integer from the given byte array at the given offset.
29 | */
30 | public static int getUInt16(byte[] src, int offset) {
31 | final int v1 = src[offset] & 0xFF;
32 | final int v0 = src[offset + 1] & 0xFF;
33 | return ((v1 << 8) | v0);
34 | }
35 |
36 | /**
37 | * Gets a 32-bit unsigned integer from the given byte array at the given offset.
38 | */
39 | public static long getUInt32(byte[] src, int offset) {
40 | final long v3 = src[offset] & 0xFF;
41 | final long v2 = src[offset + 1] & 0xFF;
42 | final long v1 = src[offset + 2] & 0xFF;
43 | final long v0 = src[offset + 3] & 0xFF;
44 | return ((v3 << 24) | (v2 << 16) | (v1 << 8) | v0);
45 | }
46 | }
47 |
--------------------------------------------------------------------------------
/loop-fs-spi/src/main/java/com/github/stephenc/javaisotools/loopfs/util/LittleEndian.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2010. Stephen Connolly.
3 | * Copyright (c) 2006-2007. loopy project (http://loopy.sourceforge.net).
4 | *
5 | * This library is free software; you can redistribute it and/or
6 | * modify it under the terms of the GNU Lesser General Public
7 | * License as published by the Free Software Foundation; either
8 | * version 2.1 of the License, or (at your option) any later version.
9 | *
10 | * This library is distributed in the hope that it will be useful,
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 | * Lesser General Public License for more details.
14 | *
15 | * You should have received a copy of the GNU Lesser General Public
16 | * License along with this library; if not, write to the Free Software
17 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
18 | */
19 |
20 | package com.github.stephenc.javaisotools.loopfs.util;
21 |
22 | /**
23 | * Little endian (LSB first) conversion methods.
24 | */
25 | public class LittleEndian {
26 |
27 | /**
28 | * Gets an 8-bit unsigned integer from the given byte array at the given offset.
29 | */
30 | public static int getUInt8(byte[] src, int offset) {
31 | return src[offset] & 0xFF;
32 | }
33 |
34 | /**
35 | * Gets an 8-bit signed integer from the given byte array at the given offset.
36 | */
37 | public static int getInt8(byte[] src, int offset) {
38 | return src[offset];
39 | }
40 |
41 | /**
42 | * Gets a 16-bit unsigned integer from the given byte array at the given offset.
43 | */
44 | public static int getUInt16(byte[] src, int offset) {
45 | final int v0 = src[offset] & 0xFF;
46 | final int v1 = src[offset + 1] & 0xFF;
47 | return ((v1 << 8) | v0);
48 | }
49 |
50 | /**
51 | * Gets a 32-bit unsigned integer from the given byte array at the given offset.
52 | */
53 | public static long getUInt32(byte[] src, int offset) {
54 | final long v0 = src[offset] & 0xFF;
55 | final long v1 = src[offset + 1] & 0xFF;
56 | final long v2 = src[offset + 2] & 0xFF;
57 | final long v3 = src[offset + 3] & 0xFF;
58 | return ((v3 << 24) | (v2 << 16) | (v1 << 8) | v0);
59 | }
60 | }
61 |
--------------------------------------------------------------------------------
/loop-fs-udf-impl/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
19 |
20 |
21 |
22 | java-iso-tools-parent
23 | com.github.stephenc.java-iso-tools
24 | 2.1.1-SNAPSHOT
25 |
26 | 4.0.0
27 |
28 | loop-fs-udf-impl
29 |
30 | Loop-back File System UDF implementation
31 |
32 |
33 |
34 | jdidion
35 | John Didion
36 | jdidion@loudeye.com
37 |
38 |
39 | stephenc
40 | Stephen Connolly
41 |
42 |
43 |
44 |
45 |
46 | com.github.stephenc.java-iso-tools
47 | loop-fs-spi
48 | 2.1.1-SNAPSHOT
49 |
50 |
51 |
52 |
--------------------------------------------------------------------------------
/loop-fs-udf-impl/src/main/java/com/github/stephenc/javaisotools/loopfs/udf/Constants.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2010. Stephen Connolly.
3 | * Copyright (c) 2006-2007. loopy project (http://loopy.sourceforge.net).
4 | *
5 | * This library is free software; you can redistribute it and/or
6 | * modify it under the terms of the GNU Lesser General Public
7 | * License as published by the Free Software Foundation; either
8 | * version 2.1 of the License, or (at your option) any later version.
9 | *
10 | * This library is distributed in the hope that it will be useful,
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 | * Lesser General Public License for more details.
14 | *
15 | * You should have received a copy of the GNU Lesser General Public
16 | * License along with this library; if not, write to the Free Software
17 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
18 | */
19 |
20 | package com.github.stephenc.javaisotools.loopfs.udf;
21 |
22 | public interface Constants {
23 |
24 | /**
25 | * ISO sector size. This does not include the 288 bytes reserved for synchronization, header, and EC on CD-ROMs
26 | * because this information is not used in .iso files.
27 | */
28 | int DEFAULT_BLOCK_SIZE = 2 * 1024;
29 |
30 | /**
31 | * The number of reserved sectors at the beginning of the file.
32 | */
33 | int RESERVED_SECTORS = 16;
34 |
35 | /**
36 | * The number of reserved bytes at the beginning of the file.
37 | */
38 | int RESERVED_BYTES = RESERVED_SECTORS * DEFAULT_BLOCK_SIZE;
39 |
40 | /**
41 | * Default character encoding.
42 | */
43 | String DEFAULT_ENCODING = "US-ASCII";
44 | }
--------------------------------------------------------------------------------
/loop-fs-udf-impl/src/main/java/com/github/stephenc/javaisotools/loopfs/udf/UDFFileEntry.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2010. Stephen Connolly.
3 | * Copyright (c) 2006-2007. loopy project (http://loopy.sourceforge.net).
4 | *
5 | * This library is free software; you can redistribute it and/or
6 | * modify it under the terms of the GNU Lesser General Public
7 | * License as published by the Free Software Foundation; either
8 | * version 2.1 of the License, or (at your option) any later version.
9 | *
10 | * This library is distributed in the hope that it will be useful,
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 | * Lesser General Public License for more details.
14 | *
15 | * You should have received a copy of the GNU Lesser General Public
16 | * License along with this library; if not, write to the Free Software
17 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
18 | */
19 |
20 | package com.github.stephenc.javaisotools.loopfs.udf;
21 |
22 | import com.github.stephenc.javaisotools.loopfs.api.FileEntry;
23 |
24 | public class UDFFileEntry implements FileEntry {
25 |
26 | public String getName() {
27 | return null;
28 | }
29 |
30 | public String getPath() {
31 | return null;
32 | }
33 |
34 | public long getLastModifiedTime() {
35 | return 0;
36 | }
37 |
38 | public boolean isDirectory() {
39 | return false;
40 | }
41 |
42 | public long getSize() {
43 | return 0;
44 | }
45 | }
--------------------------------------------------------------------------------
/loop-fs-udf-impl/src/main/java/com/github/stephenc/javaisotools/loopfs/udf/UDFFileSystem.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2010. Stephen Connolly.
3 | * Copyright (c) 2006-2007. loopy project (http://loopy.sourceforge.net).
4 | *
5 | * This library is free software; you can redistribute it and/or
6 | * modify it under the terms of the GNU Lesser General Public
7 | * License as published by the Free Software Foundation; either
8 | * version 2.1 of the License, or (at your option) any later version.
9 | *
10 | * This library is distributed in the hope that it will be useful,
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 | * Lesser General Public License for more details.
14 | *
15 | * You should have received a copy of the GNU Lesser General Public
16 | * License along with this library; if not, write to the Free Software
17 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
18 | */
19 |
20 | package com.github.stephenc.javaisotools.loopfs.udf;
21 |
22 | import java.io.File;
23 | import java.io.IOException;
24 | import java.io.InputStream;
25 | import java.util.Iterator;
26 |
27 | import com.github.stephenc.javaisotools.loopfs.spi.AbstractBlockFileSystem;
28 | import com.github.stephenc.javaisotools.loopfs.spi.SeekableInput;
29 | import com.github.stephenc.javaisotools.loopfs.spi.SeekableInputFile;
30 | import com.github.stephenc.javaisotools.loopfs.spi.VolumeDescriptorSet;
31 |
32 | public class UDFFileSystem extends AbstractBlockFileSystem {
33 |
34 | public UDFFileSystem(File file, boolean readOnly) throws IOException {
35 | this(new SeekableInputFile(file), readOnly, Constants.DEFAULT_BLOCK_SIZE);
36 | }
37 |
38 | public UDFFileSystem(SeekableInput file, boolean readOnly, int sectorSize) throws IOException {
39 | super(file, readOnly, sectorSize, Constants.RESERVED_SECTORS);
40 | }
41 |
42 | public InputStream getInputStream(UDFFileEntry entry) {
43 | return null;
44 | }
45 |
46 | protected Iterator iterator(UDFFileEntry root) {
47 | return null;
48 | }
49 |
50 | protected VolumeDescriptorSet createVolumeDescriptorSet() {
51 | return new UDFVolumeDescriptorSet(this);
52 | }
53 | }
--------------------------------------------------------------------------------
/loop-fs-udf-impl/src/main/java/com/github/stephenc/javaisotools/loopfs/udf/UDFVolumeDescriptorSet.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2010. Stephen Connolly.
3 | * Copyright (c) 2006-2007. loopy project (http://loopy.sourceforge.net).
4 | *
5 | * This library is free software; you can redistribute it and/or
6 | * modify it under the terms of the GNU Lesser General Public
7 | * License as published by the Free Software Foundation; either
8 | * version 2.1 of the License, or (at your option) any later version.
9 | *
10 | * This library is distributed in the hope that it will be useful,
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 | * Lesser General Public License for more details.
14 | *
15 | * You should have received a copy of the GNU Lesser General Public
16 | * License along with this library; if not, write to the Free Software
17 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
18 | */
19 |
20 | package com.github.stephenc.javaisotools.loopfs.udf;
21 |
22 | import java.io.IOException;
23 |
24 | import com.github.stephenc.javaisotools.loopfs.api.FileEntry;
25 | import com.github.stephenc.javaisotools.loopfs.spi.VolumeDescriptorSet;
26 |
27 | public class UDFVolumeDescriptorSet implements VolumeDescriptorSet {
28 |
29 | private UDFFileSystem fs;
30 |
31 | public UDFVolumeDescriptorSet(UDFFileSystem fs) {
32 | this.fs = fs;
33 | }
34 |
35 | public boolean deserialize(byte[] descriptorBytes) throws IOException {
36 | return false;
37 | }
38 |
39 | public FileEntry getRootEntry() {
40 | return null;
41 | }
42 | }
--------------------------------------------------------------------------------
/sabre/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
19 |
20 |
21 | 4.0.0
22 |
23 |
24 | com.github.stephenc.java-iso-tools
25 | java-iso-tools-parent
26 | 2.1.1-SNAPSHOT
27 |
28 |
29 | sabre
30 | Simple API for Binary Representations
31 |
32 |
33 |
34 | stephenc
35 | Stephen Connolly
36 |
37 |
38 | mhartle
39 | Michael Hartle
40 | mhartle@rbg.informatik.tu-darmstadt.de
41 |
42 |
43 | lewing
44 | Larry Ewing
45 | lewing@isc.tamu.edu
46 |
47 |
48 |
49 |
50 |
51 | commons-lang
52 | commons-lang
53 | 2.6
54 |
55 |
56 | org.apache.ant
57 | ant
58 | 1.9.15
59 |
60 |
61 |
62 |
63 |
--------------------------------------------------------------------------------
/sabre/src/main/java/com/github/stephenc/javaisotools/sabre/ContentHandler.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2010. Stephen Connolly.
3 | * Copyright (c) 2006. Michael Hartle .
4 | *
5 | * This library is free software; you can redistribute it and/or
6 | * modify it under the terms of the GNU Lesser General Public
7 | * License as published by the Free Software Foundation; either
8 | * version 2.1 of the License, or (at your option) any later version.
9 | *
10 | * This library is distributed in the hope that it will be useful,
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 | * Lesser General Public License for more details.
14 | *
15 | * You should have received a copy of the GNU Lesser General Public
16 | * License along with this library; if not, write to the Free Software
17 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
18 | */
19 |
20 | package com.github.stephenc.javaisotools.sabre;
21 |
22 | public interface ContentHandler {
23 |
24 | public void data(DataReference reference) throws HandlerException;
25 |
26 | public Fixup fixup(DataReference reference) throws HandlerException;
27 |
28 | public long mark() throws HandlerException;
29 | }
30 |
--------------------------------------------------------------------------------
/sabre/src/main/java/com/github/stephenc/javaisotools/sabre/DataReference.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2010. Stephen Connolly.
3 | * Copyright (c) 2006. Michael Hartle .
4 | *
5 | * This library is free software; you can redistribute it and/or
6 | * modify it under the terms of the GNU Lesser General Public
7 | * License as published by the Free Software Foundation; either
8 | * version 2.1 of the License, or (at your option) any later version.
9 | *
10 | * This library is distributed in the hope that it will be useful,
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 | * Lesser General Public License for more details.
14 | *
15 | * You should have received a copy of the GNU Lesser General Public
16 | * License along with this library; if not, write to the Free Software
17 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
18 | */
19 |
20 | package com.github.stephenc.javaisotools.sabre;
21 |
22 | import java.io.IOException;
23 | import java.io.InputStream;
24 |
25 | public interface DataReference {
26 |
27 | public long getLength();
28 |
29 | public InputStream createInputStream() throws IOException;
30 | }
31 |
--------------------------------------------------------------------------------
/sabre/src/main/java/com/github/stephenc/javaisotools/sabre/DataReferenceHelper.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2010. Stephen Connolly.
3 | * Copyright (c) 2006. Michael Hartle .
4 | *
5 | * This library is free software; you can redistribute it and/or
6 | * modify it under the terms of the GNU Lesser General Public
7 | * License as published by the Free Software Foundation; either
8 | * version 2.1 of the License, or (at your option) any later version.
9 | *
10 | * This library is distributed in the hope that it will be useful,
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 | * Lesser General Public License for more details.
14 | *
15 | * You should have received a copy of the GNU Lesser General Public
16 | * License along with this library; if not, write to the Free Software
17 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
18 | */
19 |
20 | package com.github.stephenc.javaisotools.sabre;
21 |
22 | import java.io.IOException;
23 | import java.io.InputStream;
24 | import java.io.OutputStream;
25 |
26 | public class DataReferenceHelper {
27 |
28 | public static void transfer(DataReference reference, OutputStream outputStream) throws IOException {
29 | InputStream inputStream = null;
30 | byte[] buffer = null;
31 | int bytesToRead = 0;
32 | int bytesHandled = 0;
33 | int bufferLength = 65535;
34 | long lengthToWrite = 0;
35 | long length = 0;
36 |
37 | buffer = new byte[bufferLength];
38 | length = reference.getLength();
39 | lengthToWrite = length;
40 | inputStream = reference.createInputStream();
41 | while (lengthToWrite > 0) {
42 | if (lengthToWrite > bufferLength) {
43 | bytesToRead = bufferLength;
44 | } else {
45 | bytesToRead = (int) lengthToWrite;
46 | }
47 |
48 | bytesHandled = inputStream.read(buffer, 0, bytesToRead);
49 |
50 | if (bytesHandled == -1) {
51 | throw new IOException();
52 | }
53 |
54 | outputStream.write(buffer, 0, bytesHandled);
55 | lengthToWrite -= bytesHandled;
56 | }
57 | outputStream.flush();
58 | }
59 | }
--------------------------------------------------------------------------------
/sabre/src/main/java/com/github/stephenc/javaisotools/sabre/Element.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2010. Stephen Connolly.
3 | * Copyright (c) 2006. Michael Hartle .
4 | *
5 | * This library is free software; you can redistribute it and/or
6 | * modify it under the terms of the GNU Lesser General Public
7 | * License as published by the Free Software Foundation; either
8 | * version 2.1 of the License, or (at your option) any later version.
9 | *
10 | * This library is distributed in the hope that it will be useful,
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 | * Lesser General Public License for more details.
14 | *
15 | * You should have received a copy of the GNU Lesser General Public
16 | * License along with this library; if not, write to the Free Software
17 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
18 | */
19 |
20 | package com.github.stephenc.javaisotools.sabre;
21 |
22 | public abstract class Element {
23 |
24 | public abstract Object getId();
25 | }
26 |
--------------------------------------------------------------------------------
/sabre/src/main/java/com/github/stephenc/javaisotools/sabre/Fixup.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2010. Stephen Connolly.
3 | * Copyright (c) 2006. Michael Hartle .
4 | *
5 | * This library is free software; you can redistribute it and/or
6 | * modify it under the terms of the GNU Lesser General Public
7 | * License as published by the Free Software Foundation; either
8 | * version 2.1 of the License, or (at your option) any later version.
9 | *
10 | * This library is distributed in the hope that it will be useful,
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 | * Lesser General Public License for more details.
14 | *
15 | * You should have received a copy of the GNU Lesser General Public
16 | * License along with this library; if not, write to the Free Software
17 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
18 | */
19 |
20 | package com.github.stephenc.javaisotools.sabre;
21 |
22 | public interface Fixup extends ContentHandler {
23 |
24 | public void close() throws HandlerException;
25 |
26 | public boolean isClosed();
27 | }
28 |
--------------------------------------------------------------------------------
/sabre/src/main/java/com/github/stephenc/javaisotools/sabre/FixupListener.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2010. Stephen Connolly.
3 | * Copyright (c) 2006. Michael Hartle .
4 | *
5 | * This library is free software; you can redistribute it and/or
6 | * modify it under the terms of the GNU Lesser General Public
7 | * License as published by the Free Software Foundation; either
8 | * version 2.1 of the License, or (at your option) any later version.
9 | *
10 | * This library is distributed in the hope that it will be useful,
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 | * Lesser General Public License for more details.
14 | *
15 | * You should have received a copy of the GNU Lesser General Public
16 | * License along with this library; if not, write to the Free Software
17 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
18 | */
19 |
20 | package com.github.stephenc.javaisotools.sabre;
21 |
22 | public interface FixupListener {
23 |
24 | public void fixupClosed(Fixup fixup);
25 | }
26 |
--------------------------------------------------------------------------------
/sabre/src/main/java/com/github/stephenc/javaisotools/sabre/HandlerException.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2010. Stephen Connolly.
3 | * Copyright (c) 2006. Michael Hartle .
4 | *
5 | * This library is free software; you can redistribute it and/or
6 | * modify it under the terms of the GNU Lesser General Public
7 | * License as published by the Free Software Foundation; either
8 | * version 2.1 of the License, or (at your option) any later version.
9 | *
10 | * This library is distributed in the hope that it will be useful,
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 | * Lesser General Public License for more details.
14 | *
15 | * You should have received a copy of the GNU Lesser General Public
16 | * License along with this library; if not, write to the Free Software
17 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
18 | */
19 |
20 | package com.github.stephenc.javaisotools.sabre;
21 |
22 | public class HandlerException extends Exception {
23 |
24 | private static final long serialVersionUID = -4027062370589486907L;
25 |
26 | public HandlerException(String message) {
27 | super(message);
28 | }
29 |
30 | public HandlerException(Exception e) {
31 | super(e);
32 | }
33 | }
34 |
--------------------------------------------------------------------------------
/sabre/src/main/java/com/github/stephenc/javaisotools/sabre/StreamHandler.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2010. Stephen Connolly.
3 | * Copyright (c) 2006. Michael Hartle .
4 | *
5 | * This library is free software; you can redistribute it and/or
6 | * modify it under the terms of the GNU Lesser General Public
7 | * License as published by the Free Software Foundation; either
8 | * version 2.1 of the License, or (at your option) any later version.
9 | *
10 | * This library is distributed in the hope that it will be useful,
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 | * Lesser General Public License for more details.
14 | *
15 | * You should have received a copy of the GNU Lesser General Public
16 | * License along with this library; if not, write to the Free Software
17 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
18 | */
19 |
20 | package com.github.stephenc.javaisotools.sabre;
21 |
22 | public interface StreamHandler extends StructureHandler, ContentHandler {
23 |
24 | }
25 |
--------------------------------------------------------------------------------
/sabre/src/main/java/com/github/stephenc/javaisotools/sabre/StructureHandler.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2010. Stephen Connolly.
3 | * Copyright (c) 2006. Michael Hartle .
4 | *
5 | * This library is free software; you can redistribute it and/or
6 | * modify it under the terms of the GNU Lesser General Public
7 | * License as published by the Free Software Foundation; either
8 | * version 2.1 of the License, or (at your option) any later version.
9 | *
10 | * This library is distributed in the hope that it will be useful,
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 | * Lesser General Public License for more details.
14 | *
15 | * You should have received a copy of the GNU Lesser General Public
16 | * License along with this library; if not, write to the Free Software
17 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
18 | */
19 |
20 | package com.github.stephenc.javaisotools.sabre;
21 |
22 | public interface StructureHandler {
23 |
24 | public void startDocument() throws HandlerException;
25 |
26 | public void startElement(Element element) throws HandlerException;
27 |
28 | public void endElement() throws HandlerException;
29 |
30 | public void endDocument() throws HandlerException;
31 | }
32 |
--------------------------------------------------------------------------------
/sabre/src/main/java/com/github/stephenc/javaisotools/sabre/VariableDataReference.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2010. Stephen Connolly.
3 | * Copyright (c) 2006. Michael Hartle .
4 | *
5 | * This library is free software; you can redistribute it and/or
6 | * modify it under the terms of the GNU Lesser General Public
7 | * License as published by the Free Software Foundation; either
8 | * version 2.1 of the License, or (at your option) any later version.
9 | *
10 | * This library is distributed in the hope that it will be useful,
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 | * Lesser General Public License for more details.
14 | *
15 | * You should have received a copy of the GNU Lesser General Public
16 | * License along with this library; if not, write to the Free Software
17 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
18 | */
19 |
20 | package com.github.stephenc.javaisotools.sabre;
21 |
22 | public interface VariableDataReference extends DataReference {
23 |
24 | public boolean isFixed();
25 | }
26 |
--------------------------------------------------------------------------------
/sabre/src/main/java/com/github/stephenc/javaisotools/sabre/impl/ByteArrayDataReference.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2010. Stephen Connolly.
3 | * Copyright (c) 2006. Michael Hartle .
4 | *
5 | * This library is free software; you can redistribute it and/or
6 | * modify it under the terms of the GNU Lesser General Public
7 | * License as published by the Free Software Foundation; either
8 | * version 2.1 of the License, or (at your option) any later version.
9 | *
10 | * This library is distributed in the hope that it will be useful,
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 | * Lesser General Public License for more details.
14 | *
15 | * You should have received a copy of the GNU Lesser General Public
16 | * License along with this library; if not, write to the Free Software
17 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
18 | */
19 |
20 | package com.github.stephenc.javaisotools.sabre.impl;
21 |
22 | import java.io.ByteArrayInputStream;
23 | import java.io.IOException;
24 | import java.io.InputStream;
25 |
26 | import com.github.stephenc.javaisotools.sabre.DataReference;
27 |
28 | public class ByteArrayDataReference implements DataReference {
29 |
30 | private byte[] buffer = null;
31 | private int start = 0;
32 | private int length = 0;
33 |
34 | public ByteArrayDataReference(byte[] buffer) {
35 | this.buffer = buffer;
36 | this.start = 0;
37 | this.length = this.buffer.length;
38 | }
39 |
40 | public ByteArrayDataReference(byte[] buffer, int start, int length) {
41 | this.buffer = buffer;
42 | this.start = start;
43 | this.length = length;
44 | }
45 |
46 | public long getLength() {
47 | return this.length;
48 | }
49 |
50 | public InputStream createInputStream() throws IOException {
51 | return new ByteArrayInputStream(this.buffer, this.start, this.length);
52 | }
53 |
54 | }
55 |
--------------------------------------------------------------------------------
/sabre/src/main/java/com/github/stephenc/javaisotools/sabre/impl/ByteDataReference.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2010. Stephen Connolly.
3 | * Copyright (c) 2006. Michael Hartle .
4 | *
5 | * This library is free software; you can redistribute it and/or
6 | * modify it under the terms of the GNU Lesser General Public
7 | * License as published by the Free Software Foundation; either
8 | * version 2.1 of the License, or (at your option) any later version.
9 | *
10 | * This library is distributed in the hope that it will be useful,
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 | * Lesser General Public License for more details.
14 | *
15 | * You should have received a copy of the GNU Lesser General Public
16 | * License along with this library; if not, write to the Free Software
17 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
18 | */
19 |
20 | package com.github.stephenc.javaisotools.sabre.impl;
21 |
22 | import java.io.ByteArrayInputStream;
23 | import java.io.IOException;
24 | import java.io.InputStream;
25 |
26 | import com.github.stephenc.javaisotools.sabre.DataReference;
27 |
28 | public class ByteDataReference implements DataReference {
29 |
30 | private long value = 0;
31 |
32 | public ByteDataReference(long value) {
33 | this.value = value;
34 | }
35 |
36 | public long getLength() {
37 | // TODO Auto-generated method stub
38 | return 1;
39 | }
40 |
41 | public InputStream createInputStream() throws IOException {
42 | byte[] buffer = null;
43 |
44 | buffer = new byte[1];
45 | buffer[0] = (byte) (this.value & 0xFF);
46 | return new ByteArrayInputStream(buffer);
47 | }
48 | }
49 |
--------------------------------------------------------------------------------
/sabre/src/main/java/com/github/stephenc/javaisotools/sabre/impl/DWordDataReference.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2010. Stephen Connolly.
3 | * Copyright (c) 2006. Michael Hartle .
4 | *
5 | * This library is free software; you can redistribute it and/or
6 | * modify it under the terms of the GNU Lesser General Public
7 | * License as published by the Free Software Foundation; either
8 | * version 2.1 of the License, or (at your option) any later version.
9 | *
10 | * This library is distributed in the hope that it will be useful,
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 | * Lesser General Public License for more details.
14 | *
15 | * You should have received a copy of the GNU Lesser General Public
16 | * License along with this library; if not, write to the Free Software
17 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
18 | */
19 |
20 | package com.github.stephenc.javaisotools.sabre.impl;
21 |
22 | import java.io.ByteArrayInputStream;
23 | import java.io.IOException;
24 | import java.io.InputStream;
25 |
26 | import com.github.stephenc.javaisotools.sabre.DataReference;
27 |
28 | public class DWordDataReference implements DataReference {
29 |
30 | private long value = 0;
31 |
32 | public DWordDataReference(long value) {
33 | this.value = value;
34 | }
35 |
36 | public long getLength() {
37 | return 8;
38 | }
39 |
40 | public InputStream createInputStream() throws IOException {
41 | byte[] buffer = null;
42 |
43 | buffer = new byte[8];
44 | buffer[0] = (byte) ((this.value & 0xFF00000000000000L) >> 56);
45 | buffer[1] = (byte) ((this.value & 0x00FF000000000000L) >> 48);
46 | buffer[2] = (byte) ((this.value & 0x0000FF0000000000L) >> 40);
47 | buffer[3] = (byte) ((this.value & 0x000000FF00000000L) >> 32);
48 | buffer[4] = (byte) ((this.value & 0x00000000FF000000L) >> 24);
49 | buffer[5] = (byte) ((this.value & 0x0000000000FF0000L) >> 16);
50 | buffer[6] = (byte) ((this.value & 0x000000000000FF00L) >> 8);
51 | buffer[7] = (byte) ((this.value & 0x00000000000000FFL));
52 |
53 | return new ByteArrayInputStream(buffer);
54 | }
55 | }
56 |
--------------------------------------------------------------------------------
/sabre/src/main/java/com/github/stephenc/javaisotools/sabre/impl/FileDataReference.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2010. Stephen Connolly.
3 | * Copyright (c) 2006. Michael Hartle .
4 | *
5 | * This library is free software; you can redistribute it and/or
6 | * modify it under the terms of the GNU Lesser General Public
7 | * License as published by the Free Software Foundation; either
8 | * version 2.1 of the License, or (at your option) any later version.
9 | *
10 | * This library is distributed in the hope that it will be useful,
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 | * Lesser General Public License for more details.
14 | *
15 | * You should have received a copy of the GNU Lesser General Public
16 | * License along with this library; if not, write to the Free Software
17 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
18 | */
19 |
20 | package com.github.stephenc.javaisotools.sabre.impl;
21 |
22 | import java.io.BufferedInputStream;
23 | import java.io.File;
24 | import java.io.FileInputStream;
25 | import java.io.IOException;
26 | import java.io.InputStream;
27 |
28 | import com.github.stephenc.javaisotools.sabre.DataReference;
29 | import com.github.stephenc.javaisotools.sabre.io.LimitingInputStream;
30 |
31 | public class FileDataReference implements DataReference {
32 |
33 | private File file = null;
34 | private long position = 0;
35 | private long length = 0;
36 |
37 | public FileDataReference(File file) {
38 | this.file = file;
39 | this.position = 0;
40 | this.length = -1;
41 | }
42 |
43 | public FileDataReference(File file, int position, int length) {
44 | this.file = file;
45 | this.position = position;
46 | this.length = length;
47 | }
48 |
49 | public long getLength() {
50 | long length = 0;
51 |
52 | if (this.length == -1) {
53 | length = this.file.length();
54 | } else {
55 | length = this.length;
56 | }
57 |
58 | return length;
59 | }
60 |
61 | public InputStream createInputStream() throws IOException {
62 | InputStream fileInputStream = null;
63 |
64 | fileInputStream = new FileInputStream(file);
65 |
66 | // Reposition input stream, if necessary
67 | if (this.position > 0) {
68 | long skipped = 0;
69 | // System.out.print("Skipping to " + position + "/" + this.file.length() + " ");
70 | while (skipped != this.position) {
71 | skipped = fileInputStream.skip(this.position - skipped);
72 | }
73 | }
74 |
75 | // Limit input stream, if necessary
76 | if (this.length != -1) {
77 | // System.out.println("Limiting to " + this.length + " ");
78 | fileInputStream = new LimitingInputStream(fileInputStream, (int) this.length);
79 | }
80 |
81 | // System.out.println();
82 |
83 | // Buffer input stream
84 | fileInputStream = new BufferedInputStream(fileInputStream);
85 |
86 | return fileInputStream;
87 | }
88 |
89 | }
90 |
--------------------------------------------------------------------------------
/sabre/src/main/java/com/github/stephenc/javaisotools/sabre/impl/IntegerArrayDataReference.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2010. Stephen Connolly.
3 | * Copyright (c) 2006. Michael Hartle .
4 | *
5 | * This library is free software; you can redistribute it and/or
6 | * modify it under the terms of the GNU Lesser General Public
7 | * License as published by the Free Software Foundation; either
8 | * version 2.1 of the License, or (at your option) any later version.
9 | *
10 | * This library is distributed in the hope that it will be useful,
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 | * Lesser General Public License for more details.
14 | *
15 | * You should have received a copy of the GNU Lesser General Public
16 | * License along with this library; if not, write to the Free Software
17 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
18 | */
19 |
20 | package com.github.stephenc.javaisotools.sabre.impl;
21 |
22 | import java.io.ByteArrayInputStream;
23 | import java.io.IOException;
24 | import java.io.InputStream;
25 |
26 | import com.github.stephenc.javaisotools.sabre.DataReference;
27 |
28 | public class IntegerArrayDataReference implements DataReference {
29 |
30 | private byte[] buffer = null;
31 |
32 | public IntegerArrayDataReference(int[] buffer) {
33 | this.buffer = new byte[buffer.length];
34 | for (int i = 0; i < buffer.length; i++) {
35 | this.buffer[i] = (byte) buffer[i];
36 | }
37 | }
38 |
39 | public long getLength() {
40 | return this.buffer.length;
41 | }
42 |
43 | public InputStream createInputStream() throws IOException {
44 | return new ByteArrayInputStream(this.buffer);
45 | }
46 | }
47 |
--------------------------------------------------------------------------------
/sabre/src/main/java/com/github/stephenc/javaisotools/sabre/impl/LongElement.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2010. Stephen Connolly.
3 | * Copyright (c) 2006. Michael Hartle .
4 | *
5 | * This library is free software; you can redistribute it and/or
6 | * modify it under the terms of the GNU Lesser General Public
7 | * License as published by the Free Software Foundation; either
8 | * version 2.1 of the License, or (at your option) any later version.
9 | *
10 | * This library is distributed in the hope that it will be useful,
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 | * Lesser General Public License for more details.
14 | *
15 | * You should have received a copy of the GNU Lesser General Public
16 | * License along with this library; if not, write to the Free Software
17 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
18 | */
19 |
20 | package com.github.stephenc.javaisotools.sabre.impl;
21 |
22 | import com.github.stephenc.javaisotools.sabre.Element;
23 |
24 | public class LongElement extends Element {
25 |
26 | private long id = 0;
27 |
28 | public LongElement(long id) {
29 | this.id = id;
30 | }
31 |
32 | public Object getId() {
33 | return new Long(id);
34 | }
35 |
36 | public String toString() {
37 | String result = null;
38 |
39 | result = new String();
40 | result += (char) ((id & 0xFF000000) >> 24);
41 | result += (char) ((id & 0x00FF0000) >> 16);
42 | result += (char) ((id & 0x0000FF00) >> 8);
43 | result += (char) ((id & 0x000000FF));
44 |
45 | return result;
46 | }
47 | }
48 |
--------------------------------------------------------------------------------
/sabre/src/main/java/com/github/stephenc/javaisotools/sabre/impl/ShortDataReference.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2010. Stephen Connolly.
3 | * Copyright (c) 2006. Michael Hartle .
4 | *
5 | * This library is free software; you can redistribute it and/or
6 | * modify it under the terms of the GNU Lesser General Public
7 | * License as published by the Free Software Foundation; either
8 | * version 2.1 of the License, or (at your option) any later version.
9 | *
10 | * This library is distributed in the hope that it will be useful,
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 | * Lesser General Public License for more details.
14 | *
15 | * You should have received a copy of the GNU Lesser General Public
16 | * License along with this library; if not, write to the Free Software
17 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
18 | */
19 |
20 | package com.github.stephenc.javaisotools.sabre.impl;
21 |
22 | import java.io.ByteArrayInputStream;
23 | import java.io.IOException;
24 | import java.io.InputStream;
25 |
26 | import com.github.stephenc.javaisotools.sabre.DataReference;
27 |
28 | public class ShortDataReference implements DataReference {
29 |
30 | private long value = 0;
31 |
32 | public ShortDataReference(long value) {
33 | this.value = value;
34 | }
35 |
36 | public long getLength() {
37 | // TODO Auto-generated method stub
38 | return 2;
39 | }
40 |
41 | public InputStream createInputStream() throws IOException {
42 | byte[] buffer = null;
43 |
44 | buffer = new byte[2];
45 | buffer[0] = (byte) ((this.value & 0xFF00) >> 8);
46 | buffer[1] = (byte) (this.value & 0x00FF);
47 |
48 | return new ByteArrayInputStream(buffer);
49 | }
50 | }
51 |
--------------------------------------------------------------------------------
/sabre/src/main/java/com/github/stephenc/javaisotools/sabre/impl/ThreeByteDataReference.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2010. Stephen Connolly.
3 | * Copyright (c) 2006. Michael Hartle .
4 | *
5 | * This library is free software; you can redistribute it and/or
6 | * modify it under the terms of the GNU Lesser General Public
7 | * License as published by the Free Software Foundation; either
8 | * version 2.1 of the License, or (at your option) any later version.
9 | *
10 | * This library is distributed in the hope that it will be useful,
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 | * Lesser General Public License for more details.
14 | *
15 | * You should have received a copy of the GNU Lesser General Public
16 | * License along with this library; if not, write to the Free Software
17 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
18 | */
19 |
20 | package com.github.stephenc.javaisotools.sabre.impl;
21 |
22 | import java.io.ByteArrayInputStream;
23 | import java.io.IOException;
24 | import java.io.InputStream;
25 |
26 | import com.github.stephenc.javaisotools.sabre.DataReference;
27 |
28 | public class ThreeByteDataReference implements DataReference {
29 |
30 | private long value = 0;
31 |
32 | public ThreeByteDataReference(long value) {
33 | this.value = value;
34 | }
35 |
36 | public long getLength() {
37 | // TODO Auto-generated method stub
38 | return 3;
39 | }
40 |
41 | public InputStream createInputStream() throws IOException {
42 | byte[] buffer = null;
43 |
44 | buffer = new byte[3];
45 | buffer[0] = (byte) ((this.value & 0xFF0000) >> 16);
46 | buffer[1] = (byte) ((this.value & 0x00FF00) >> 8);
47 | buffer[2] = (byte) (this.value & 0x0000FF);
48 | return new ByteArrayInputStream(buffer);
49 | }
50 |
51 | }
52 |
--------------------------------------------------------------------------------
/sabre/src/main/java/com/github/stephenc/javaisotools/sabre/impl/URLDataReference.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2010. Stephen Connolly.
3 | * Copyright (c) 2006. Michael Hartle .
4 | *
5 | * This library is free software; you can redistribute it and/or
6 | * modify it under the terms of the GNU Lesser General Public
7 | * License as published by the Free Software Foundation; either
8 | * version 2.1 of the License, or (at your option) any later version.
9 | *
10 | * This library is distributed in the hope that it will be useful,
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 | * Lesser General Public License for more details.
14 | *
15 | * You should have received a copy of the GNU Lesser General Public
16 | * License along with this library; if not, write to the Free Software
17 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
18 | */
19 |
20 | package com.github.stephenc.javaisotools.sabre.impl;
21 |
22 | import java.io.IOException;
23 | import java.io.InputStream;
24 | import java.net.URL;
25 |
26 | import com.github.stephenc.javaisotools.sabre.io.LimitingInputStream;
27 | import com.github.stephenc.javaisotools.sabre.DataReference;
28 |
29 | public class URLDataReference implements DataReference {
30 |
31 | private URL url = null;
32 | private long position = 0;
33 | private long length = 0;
34 |
35 | public URLDataReference(URL url, long position, long length) {
36 | this.url = url;
37 | this.position = position;
38 | this.length = length;
39 | }
40 |
41 | public long getLength() {
42 | return this.length;
43 | }
44 |
45 | public InputStream createInputStream() throws IOException {
46 | InputStream urlInputStream = null;
47 | InputStream limitedInputStream = null;
48 |
49 | urlInputStream = this.url.openStream();
50 | urlInputStream.skip(this.position);
51 | limitedInputStream = new LimitingInputStream(urlInputStream, (int) this.length);
52 |
53 | return limitedInputStream;
54 | }
55 | }
56 |
--------------------------------------------------------------------------------
/sabre/src/main/java/com/github/stephenc/javaisotools/sabre/impl/WordDataReference.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2010. Stephen Connolly.
3 | * Copyright (c) 2006. Michael Hartle .
4 | *
5 | * This library is free software; you can redistribute it and/or
6 | * modify it under the terms of the GNU Lesser General Public
7 | * License as published by the Free Software Foundation; either
8 | * version 2.1 of the License, or (at your option) any later version.
9 | *
10 | * This library is distributed in the hope that it will be useful,
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 | * Lesser General Public License for more details.
14 | *
15 | * You should have received a copy of the GNU Lesser General Public
16 | * License along with this library; if not, write to the Free Software
17 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
18 | */
19 |
20 | package com.github.stephenc.javaisotools.sabre.impl;
21 |
22 | import java.io.ByteArrayInputStream;
23 | import java.io.IOException;
24 | import java.io.InputStream;
25 |
26 | import com.github.stephenc.javaisotools.sabre.DataReference;
27 |
28 | public class WordDataReference implements DataReference {
29 |
30 | private long value = 0;
31 |
32 | public WordDataReference(long value) {
33 | this.value = value;
34 | }
35 |
36 | public long getLength() {
37 | return 4;
38 | }
39 |
40 | public InputStream createInputStream() throws IOException {
41 | byte[] buffer = null;
42 |
43 | buffer = new byte[4];
44 | buffer[0] = (byte) ((this.value & 0xFF000000) >> 24);
45 | buffer[1] = (byte) ((this.value & 0x00FF0000) >> 16);
46 | buffer[2] = (byte) ((this.value & 0x0000FF00) >> 8);
47 | buffer[3] = (byte) (this.value & 0x000000FF);
48 |
49 | return new ByteArrayInputStream(buffer);
50 | }
51 | }
52 |
--------------------------------------------------------------------------------
/sabre/src/main/java/com/github/stephenc/javaisotools/udflib/SabreUDFElement.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2010. Stephen Connolly.
3 | * Copyright (c) 2006. Björn Stickler .
4 | *
5 | * This library is free software; you can redistribute it and/or
6 | * modify it under the terms of the GNU Lesser General Public
7 | * License as published by the Free Software Foundation; either
8 | * version 2.1 of the License, or (at your option) any later version.
9 | *
10 | * This library is distributed in the hope that it will be useful,
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 | * Lesser General Public License for more details.
14 | *
15 | * You should have received a copy of the GNU Lesser General Public
16 | * License along with this library; if not, write to the Free Software
17 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
18 | */
19 |
20 | package com.github.stephenc.javaisotools.udflib;
21 |
22 | import com.github.stephenc.javaisotools.sabre.Element;
23 |
24 | public class SabreUDFElement extends Element {
25 |
26 | private UDFElementType udfElementType;
27 |
28 | public enum UDFElementType {
29 |
30 | EmptyArea,
31 | ReservedArea,
32 | VolumeRecognitionSequence,
33 | AnchorVolumeDescriptorPointer,
34 | PrimaryVolumeDescriptor,
35 | LogicalVolumeDescriptor,
36 | PartitionDescriptor,
37 | ImplementationUseVolumeDescriptor,
38 | UnallocatedSpaceDescriptor,
39 | TerminatingDescriptor,
40 | FileSetDescriptor,
41 | LogicalVolumeIntegrityDescriptor,
42 | FileEntry,
43 | RawFileData,
44 | MetadataFile,
45 |
46 | DescriptorTag // not used on "frontend"
47 | }
48 |
49 | public SabreUDFElement(UDFElementType udfElementType) {
50 | this.udfElementType = udfElementType;
51 | }
52 |
53 | public Object getId() {
54 | return udfElementType;
55 | }
56 |
57 | }
58 |
--------------------------------------------------------------------------------
/sabre/src/main/java/com/github/stephenc/javaisotools/udflib/UDFRevision.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2010. Stephen Connolly.
3 | * Copyright (c) 2006. Björn Stickler .
4 | *
5 | * This library is free software; you can redistribute it and/or
6 | * modify it under the terms of the GNU Lesser General Public
7 | * License as published by the Free Software Foundation; either
8 | * version 2.1 of the License, or (at your option) any later version.
9 | *
10 | * This library is distributed in the hope that it will be useful,
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 | * Lesser General Public License for more details.
14 | *
15 | * You should have received a copy of the GNU Lesser General Public
16 | * License along with this library; if not, write to the Free Software
17 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
18 | */
19 |
20 | package com.github.stephenc.javaisotools.udflib;
21 |
22 | public enum UDFRevision {
23 |
24 | Revision102,
25 | Revision201,
26 | Revision260
27 | }
28 |
--------------------------------------------------------------------------------
/sabre/src/main/java/com/github/stephenc/javaisotools/udflib/UDFTest.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2010. Stephen Connolly.
3 | * Copyright (c) 2006. Björn Stickler .
4 | *
5 | * This library is free software; you can redistribute it and/or
6 | * modify it under the terms of the GNU Lesser General Public
7 | * License as published by the Free Software Foundation; either
8 | * version 2.1 of the License, or (at your option) any later version.
9 | *
10 | * This library is distributed in the hope that it will be useful,
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 | * Lesser General Public License for more details.
14 | *
15 | * You should have received a copy of the GNU Lesser General Public
16 | * License along with this library; if not, write to the Free Software
17 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
18 | */
19 |
20 | package com.github.stephenc.javaisotools.udflib;
21 |
22 | import java.io.File;
23 | import java.util.Calendar;
24 |
25 | public class UDFTest {
26 |
27 | private void testUDFImageBuilder() {
28 | try {
29 | UDFImageBuilder myUDFImageBuilder = new UDFImageBuilder();
30 |
31 | File testFile = new File("C:\\Program Files (x86)\\Microsoft Visual Studio 8");
32 | File testChildFiles[] = testFile.listFiles();
33 | for (int i = 0; i < testChildFiles.length; ++i) {
34 | myUDFImageBuilder.addFileToRootDirectory(testChildFiles[i]);
35 | }
36 |
37 | myUDFImageBuilder.setImageIdentifier("Test-Disc");
38 |
39 | myUDFImageBuilder.writeImage("c:\\temp\\test-disc.iso", UDFRevision.Revision201);
40 | }
41 | catch (Exception myException) {
42 | System.out.println(myException.toString());
43 | myException.printStackTrace();
44 | }
45 | }
46 |
47 | public void testSabreUDFImageBuilder() {
48 | try {
49 | SabreUDFImageBuilder mySabreUDF = new SabreUDFImageBuilder();
50 |
51 | File testFile = new File("C:\\Program Files (x86)\\Microsoft Visual Studio 8");
52 | File testChildFiles[] = testFile.listFiles();
53 | for (int i = 0; i < testChildFiles.length; ++i) {
54 | mySabreUDF.addFileToRootDirectory(testChildFiles[i]);
55 | }
56 |
57 | mySabreUDF.setImageIdentifier("Test-Disc");
58 |
59 | mySabreUDF.writeImage("c:\\temp\\test-disc.iso", UDFRevision.Revision201);
60 | }
61 | catch (Exception myException) {
62 | System.out.println(myException.toString());
63 | myException.printStackTrace();
64 | }
65 | }
66 |
67 | public UDFTest() {
68 | System.out.println("UDFTest\n");
69 |
70 | long startTime = Calendar.getInstance().getTimeInMillis();
71 |
72 | //testUDFImageBuilder();
73 | testSabreUDFImageBuilder();
74 |
75 | System.out.println("Run-Time: " + (Calendar.getInstance().getTimeInMillis() - startTime) + " Milliseconds");
76 | }
77 |
78 | public static void main(String[] args) {
79 | new UDFTest();
80 | }
81 |
82 | }
83 |
--------------------------------------------------------------------------------
/sabre/src/main/java/com/github/stephenc/javaisotools/udflib/handler/PaddingHandler.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2010. Stephen Connolly.
3 | * Copyright (c) 2006. Björn Stickler .
4 | *
5 | * This library is free software; you can redistribute it and/or
6 | * modify it under the terms of the GNU Lesser General Public
7 | * License as published by the Free Software Foundation; either
8 | * version 2.1 of the License, or (at your option) any later version.
9 | *
10 | * This library is distributed in the hope that it will be useful,
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 | * Lesser General Public License for more details.
14 | *
15 | * You should have received a copy of the GNU Lesser General Public
16 | * License along with this library; if not, write to the Free Software
17 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
18 | */
19 |
20 | package com.github.stephenc.javaisotools.udflib.handler;
21 |
22 | import com.github.stephenc.javaisotools.sabre.ContentHandler;
23 | import com.github.stephenc.javaisotools.sabre.impl.ChainingStreamHandler;
24 | import com.github.stephenc.javaisotools.sabre.DataReference;
25 | import com.github.stephenc.javaisotools.sabre.HandlerException;
26 | import com.github.stephenc.javaisotools.sabre.StructureHandler;
27 | import com.github.stephenc.javaisotools.sabre.impl.ByteArrayDataReference;
28 |
29 | public class PaddingHandler extends ChainingStreamHandler {
30 |
31 | private int blockSize = 2048;
32 | private long currentPosition = 0;
33 |
34 | public PaddingHandler(StructureHandler myStructureHandler, ContentHandler myContentHandler) {
35 | super(myStructureHandler, myContentHandler);
36 | }
37 |
38 | public void setBlockSize(int blockSize) {
39 | this.blockSize = blockSize;
40 | }
41 |
42 | public void data(DataReference myDataReference)
43 | throws HandlerException {
44 | currentPosition += myDataReference.getLength();
45 |
46 | super.data(myDataReference);
47 | }
48 |
49 | public void endElement()
50 | throws HandlerException {
51 | if (currentPosition % blockSize != 0) {
52 | int paddingLength = blockSize - (int) (currentPosition % blockSize);
53 | super.data(new ByteArrayDataReference(new byte[paddingLength]));
54 |
55 | currentPosition += paddingLength;
56 | }
57 |
58 | super.endElement();
59 | }
60 |
61 | }
62 |
--------------------------------------------------------------------------------
/sabre/src/main/java/com/github/stephenc/javaisotools/udflib/structures/CharSpec.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2010. Stephen Connolly.
3 | * Copyright (c) 2006. Björn Stickler .
4 | *
5 | * This library is free software; you can redistribute it and/or
6 | * modify it under the terms of the GNU Lesser General Public
7 | * License as published by the Free Software Foundation; either
8 | * version 2.1 of the License, or (at your option) any later version.
9 | *
10 | * This library is distributed in the hope that it will be useful,
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 | * Lesser General Public License for more details.
14 | *
15 | * You should have received a copy of the GNU Lesser General Public
16 | * License along with this library; if not, write to the Free Software
17 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
18 | */
19 |
20 | package com.github.stephenc.javaisotools.udflib.structures;
21 |
22 | import java.io.IOException;
23 | import java.io.RandomAccessFile;
24 |
25 | public class CharSpec {
26 |
27 | public byte CharacterSetType; // Uint8
28 | public byte CharacterSetInfo[]; // byte[63]
29 |
30 | public CharSpec() {
31 | CharacterSetType = 0;
32 | CharacterSetInfo = new byte[63];
33 |
34 | CharacterSetInfo[0] = 'O';
35 | CharacterSetInfo[1] = 'S';
36 | CharacterSetInfo[2] = 'T';
37 | CharacterSetInfo[3] = 'A';
38 | CharacterSetInfo[4] = ' ';
39 | CharacterSetInfo[5] = 'C';
40 | CharacterSetInfo[6] = 'o';
41 | CharacterSetInfo[7] = 'm';
42 | CharacterSetInfo[8] = 'p';
43 | CharacterSetInfo[9] = 'r';
44 | CharacterSetInfo[10] = 'e';
45 | CharacterSetInfo[11] = 's';
46 | CharacterSetInfo[12] = 's';
47 | CharacterSetInfo[13] = 'e';
48 | CharacterSetInfo[14] = 'd';
49 | CharacterSetInfo[15] = ' ';
50 | CharacterSetInfo[16] = 'U';
51 | CharacterSetInfo[17] = 'n';
52 | CharacterSetInfo[18] = 'i';
53 | CharacterSetInfo[19] = 'c';
54 | CharacterSetInfo[20] = 'o';
55 | CharacterSetInfo[21] = 'd';
56 | CharacterSetInfo[22] = 'e';
57 | }
58 |
59 | public void read(RandomAccessFile myRandomAccessFile)
60 | throws IOException {
61 | CharacterSetType = myRandomAccessFile.readByte();
62 |
63 | CharacterSetInfo = new byte[63];
64 | myRandomAccessFile.read(CharacterSetInfo);
65 | }
66 |
67 | public void write(RandomAccessFile myRandomAccessFile)
68 | throws IOException {
69 | myRandomAccessFile.write(getBytes());
70 | }
71 |
72 | public byte[] getBytes() {
73 | byte rawBytes[] = new byte[64];
74 |
75 | rawBytes[0] = CharacterSetType;
76 | System.arraycopy(CharacterSetInfo, 0, rawBytes, 1, CharacterSetInfo.length);
77 |
78 | return rawBytes;
79 | }
80 | }
81 |
--------------------------------------------------------------------------------
/sabre/src/main/java/com/github/stephenc/javaisotools/udflib/structures/EntityID.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2010. Stephen Connolly.
3 | * Copyright (c) 2006. Björn Stickler .
4 | *
5 | * This library is free software; you can redistribute it and/or
6 | * modify it under the terms of the GNU Lesser General Public
7 | * License as published by the Free Software Foundation; either
8 | * version 2.1 of the License, or (at your option) any later version.
9 | *
10 | * This library is distributed in the hope that it will be useful,
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 | * Lesser General Public License for more details.
14 | *
15 | * You should have received a copy of the GNU Lesser General Public
16 | * License along with this library; if not, write to the Free Software
17 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
18 | */
19 |
20 | package com.github.stephenc.javaisotools.udflib.structures;
21 |
22 | import java.io.IOException;
23 | import java.io.RandomAccessFile;
24 |
25 | public class EntityID {
26 |
27 | public byte Flags; // Uint8
28 | public byte Identifier[]; // char[23]
29 | public byte IdentifierSuffix[]; // char[8]
30 |
31 | public EntityID() {
32 | Identifier = new byte[23];
33 | IdentifierSuffix = new byte[8];
34 | }
35 |
36 | public void setIdentifier(String identifier)
37 | throws Exception {
38 | if (identifier.length() > 23) {
39 | throw new Exception("error: identifier length exceeds maximum length of 23 characters");
40 | }
41 |
42 | Identifier = new byte[23];
43 |
44 | for (int i = 0; i < identifier.length() && i < 23; ++i) {
45 | Identifier[i] = (byte) identifier.charAt(i);
46 | }
47 | }
48 |
49 | public void read(RandomAccessFile myRandomAccessFile)
50 | throws IOException {
51 | Flags = myRandomAccessFile.readByte();
52 |
53 | Identifier = new byte[23];
54 | myRandomAccessFile.read(Identifier);
55 |
56 | IdentifierSuffix = new byte[8];
57 | myRandomAccessFile.read(IdentifierSuffix);
58 | }
59 |
60 | public void write(RandomAccessFile myRandomAccessFile)
61 | throws IOException {
62 | myRandomAccessFile.write(getBytes());
63 | }
64 |
65 | public byte[] getBytes() {
66 | byte rawBytes[] = new byte[32];
67 |
68 | rawBytes[0] = Flags;
69 | System.arraycopy(Identifier, 0, rawBytes, 1, Identifier.length);
70 | System.arraycopy(IdentifierSuffix, 0, rawBytes, Identifier.length + 1, IdentifierSuffix.length);
71 |
72 | return rawBytes;
73 | }
74 |
75 | }
76 |
--------------------------------------------------------------------------------
/sabre/src/main/java/com/github/stephenc/javaisotools/udflib/structures/Extend_ad.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2010. Stephen Connolly.
3 | * Copyright (c) 2006. Björn Stickler .
4 | *
5 | * This library is free software; you can redistribute it and/or
6 | * modify it under the terms of the GNU Lesser General Public
7 | * License as published by the Free Software Foundation; either
8 | * version 2.1 of the License, or (at your option) any later version.
9 | *
10 | * This library is distributed in the hope that it will be useful,
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 | * Lesser General Public License for more details.
14 | *
15 | * You should have received a copy of the GNU Lesser General Public
16 | * License along with this library; if not, write to the Free Software
17 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
18 | */
19 |
20 | package com.github.stephenc.javaisotools.udflib.structures;
21 |
22 | import java.io.IOException;
23 | import java.io.RandomAccessFile;
24 |
25 | import com.github.stephenc.javaisotools.udflib.tools.BinaryTools;
26 |
27 | public class Extend_ad {
28 |
29 | public long len; // Uint32
30 | public long loc; // Uint32
31 |
32 | public void read(RandomAccessFile myRandomAccessFile)
33 | throws IOException {
34 | len = BinaryTools.readUInt32AsLong(myRandomAccessFile);
35 | loc = BinaryTools.readUInt32AsLong(myRandomAccessFile);
36 | }
37 |
38 | public void write(RandomAccessFile myRandomAccessFile)
39 | throws IOException {
40 | myRandomAccessFile.write(getBytes());
41 | }
42 |
43 | public byte[] getBytes() {
44 | byte rawBytes[] = new byte[8];
45 |
46 | int pos = 0;
47 |
48 | pos = BinaryTools.getUInt32BytesFromLong(len, rawBytes, pos);
49 | pos = BinaryTools.getUInt32BytesFromLong(loc, rawBytes, pos);
50 |
51 | return rawBytes;
52 | }
53 | }
54 |
--------------------------------------------------------------------------------
/sabre/src/main/java/com/github/stephenc/javaisotools/udflib/structures/Lb_addr.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2010. Stephen Connolly.
3 | * Copyright (c) 2006. Björn Stickler .
4 | *
5 | * This library is free software; you can redistribute it and/or
6 | * modify it under the terms of the GNU Lesser General Public
7 | * License as published by the Free Software Foundation; either
8 | * version 2.1 of the License, or (at your option) any later version.
9 | *
10 | * This library is distributed in the hope that it will be useful,
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 | * Lesser General Public License for more details.
14 | *
15 | * You should have received a copy of the GNU Lesser General Public
16 | * License along with this library; if not, write to the Free Software
17 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
18 | */
19 |
20 | package com.github.stephenc.javaisotools.udflib.structures;
21 |
22 | import java.io.IOException;
23 | import java.io.RandomAccessFile;
24 |
25 | import com.github.stephenc.javaisotools.udflib.tools.BinaryTools;
26 |
27 | public class Lb_addr {
28 |
29 | public long lb_num; // Uint32
30 | public int part_num; // Uint16
31 |
32 | public void read(RandomAccessFile myRandomAccessFile)
33 | throws IOException {
34 | lb_num = myRandomAccessFile.readUnsignedByte() + myRandomAccessFile.readUnsignedByte() * 256 +
35 | myRandomAccessFile.readUnsignedByte() * 256 * 256 +
36 | (int) myRandomAccessFile.readUnsignedByte() * 256 * 256 * 256;
37 | part_num = myRandomAccessFile.readUnsignedByte() + myRandomAccessFile.readUnsignedByte() * 256;
38 | }
39 |
40 | public int read(byte[] rawBytes, int startPosition) {
41 | int position = startPosition;
42 |
43 | lb_num = (rawBytes[position++] & 0xFF)
44 | + (rawBytes[position++] & 0xFF) * 256
45 | + (rawBytes[position++] & 0xFF) * 256 * 256
46 | + (rawBytes[position++] & 0xFF) * 256 * 256 * 256;
47 |
48 | part_num = (rawBytes[position++] & 0xFF) + (rawBytes[position++] & 0xFF) * 256;
49 |
50 | return position;
51 | }
52 |
53 | public void write(RandomAccessFile myRandomAccessFile)
54 | throws IOException {
55 | byte rawBytes[] = getBytes();
56 | myRandomAccessFile.write(rawBytes);
57 | }
58 |
59 | public byte[] getBytes() {
60 | byte rawBytes[] = new byte[6];
61 |
62 | int pos = 0;
63 |
64 | pos = BinaryTools.getUInt32BytesFromLong(lb_num, rawBytes, pos);
65 | pos = BinaryTools.getUInt16BytesFromInt(part_num, rawBytes, pos);
66 |
67 | return rawBytes;
68 | }
69 | }
70 |
--------------------------------------------------------------------------------
/sabre/src/main/java/com/github/stephenc/javaisotools/udflib/structures/LogicalVolumeHeaderDescriptor.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2010. Stephen Connolly.
3 | * Copyright (c) 2006. Björn Stickler .
4 | *
5 | * This library is free software; you can redistribute it and/or
6 | * modify it under the terms of the GNU Lesser General Public
7 | * License as published by the Free Software Foundation; either
8 | * version 2.1 of the License, or (at your option) any later version.
9 | *
10 | * This library is distributed in the hope that it will be useful,
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 | * Lesser General Public License for more details.
14 | *
15 | * You should have received a copy of the GNU Lesser General Public
16 | * License along with this library; if not, write to the Free Software
17 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
18 | */
19 |
20 | package com.github.stephenc.javaisotools.udflib.structures;
21 |
22 | import java.io.IOException;
23 | import java.io.RandomAccessFile;
24 |
25 | import com.github.stephenc.javaisotools.udflib.tools.BinaryTools;
26 |
27 | public class LogicalVolumeHeaderDescriptor {
28 |
29 | public long UniqueID; // Uint64 !
30 | public byte Reserved[]; // byte[24]
31 |
32 | public LogicalVolumeHeaderDescriptor() {
33 | Reserved = new byte[24];
34 | }
35 |
36 | public void read(RandomAccessFile myRandomAccessFile)
37 | throws IOException {
38 | UniqueID = BinaryTools.readUInt64AsLong(myRandomAccessFile);
39 |
40 | Reserved = new byte[24];
41 | myRandomAccessFile.read(Reserved);
42 | }
43 |
44 | public void write(RandomAccessFile myRandomAccessFile)
45 | throws IOException {
46 | byte[] rawBytes = getBytes();
47 | myRandomAccessFile.write(rawBytes);
48 | }
49 |
50 | public byte[] getBytes() {
51 | byte[] rawBytes = new byte[8 + Reserved.length];
52 |
53 | int pos = 0;
54 |
55 | pos = BinaryTools.getUInt64BytesFromLong(UniqueID, rawBytes, pos);
56 |
57 | System.arraycopy(Reserved, 0, rawBytes, pos, Reserved.length);
58 | pos += Reserved.length;
59 |
60 | return rawBytes;
61 | }
62 | }
63 |
--------------------------------------------------------------------------------
/sabre/src/main/java/com/github/stephenc/javaisotools/udflib/structures/PartitionMapType1.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2010. Stephen Connolly.
3 | * Copyright (c) 2006. Björn Stickler .
4 | *
5 | * This library is free software; you can redistribute it and/or
6 | * modify it under the terms of the GNU Lesser General Public
7 | * License as published by the Free Software Foundation; either
8 | * version 2.1 of the License, or (at your option) any later version.
9 | *
10 | * This library is distributed in the hope that it will be useful,
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 | * Lesser General Public License for more details.
14 | *
15 | * You should have received a copy of the GNU Lesser General Public
16 | * License along with this library; if not, write to the Free Software
17 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
18 | */
19 |
20 | package com.github.stephenc.javaisotools.udflib.structures;
21 |
22 | import java.io.IOException;
23 | import java.io.RandomAccessFile;
24 |
25 | import com.github.stephenc.javaisotools.udflib.tools.BinaryTools;
26 |
27 | public class PartitionMapType1 {
28 |
29 | public byte PartitionMapType; // Uint8
30 | public byte PartitionMapLength; // Uint8
31 | public int VolumeSequenceNumber; // Uint16
32 | public int PartitionNumber; // Uint16
33 |
34 | public PartitionMapType1() {
35 | PartitionMapType = 1;
36 | PartitionMapLength = 6;
37 | VolumeSequenceNumber = 1;
38 | PartitionNumber = 0;
39 | }
40 |
41 | public void read(RandomAccessFile myRandomAccessFile)
42 | throws IOException {
43 | PartitionMapType = myRandomAccessFile.readByte();
44 | PartitionMapLength = myRandomAccessFile.readByte();
45 | VolumeSequenceNumber = BinaryTools.readUInt16AsInt(myRandomAccessFile);
46 | PartitionNumber = BinaryTools.readUInt16AsInt(myRandomAccessFile);
47 | }
48 |
49 | public void write(RandomAccessFile myRandomAccessFile)
50 | throws IOException {
51 | myRandomAccessFile.write(getBytes());
52 | }
53 |
54 | public byte[] getBytes() {
55 | byte rawBytes[] = new byte[6];
56 |
57 | int pos = 0;
58 |
59 | rawBytes[pos++] = PartitionMapType;
60 | rawBytes[pos++] = PartitionMapLength;
61 |
62 | pos = BinaryTools.getUInt16BytesFromInt(VolumeSequenceNumber, rawBytes, pos);
63 | BinaryTools.getUInt16BytesFromInt(PartitionNumber, rawBytes, pos);
64 |
65 | return rawBytes;
66 | }
67 |
68 | }
69 |
--------------------------------------------------------------------------------
/sabre/src/main/java/com/github/stephenc/javaisotools/udflib/structures/ReservedArea.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2010. Stephen Connolly.
3 | * Copyright (c) 2006. Björn Stickler .
4 | *
5 | * This library is free software; you can redistribute it and/or
6 | * modify it under the terms of the GNU Lesser General Public
7 | * License as published by the Free Software Foundation; either
8 | * version 2.1 of the License, or (at your option) any later version.
9 | *
10 | * This library is distributed in the hope that it will be useful,
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 | * Lesser General Public License for more details.
14 | *
15 | * You should have received a copy of the GNU Lesser General Public
16 | * License along with this library; if not, write to the Free Software
17 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
18 | */
19 |
20 | package com.github.stephenc.javaisotools.udflib.structures;
21 |
22 | import java.io.IOException;
23 | import java.io.RandomAccessFile;
24 |
25 | public class ReservedArea {
26 |
27 | public static boolean check(RandomAccessFile myRandomAccessFile)
28 | throws IOException {
29 | byte buffer[] = new byte[16 * 2048];
30 |
31 | myRandomAccessFile.read(buffer);
32 |
33 | for (int i = 0; i < buffer.length; ++i) {
34 | if (buffer[i] != 0x00) {
35 | return false;
36 | }
37 | }
38 |
39 | return true;
40 | }
41 |
42 | public static void write(RandomAccessFile myRandomAccessFile)
43 | throws IOException {
44 | byte buffer[] = new byte[16 * 2048];
45 |
46 | myRandomAccessFile.write(buffer);
47 | }
48 | }
49 |
--------------------------------------------------------------------------------
/sabre/src/main/java/com/github/stephenc/javaisotools/udflib/structures/Short_ad.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2010. Stephen Connolly.
3 | * Copyright (c) 2006. Björn Stickler .
4 | *
5 | * This library is free software; you can redistribute it and/or
6 | * modify it under the terms of the GNU Lesser General Public
7 | * License as published by the Free Software Foundation; either
8 | * version 2.1 of the License, or (at your option) any later version.
9 | *
10 | * This library is distributed in the hope that it will be useful,
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 | * Lesser General Public License for more details.
14 | *
15 | * You should have received a copy of the GNU Lesser General Public
16 | * License along with this library; if not, write to the Free Software
17 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
18 | */
19 |
20 | package com.github.stephenc.javaisotools.udflib.structures;
21 |
22 | import java.io.IOException;
23 | import java.io.RandomAccessFile;
24 |
25 | import com.github.stephenc.javaisotools.udflib.tools.BinaryTools;
26 |
27 | public class Short_ad {
28 |
29 | public long ExtentLength; // Uint32
30 | public long ExtentPosition; // Uint32
31 |
32 | public void read(RandomAccessFile myRandomAccessFile)
33 | throws IOException {
34 | ExtentLength = BinaryTools.readUInt32AsLong(myRandomAccessFile);
35 | ExtentPosition = BinaryTools.readUInt32AsLong(myRandomAccessFile);
36 | }
37 |
38 | public byte[] getBytes() {
39 | byte[] rawBytes = new byte[8];
40 |
41 | int pos = 0;
42 |
43 | pos = BinaryTools.getUInt32BytesFromLong(ExtentLength, rawBytes, pos);
44 | pos = BinaryTools.getUInt32BytesFromLong(ExtentPosition, rawBytes, pos);
45 |
46 | return rawBytes;
47 | }
48 | }
49 |
--------------------------------------------------------------------------------
/sabre/src/main/java/com/github/stephenc/javaisotools/udflib/structures/UnallocatedSpaceDescriptor.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2010. Stephen Connolly.
3 | * Copyright (c) 2006. Björn Stickler .
4 | *
5 | * This library is free software; you can redistribute it and/or
6 | * modify it under the terms of the GNU Lesser General Public
7 | * License as published by the Free Software Foundation; either
8 | * version 2.1 of the License, or (at your option) any later version.
9 | *
10 | * This library is distributed in the hope that it will be useful,
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 | * Lesser General Public License for more details.
14 | *
15 | * You should have received a copy of the GNU Lesser General Public
16 | * License along with this library; if not, write to the Free Software
17 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
18 | */
19 |
20 | package com.github.stephenc.javaisotools.udflib.structures;
21 |
22 | import java.io.IOException;
23 | import java.io.RandomAccessFile;
24 |
25 | import com.github.stephenc.javaisotools.udflib.tools.BinaryTools;
26 |
27 | public class UnallocatedSpaceDescriptor extends VolumeDescriptorSequenceItem {
28 |
29 | public long NumberofAllocationDescriptors; // Uint32
30 | public Extend_ad AllocationDescriptors[]; // struct extend_ad[]
31 |
32 | public UnallocatedSpaceDescriptor() {
33 | DescriptorTag = new Tag();
34 | DescriptorTag.TagIdentifier = 7;
35 |
36 | AllocationDescriptors = new Extend_ad[0];
37 | }
38 |
39 | public void read(RandomAccessFile myRandomAccessFile)
40 | throws IOException {
41 | DescriptorTag = new Tag();
42 | DescriptorTag.read(myRandomAccessFile);
43 |
44 | VolumeDescriptorSequenceNumber = BinaryTools.readUInt32AsLong(myRandomAccessFile);
45 | NumberofAllocationDescriptors = BinaryTools.readUInt32AsLong(myRandomAccessFile);
46 |
47 | AllocationDescriptors = new Extend_ad[(int) NumberofAllocationDescriptors];
48 |
49 | for (int i = 0; i < NumberofAllocationDescriptors; ++i) {
50 | AllocationDescriptors[i] = new Extend_ad();
51 | AllocationDescriptors[i].read(myRandomAccessFile);
52 | }
53 | }
54 |
55 | public byte[] getBytesWithoutDescriptorTag() {
56 | byte rawBytes[] = new byte[8 + (int) NumberofAllocationDescriptors * 8];
57 |
58 | int pos = 0;
59 |
60 | pos = BinaryTools.getUInt32BytesFromLong(VolumeDescriptorSequenceNumber, rawBytes, pos);
61 | pos = BinaryTools.getUInt32BytesFromLong(NumberofAllocationDescriptors, rawBytes, pos);
62 |
63 | for (int i = 0; i < AllocationDescriptors.length; ++i) {
64 | byte allocationDescriptorBytes[] = AllocationDescriptors[i].getBytes();
65 | System.arraycopy(allocationDescriptorBytes, 0, rawBytes, pos, allocationDescriptorBytes.length);
66 | pos += allocationDescriptorBytes.length;
67 | }
68 |
69 | return rawBytes;
70 | }
71 | }
72 |
--------------------------------------------------------------------------------
/sabre/src/main/java/com/github/stephenc/javaisotools/udflib/structures/VolumeStructureDescriptor.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2010. Stephen Connolly.
3 | * Copyright (c) 2006. Björn Stickler .
4 | *
5 | * This library is free software; you can redistribute it and/or
6 | * modify it under the terms of the GNU Lesser General Public
7 | * License as published by the Free Software Foundation; either
8 | * version 2.1 of the License, or (at your option) any later version.
9 | *
10 | * This library is distributed in the hope that it will be useful,
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 | * Lesser General Public License for more details.
14 | *
15 | * You should have received a copy of the GNU Lesser General Public
16 | * License along with this library; if not, write to the Free Software
17 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
18 | */
19 |
20 | package com.github.stephenc.javaisotools.udflib.structures;
21 |
22 | import java.io.IOException;
23 | import java.io.RandomAccessFile;
24 |
25 | public class VolumeStructureDescriptor {
26 |
27 | public byte StructureType; // Uint8
28 | public byte StandardIdentifier[]; // byte[5]
29 | public byte StructureVersion; // Uint8
30 | public byte StructureData[]; // byte[2041]
31 |
32 | public VolumeStructureDescriptor() {
33 | StandardIdentifier = new byte[5];
34 | StructureData = new byte[2041];
35 | }
36 |
37 | public void read(RandomAccessFile myRandomAccessFile)
38 | throws IOException {
39 | StructureType = myRandomAccessFile.readByte();
40 |
41 | StandardIdentifier = new byte[5];
42 | myRandomAccessFile.read(StandardIdentifier);
43 |
44 | StructureVersion = myRandomAccessFile.readByte();
45 |
46 | StructureData = new byte[2041];
47 | myRandomAccessFile.read(StructureData);
48 | }
49 |
50 | public void write(RandomAccessFile myRandomAccessFile)
51 | throws IOException {
52 | myRandomAccessFile.writeByte(StructureType);
53 | myRandomAccessFile.write(StandardIdentifier);
54 | myRandomAccessFile.writeByte(StructureVersion);
55 | myRandomAccessFile.write(StructureData);
56 | }
57 |
58 | public byte[] getBytes() {
59 | byte[] rawBytes = new byte[2048];
60 |
61 | int pos = 0;
62 |
63 | rawBytes[pos++] = StructureType;
64 |
65 | System.arraycopy(StandardIdentifier, 0, rawBytes, pos, StandardIdentifier.length);
66 | pos += StandardIdentifier.length;
67 |
68 | rawBytes[pos++] = StructureVersion;
69 |
70 | System.arraycopy(StructureData, 0, rawBytes, pos, StructureData.length);
71 | pos += StructureData.length;
72 |
73 | return rawBytes;
74 | }
75 | }
76 |
--------------------------------------------------------------------------------
/sabre/src/main/java/com/github/stephenc/javaisotools/udflib/tools/OSTAIdentifierTranslation.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2010. Stephen Connolly.
3 | * Copyright (c) 2006. Björn Stickler .
4 | *
5 | * This library is free software; you can redistribute it and/or
6 | * modify it under the terms of the GNU Lesser General Public
7 | * License as published by the Free Software Foundation; either
8 | * version 2.1 of the License, or (at your option) any later version.
9 | *
10 | * This library is distributed in the hope that it will be useful,
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 | * Lesser General Public License for more details.
14 | *
15 | * You should have received a copy of the GNU Lesser General Public
16 | * License along with this library; if not, write to the Free Software
17 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
18 | */
19 |
20 | package com.github.stephenc.javaisotools.udflib.tools;
21 |
22 | public class OSTAIdentifierTranslation {
23 | // TODO
24 | }
25 |
--------------------------------------------------------------------------------
/sabre/src/main/java/com/github/stephenc/javaisotools/udflib/tools/OSTAUnicode.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2010. Stephen Connolly.
3 | * Copyright (c) 2006. Björn Stickler .
4 | *
5 | * This library is free software; you can redistribute it and/or
6 | * modify it under the terms of the GNU Lesser General Public
7 | * License as published by the Free Software Foundation; either
8 | * version 2.1 of the License, or (at your option) any later version.
9 | *
10 | * This library is distributed in the hope that it will be useful,
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 | * Lesser General Public License for more details.
14 | *
15 | * You should have received a copy of the GNU Lesser General Public
16 | * License along with this library; if not, write to the Free Software
17 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
18 | */
19 |
20 | package com.github.stephenc.javaisotools.udflib.tools;
21 |
22 | public class OSTAUnicode {
23 |
24 | public static byte[] UncompressUnicodeByte(byte UDFCompressed[]) {
25 | byte unicode[] = new byte[0];
26 |
27 | int compId = UDFCompressed[0];
28 |
29 | if (compId == 16) {
30 | unicode = new byte[UDFCompressed.length - 1];
31 |
32 | System.arraycopy(UDFCompressed, 1, unicode, 0, UDFCompressed.length - 1);
33 | } else if (compId == 8) {
34 | unicode = new byte[(UDFCompressed.length - 1) * 2];
35 |
36 | for (int i = 0; i < (UDFCompressed.length - 1); ++i) {
37 | unicode[i * 2] = 0;
38 | unicode[i * 2 + 1] = UDFCompressed[i + 1];
39 | }
40 | }
41 |
42 | return unicode;
43 | }
44 |
45 | public static byte[] CompressUnicodeByte(byte utf16[], int compId) {
46 | // skip 2 byte java utf-16 heading bytes
47 | byte unicode[] = new byte[utf16.length - 2];
48 | System.arraycopy(utf16, 2, unicode, 0, unicode.length);
49 |
50 | byte UDFCompressed[] = new byte[0];
51 |
52 | if (utf16.length == 0) {
53 | return UDFCompressed;
54 | }
55 |
56 | if (compId == 8) {
57 | UDFCompressed = new byte[unicode.length / 2 + 1];
58 |
59 | UDFCompressed[0] = 8;
60 |
61 | for (int i = 0; i < unicode.length / 2; ++i) {
62 | UDFCompressed[i + 1] = unicode[i * 2 + 1];
63 | }
64 | } else if (compId == 16) {
65 | UDFCompressed = new byte[unicode.length + 1];
66 |
67 | UDFCompressed[0] = 8;
68 |
69 | System.arraycopy(unicode, 0, UDFCompressed, 1, unicode.length);
70 | }
71 |
72 | return UDFCompressed;
73 | }
74 |
75 | public static int getBestCompressionId(byte utf16[]) {
76 | // skip 2 byte java utf-16 heading bytes
77 | for (int i = 2; i < utf16.length; i += 2) {
78 | if (utf16[i] != (byte) 0x00) {
79 | return 16;
80 | }
81 | }
82 | return 8;
83 | }
84 | }
85 |
--------------------------------------------------------------------------------
/sabre/src/main/java/com/github/stephenc/javaisotools/udflib/tools/Permissions.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2010. Stephen Connolly.
3 | * Copyright (c) 2006. Björn Stickler .
4 | *
5 | * This library is free software; you can redistribute it and/or
6 | * modify it under the terms of the GNU Lesser General Public
7 | * License as published by the Free Software Foundation; either
8 | * version 2.1 of the License, or (at your option) any later version.
9 | *
10 | * This library is distributed in the hope that it will be useful,
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 | * Lesser General Public License for more details.
14 | *
15 | * You should have received a copy of the GNU Lesser General Public
16 | * License along with this library; if not, write to the Free Software
17 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
18 | */
19 |
20 | package com.github.stephenc.javaisotools.udflib.tools;
21 |
22 | public class Permissions {
23 |
24 | public static int OTHER_Execute = 0x00000001;
25 | public static int OTHER_Write = 0x00000002;
26 | public static int OTHER_Read = 0x00000004;
27 | public static int OTHER_ChAttr = 0x00000008;
28 | public static int OTHER_Delete = 0x00000010;
29 |
30 | public static int GROUP_Execute = 0x00000020;
31 | public static int GROUP_Write = 0x00000040;
32 | public static int GROUP_Read = 0x00000080;
33 | public static int GROUP_ChAttr = 0x00000100;
34 | public static int GROUP_Delete = 0x00000200;
35 |
36 | public static int OWNER_Execute = 0x00000400;
37 | public static int OWNER_Write = 0x00000800;
38 | public static int OWNER_Read = 0x00001000;
39 | public static int OWNER_ChAttr = 0x00002000;
40 | public static int OWNER_Delete = 0x00004000;
41 |
42 | }
43 |
--------------------------------------------------------------------------------
/sabre/src/main/java/com/github/stephenc/javaisotools/udflib/tools/UniqueIdDisposer.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2010. Stephen Connolly.
3 | * Copyright (c) 2006. Björn Stickler .
4 | *
5 | * This library is free software; you can redistribute it and/or
6 | * modify it under the terms of the GNU Lesser General Public
7 | * License as published by the Free Software Foundation; either
8 | * version 2.1 of the License, or (at your option) any later version.
9 | *
10 | * This library is distributed in the hope that it will be useful,
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 | * Lesser General Public License for more details.
14 | *
15 | * You should have received a copy of the GNU Lesser General Public
16 | * License along with this library; if not, write to the Free Software
17 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
18 | */
19 |
20 | package com.github.stephenc.javaisotools.udflib.tools;
21 |
22 | public class UniqueIdDisposer {
23 |
24 | private long currentUniqueId;
25 |
26 | public UniqueIdDisposer() {
27 | currentUniqueId = 15;
28 | }
29 |
30 | public long getNextUniqueId() {
31 | currentUniqueId++;
32 |
33 | if ((currentUniqueId & 0xFFFFFFFF) == 0) {
34 | currentUniqueId |= 0x00000010;
35 | }
36 |
37 | return currentUniqueId;
38 | }
39 |
40 | }
41 |
--------------------------------------------------------------------------------