Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
Checked out from CVS
- Loading branch information
0 parents
commit 86df383
Showing
180 changed files
with
5,210 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,2 @@ | |||
loopy is based on the file system code from JNode (www.jnode.org). Thanks to the JNode developers for doing a lot of | |||
hard work :) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,4 @@ | |||
/CREDITS.txt/1.2/Wed Jul 4 02:35:23 2007// | |||
/LICENSE.txt/1.2/Wed Jul 4 02:35:23 2007// | |||
/pom.xml/1.3/Wed Jul 4 18:48:42 2007// | |||
D |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1 @@ | |||
A D/src//// |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1 @@ | |||
loopy/loopy-core |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1 @@ | |||
:pserver:anonymous@loopy.cvs.sourceforge.net:/cvsroot/loopy |
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,37 @@ | |||
<?xml version="1.0"?> | |||
<project xmlns="http://maven.apache.org/POM/4.0.0" | |||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | |||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> | |||
<modelVersion>4.0.0</modelVersion> | |||
<name>loopy-core</name> | |||
<description>loopy core library.</description> | |||
|
|||
<parent> | |||
<groupId>net.didion.loopy</groupId> | |||
<artifactId>loopy</artifactId> | |||
<version>0.3</version> | |||
</parent> | |||
|
|||
<artifactId>loopy-core</artifactId> | |||
|
|||
<dependencies> | |||
<dependency> | |||
<groupId>commons-logging</groupId> | |||
<artifactId>commons-logging</artifactId> | |||
</dependency> | |||
</dependencies> | |||
|
|||
<build> | |||
<plugins> | |||
<plugin> | |||
<groupId>org.apache.maven.plugins</groupId> | |||
<artifactId>maven-compiler-plugin</artifactId> | |||
<configuration> | |||
<excludes> | |||
<exclude>net/didion/loopy/udf/*.*</exclude> | |||
</excludes> | |||
</configuration> | |||
</plugin> | |||
</plugins> | |||
</build> | |||
</project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1 @@ | |||
D/main//// |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1 @@ | |||
loopy/loopy-core/src |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1 @@ | |||
:pserver:anonymous@loopy.cvs.sourceforge.net:/cvsroot/loopy |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1 @@ | |||
D/java//// |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1 @@ | |||
loopy/loopy-core/src/main |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1 @@ | |||
:pserver:anonymous@loopy.cvs.sourceforge.net:/cvsroot/loopy |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1 @@ | |||
D |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1 @@ | |||
A D/net//// |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1 @@ | |||
loopy/loopy-core/src/main/java |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1 @@ | |||
:pserver:anonymous@loopy.cvs.sourceforge.net:/cvsroot/loopy |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1 @@ | |||
D/didion//// |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1 @@ | |||
loopy/loopy-core/src/main/java/net |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1 @@ | |||
:pserver:anonymous@loopy.cvs.sourceforge.net:/cvsroot/loopy |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1 @@ | |||
D/loopy//// |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1 @@ | |||
loopy/loopy-core/src/main/java/net/didion |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1 @@ | |||
:pserver:anonymous@loopy.cvs.sourceforge.net:/cvsroot/loopy |
135 changes: 135 additions & 0 deletions
135
loopy-core/src/main/java/net/didion/loopy/AbstractBlockFileSystem.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,135 @@ | |||
/* | |||
Copyright (C) 2006-2007 loopy project (http://loopy.sourceforge.net) | |||
This library is free software; you can redistribute it and/or | |||
modify it under the terms of the GNU Lesser General Public | |||
License as published by the Free Software Foundation; either | |||
version 2.1 of the License, or (at your option) any later version. | |||
This library is distributed in the hope that it will be useful, | |||
but WITHOUT ANY WARRANTY; without even the implied warranty of | |||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |||
Lesser General Public License for more details. | |||
You should have received a copy of the GNU Lesser General Public | |||
License along with this library; if not, write to the Free Software | |||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA | |||
*/ | |||
package net.didion.loopy; | |||
|
|||
import java.io.File; | |||
import java.io.IOException; | |||
import java.util.Enumeration; | |||
|
|||
/** | |||
* A block file system is segmented into multiple fixed-size blocks. It consists of a set of volume | |||
* descriptors followed by an index, which points to the file locations. | |||
*/ | |||
public abstract class AbstractBlockFileSystem extends AbstractFileSystem { | |||
private final int blockSize; | |||
private final int reservedBlocks; | |||
private VolumeDescriptorSet volumeDescriptorSet; | |||
|
|||
protected AbstractBlockFileSystem(final File file, final boolean readOnly, final int blockSize, | |||
final int reservedBlocks) | |||
throws IOException { | |||
super(file, readOnly); | |||
|
|||
if (blockSize <= 0) { | |||
throw new IllegalArgumentException("'blockSize' must be > 0"); | |||
} | |||
if (reservedBlocks < 0) { | |||
throw new IllegalArgumentException("'reservedBlocks' must be >= 0"); | |||
} | |||
|
|||
this.blockSize = blockSize; | |||
this.reservedBlocks = reservedBlocks; | |||
} | |||
|
|||
public Enumeration getEntries() { | |||
ensureOpen(); | |||
|
|||
// load the volume descriptors if necessary | |||
if (null == this.volumeDescriptorSet) { | |||
try { | |||
loadVolumeDescriptors(); | |||
} | |||
catch (IOException ex) { | |||
throw new RuntimeException(ex); | |||
} | |||
} | |||
|
|||
return enumerate(this.volumeDescriptorSet.getRootEntry()); | |||
} | |||
|
|||
protected void loadVolumeDescriptors() throws IOException { | |||
final byte[] buffer = new byte[this.blockSize]; | |||
|
|||
this.volumeDescriptorSet = createVolumeDescriptorSet(); | |||
|
|||
// skip the reserved blocks, then read volume descriptor blocks sequentially and add them | |||
// to the VolumeDescriptorSet | |||
for (int block = this.reservedBlocks; | |||
readBlock(block, buffer) && !this.volumeDescriptorSet.deserialize(buffer); | |||
block++); | |||
} | |||
|
|||
/** | |||
* Read the data for the specified block into the specified buffer. | |||
* | |||
* @param block | |||
* @param buffer | |||
* @return if the block was actually read | |||
* @throws IOException if the number of bytes read into the buffer was less than the expected | |||
* number (i.e. the block size) | |||
*/ | |||
protected boolean readBlock(final long block, final byte[] buffer) throws IOException { | |||
final int bytesRead = readData(block * this.blockSize, buffer, 0, this.blockSize); | |||
|
|||
if (bytesRead <= 0) { | |||
return false; | |||
} | |||
|
|||
if (this.blockSize != bytesRead) { | |||
throw new IOException("Could not deserialize a complete block"); | |||
} | |||
|
|||
return true; | |||
} | |||
|
|||
/** | |||
* Read file data, starting at the specified position. | |||
* | |||
* @param startPos | |||
* @param buffer | |||
* @param offset | |||
* @param len | |||
* @return the number of bytes read into the buffer | |||
* @throws IOException | |||
*/ | |||
protected synchronized int readData(final long startPos, final byte[] buffer, final int offset, | |||
final int len) | |||
throws IOException { | |||
seek(startPos); | |||
return read(buffer, offset, len); | |||
} | |||
|
|||
protected VolumeDescriptorSet getVolumeDescriptorSet() { | |||
return this.volumeDescriptorSet; | |||
} | |||
|
|||
/** | |||
* Returns an enumeration of the file entries starting at <code>root</code>. | |||
* | |||
* @param root | |||
* @return | |||
*/ | |||
protected abstract Enumeration enumerate(FileEntry root); | |||
|
|||
/** | |||
* Creates the VolumeDescriptorSet that deserializes volume descriptors for this file system. | |||
* | |||
* @return | |||
*/ | |||
protected abstract VolumeDescriptorSet createVolumeDescriptorSet(); | |||
} |
103 changes: 103 additions & 0 deletions
103
loopy-core/src/main/java/net/didion/loopy/AbstractFileSystem.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,103 @@ | |||
/* | |||
Copyright (C) 2006-2007 loopy project (http://loopy.sourceforge.net) | |||
This library is free software; you can redistribute it and/or | |||
modify it under the terms of the GNU Lesser General Public | |||
License as published by the Free Software Foundation; either | |||
version 2.1 of the License, or (at your option) any later version. | |||
This library is distributed in the hope that it will be useful, | |||
but WITHOUT ANY WARRANTY; without even the implied warranty of | |||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |||
Lesser General Public License for more details. | |||
You should have received a copy of the GNU Lesser General Public | |||
License along with this library; if not, write to the Free Software | |||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA | |||
*/ | |||
package net.didion.loopy; | |||
|
|||
import java.io.RandomAccessFile; | |||
import java.io.File; | |||
import java.io.IOException; | |||
import java.io.FileNotFoundException; | |||
|
|||
/** | |||
* Implementation of FileSystem that is backed by a {@link RandomAccessFile}. | |||
*/ | |||
public abstract class AbstractFileSystem implements FileSystem { | |||
/** | |||
* Channel to the open file. | |||
*/ | |||
private RandomAccessFile channel; | |||
|
|||
protected AbstractFileSystem(final File file, final boolean readOnly) throws IOException { | |||
if (!readOnly) { | |||
throw new IllegalArgumentException("Currrently, only read-only is supported"); | |||
} | |||
|
|||
// check that the underlying file is valid | |||
if (!file.exists()) { | |||
throw new FileNotFoundException("File does not exist: " + file); | |||
} | |||
|
|||
// open the channel | |||
this.channel = new RandomAccessFile(file, "r"); | |||
} | |||
|
|||
// TODO: close open streams automatically | |||
public synchronized void close() throws IOException { | |||
if (isClosed()) { | |||
return; | |||
} | |||
|
|||
try { | |||
this.channel.close(); | |||
} | |||
finally { | |||
this.channel = null; | |||
} | |||
} | |||
|
|||
public boolean isClosed() { | |||
return (null == this.channel); | |||
} | |||
|
|||
/** | |||
* Throws an exception if the underlying file is closed. | |||
* | |||
* @throws IllegalStateException | |||
*/ | |||
protected void ensureOpen() throws IllegalStateException { | |||
if (isClosed()) { | |||
throw new IllegalStateException("File has been closed"); | |||
} | |||
} | |||
|
|||
/** | |||
* Moves the pointer in the underlying file to the specified position. | |||
* | |||
* @param pos | |||
* @throws IOException | |||
*/ | |||
protected void seek(long pos) throws IOException { | |||
ensureOpen(); | |||
this.channel.seek(pos); | |||
} | |||
|
|||
/** | |||
* Reads up to <code>length</code> bytes into the specified buffer, starting at the specified | |||
* offset. The actual number of bytes read will be less than <code>length</code> if there are | |||
* not enough available bytes to read, or if the buffer is not large enough. | |||
* | |||
* @param buffer | |||
* @param offset | |||
* @param length | |||
* @return the number of bytes read into the buffer | |||
* @throws IOException | |||
*/ | |||
protected int read(byte[] buffer, int offset, int length) throws IOException { | |||
ensureOpen(); | |||
return this.channel.read(buffer, offset, length); | |||
} | |||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,7 @@ | |||
/AbstractBlockFileSystem.java/1.2/Wed Jul 4 18:48:43 2007// | |||
/AbstractFileSystem.java/1.2/Wed Jul 4 18:48:43 2007// | |||
/FileEntry.java/1.2/Wed Jul 4 02:35:23 2007// | |||
/FileSystem.java/1.2/Wed Jul 4 02:35:23 2007// | |||
/LoopyException.java/1.3/Wed Jul 4 18:48:43 2007// | |||
/VolumeDescriptorSet.java/1.1/Wed Jul 4 02:35:23 2007// | |||
D |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,4 @@ | |||
A D/impl//// | |||
A D/iso9660//// | |||
A D/udf//// | |||
A D/util//// |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1 @@ | |||
loopy/loopy-core/src/main/java/net/didion/loopy |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1 @@ | |||
:pserver:anonymous@loopy.cvs.sourceforge.net:/cvsroot/loopy |
Oops, something went wrong.