From: <ls...@us...> - 2008-08-26 18:28:44
|
Revision: 4512 http://jnode.svn.sourceforge.net/jnode/?rev=4512&view=rev Author: lsantha Date: 2008-08-26 18:28:40 +0000 (Tue, 26 Aug 2008) Log Message: ----------- Throwing ReadOnlyFileSystemExcpetion in directory modification operations on read-only file systems. Modified Paths: -------------- trunk/fs/src/fs/org/jnode/fs/ReadOnlyFileSystemException.java trunk/fs/src/fs/org/jnode/fs/ftpfs/FTPFSDirectory.java trunk/fs/src/fs/org/jnode/fs/hfsplus/HFSPlusDirectory.java trunk/fs/src/fs/org/jnode/fs/iso9660/ISO9660Directory.java trunk/fs/src/fs/org/jnode/fs/jifs/JIFSDirectory.java trunk/fs/src/fs/org/jnode/fs/jifs/JIFileSystem.java trunk/fs/src/fs/org/jnode/fs/ntfs/NTFSDirectory.java trunk/fs/src/fs/org/jnode/fs/spi/AbstractFSDirectory.java Modified: trunk/fs/src/fs/org/jnode/fs/ReadOnlyFileSystemException.java =================================================================== --- trunk/fs/src/fs/org/jnode/fs/ReadOnlyFileSystemException.java 2008-08-26 18:15:18 UTC (rev 4511) +++ trunk/fs/src/fs/org/jnode/fs/ReadOnlyFileSystemException.java 2008-08-26 18:28:40 UTC (rev 4512) @@ -29,7 +29,10 @@ * New exception allowing to handle cases where a FileSystem is mounted readOnly */ public class ReadOnlyFileSystemException extends IOException { - + + public ReadOnlyFileSystemException() { + super("read-only file system"); + } /** * @param message * @param cause Modified: trunk/fs/src/fs/org/jnode/fs/ftpfs/FTPFSDirectory.java =================================================================== --- trunk/fs/src/fs/org/jnode/fs/ftpfs/FTPFSDirectory.java 2008-08-26 18:15:18 UTC (rev 4511) +++ trunk/fs/src/fs/org/jnode/fs/ftpfs/FTPFSDirectory.java 2008-08-26 18:28:40 UTC (rev 4512) @@ -22,6 +22,7 @@ package org.jnode.fs.ftpfs; import org.jnode.fs.FSDirectory; +import org.jnode.fs.ReadOnlyFileSystemException; import java.io.IOException; import java.util.HashMap; @@ -100,8 +101,7 @@ * @throws java.io.IOException */ public FTPFSEntry addDirectory(String name) throws IOException { - // TODO implement this - return null; + throw new ReadOnlyFileSystemException(); } /** @@ -111,8 +111,7 @@ * @throws java.io.IOException */ public FTPFSEntry addFile(String name) throws IOException { - // TODO implement this - return null; + throw new ReadOnlyFileSystemException(); } /** @@ -121,7 +120,7 @@ * @throws java.io.IOException */ public void flush() throws IOException { - // TODO implement me + //nothing to do } /** @@ -131,6 +130,6 @@ * @throws java.io.IOException */ public void remove(String name) throws IOException { - // TODO implement this + throw new ReadOnlyFileSystemException(); } } Modified: trunk/fs/src/fs/org/jnode/fs/hfsplus/HFSPlusDirectory.java =================================================================== --- trunk/fs/src/fs/org/jnode/fs/hfsplus/HFSPlusDirectory.java 2008-08-26 18:15:18 UTC (rev 4511) +++ trunk/fs/src/fs/org/jnode/fs/hfsplus/HFSPlusDirectory.java 2008-08-26 18:28:40 UTC (rev 4512) @@ -6,6 +6,7 @@ import org.apache.log4j.Logger; import org.jnode.fs.FSEntry; +import org.jnode.fs.ReadOnlyFileSystemException; import org.jnode.fs.hfsplus.catalog.CatalogFolder; import org.jnode.fs.hfsplus.catalog.CatalogKey; import org.jnode.fs.hfsplus.tree.LeafRecord; @@ -31,16 +32,18 @@ @Override protected final FSEntry createDirectoryEntry(final String name) throws IOException { - // TODO Auto-generated method stub - return null; + throw new ReadOnlyFileSystemException(); } @Override protected final FSEntry createFileEntry(final String name) throws IOException { - // TODO Auto-generated method stub - return null; + throw new ReadOnlyFileSystemException(); } + public synchronized void remove(String name) throws IOException { + throw new ReadOnlyFileSystemException(); + } + @Override protected final FSEntryTable readEntries() throws IOException { List<FSEntry> pathList = new LinkedList<FSEntry>(); Modified: trunk/fs/src/fs/org/jnode/fs/iso9660/ISO9660Directory.java =================================================================== --- trunk/fs/src/fs/org/jnode/fs/iso9660/ISO9660Directory.java 2008-08-26 18:15:18 UTC (rev 4511) +++ trunk/fs/src/fs/org/jnode/fs/iso9660/ISO9660Directory.java 2008-08-26 18:28:40 UTC (rev 4512) @@ -27,6 +27,7 @@ import org.jnode.fs.FSDirectory; import org.jnode.fs.FSEntry; import org.jnode.fs.FileSystem; +import org.jnode.fs.ReadOnlyFileSystemException; import org.jnode.util.LittleEndian; /** @@ -93,21 +94,21 @@ * @see org.jnode.fs.FSDirectory#addFile(java.lang.String) */ public FSEntry addFile(String name) throws IOException { - throw new UnsupportedOperationException("Not yet implemented"); + throw new ReadOnlyFileSystemException(); } /** * @see org.jnode.fs.FSDirectory#addDirectory(java.lang.String) */ public FSEntry addDirectory(String name) throws IOException { - throw new UnsupportedOperationException("Not yet implemented"); + throw new ReadOnlyFileSystemException(); } /** * @see org.jnode.fs.FSDirectory#remove(java.lang.String) */ public void remove(String name) throws IOException { - throw new UnsupportedOperationException("Not yet implemented"); + throw new ReadOnlyFileSystemException(); } /** Modified: trunk/fs/src/fs/org/jnode/fs/jifs/JIFSDirectory.java =================================================================== --- trunk/fs/src/fs/org/jnode/fs/jifs/JIFSDirectory.java 2008-08-26 18:15:18 UTC (rev 4511) +++ trunk/fs/src/fs/org/jnode/fs/jifs/JIFSDirectory.java 2008-08-26 18:28:40 UTC (rev 4512) @@ -77,12 +77,12 @@ // TODO -> extended FSEntry maybe have to be flushed } - public FSEntry addDirectory(String name) { - return null; + public FSEntry addDirectory(String name) throws IOException { + throw new ReadOnlyFileSystemException(); } - public FSEntry addFile(String name) { - return null; + public FSEntry addFile(String name) throws IOException { + throw new ReadOnlyFileSystemException(); } public Iterator<FSEntry> iterator() { @@ -90,7 +90,7 @@ } public void remove(String name) throws IOException { - throw new ReadOnlyFileSystemException("you can not remove from JNIFS.."); + throw new ReadOnlyFileSystemException(); } public boolean isValid() { Modified: trunk/fs/src/fs/org/jnode/fs/jifs/JIFileSystem.java =================================================================== --- trunk/fs/src/fs/org/jnode/fs/jifs/JIFileSystem.java 2008-08-26 18:15:18 UTC (rev 4511) +++ trunk/fs/src/fs/org/jnode/fs/jifs/JIFileSystem.java 2008-08-26 18:28:40 UTC (rev 4512) @@ -21,12 +21,7 @@ package org.jnode.fs.jifs; -import java.io.IOException; - import org.jnode.driver.Device; -import org.jnode.fs.FSDirectory; -import org.jnode.fs.FSEntry; -import org.jnode.fs.FSFile; import org.jnode.fs.FileSystem; import org.jnode.fs.FileSystemException; import org.jnode.fs.jifs.directories.JIFSDrootDir; @@ -61,11 +56,12 @@ * Is the filesystem mounted in readonly mode ? */ public boolean isReadOnly() { - return true; // always readOnly + // always readOnly + return true; } public void close() { - return; + //nothing to do } public boolean isClosed() { @@ -77,16 +73,6 @@ } /** - * Flush all changed structures to the device. Since JIFS is readonly, this - * method does nothing. - * - * @throws IOException - */ - public void flush() throws IOException { - return; - } - - /** * Gets the root entry of this filesystem. This is usually a director, but * this is not required. * @@ -96,41 +82,15 @@ return rootDir; } - /** - * Gets the file for the given entry. - * - * @return null - * @param entry - */ - public synchronized JIFSFile getFile(FSEntry entry) { - return null; - } - - protected FSFile createFile(FSEntry entry) throws IOException { - return null; - } - - protected FSDirectory createDirectory(FSEntry entry) throws IOException { - return null; - } - - protected FSEntry createRootEntry() throws IOException { - return null; - } - public long getFreeSpace() { - // TODO implement me return -1; } public long getTotalSpace() { - // TODO implement me return -1; } public long getUsableSpace() { - // TODO implement me return -1; } - } Modified: trunk/fs/src/fs/org/jnode/fs/ntfs/NTFSDirectory.java =================================================================== --- trunk/fs/src/fs/org/jnode/fs/ntfs/NTFSDirectory.java 2008-08-26 18:15:18 UTC (rev 4511) +++ trunk/fs/src/fs/org/jnode/fs/ntfs/NTFSDirectory.java 2008-08-26 18:28:40 UTC (rev 4512) @@ -28,6 +28,7 @@ import org.jnode.fs.FSDirectory; import org.jnode.fs.FSEntry; import org.jnode.fs.FileSystem; +import org.jnode.fs.ReadOnlyFileSystemException; /** * @author vali @@ -75,25 +76,22 @@ /** * */ - public FSEntry addFile(String name) { - // TODO Auto-generated method stub - return null; + public FSEntry addFile(String name) throws IOException { + throw new ReadOnlyFileSystemException(); } /** * */ - public FSEntry addDirectory(String name) { - // TODO Auto-generated method stub - return null; + public FSEntry addDirectory(String name) throws IOException { + throw new ReadOnlyFileSystemException(); } /** * Remove the entry with the given name from this directory. */ - public void remove(String name) { - // TODO Auto-generated method stub - + public void remove(String name) throws IOException { + throw new ReadOnlyFileSystemException(); } /** Modified: trunk/fs/src/fs/org/jnode/fs/spi/AbstractFSDirectory.java =================================================================== --- trunk/fs/src/fs/org/jnode/fs/spi/AbstractFSDirectory.java 2008-08-26 18:15:18 UTC (rev 4511) +++ trunk/fs/src/fs/org/jnode/fs/spi/AbstractFSDirectory.java 2008-08-26 18:28:40 UTC (rev 4512) @@ -143,7 +143,7 @@ * @param name * @throws IOException */ - public final synchronized void remove(String name) throws IOException { + public synchronized void remove(String name) throws IOException { if (!canWrite()) throw new IOException("Filesystem or directory is mounted read-only!"); if (entries.remove(name) >= 0) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |