|
From: <fd...@us...> - 2007-07-31 18:23:51
|
Revision: 3373
http://jnode.svn.sourceforge.net/jnode/?rev=3373&view=rev
Author: fduminy
Date: 2007-07-31 11:23:49 -0700 (Tue, 31 Jul 2007)
Log Message:
-----------
fixed case where FSAccessRights is null : we default to read/write/execute allowed
Modified Paths:
--------------
trunk/fs/src/fs/org/jnode/fs/service/def/FileSystemAPIImpl.java
Modified: trunk/fs/src/fs/org/jnode/fs/service/def/FileSystemAPIImpl.java
===================================================================
--- trunk/fs/src/fs/org/jnode/fs/service/def/FileSystemAPIImpl.java 2007-07-29 05:12:04 UTC (rev 3372)
+++ trunk/fs/src/fs/org/jnode/fs/service/def/FileSystemAPIImpl.java 2007-07-31 18:23:49 UTC (rev 3373)
@@ -25,12 +25,14 @@
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.VMFileSystemAPI;
+import java.io.VMIOUtils;
import java.io.VMOpenMode;
import java.util.ArrayList;
import java.util.Iterator;
import org.apache.log4j.Logger;
import org.jnode.driver.Device;
+import org.jnode.fs.FSAccessRights;
import org.jnode.fs.FSDirectory;
import org.jnode.fs.FSEntry;
import org.jnode.fs.FileSystem;
@@ -100,8 +102,8 @@
* @param file
*/
public boolean canRead(String file) throws IOException {
- final FSEntry entry = getEntry(file);
- return (entry != null) && (entry.getAccessRights().canRead());
+ final FSAccessRights rights = getAccessRights(file);
+ return (rights == null) || rights.canRead();
}
/**
@@ -110,8 +112,8 @@
* @param file
*/
public boolean canWrite(String file) throws IOException {
- final FSEntry entry = getEntry(file);
- return (entry != null) && (entry.getAccessRights().canWrite());
+ final FSAccessRights rights = getAccessRights(file);
+ return (rights == null) || rights.canWrite();
}
/**
@@ -120,30 +122,45 @@
* @param file
*/
public boolean canExecute(String file) throws IOException {
- final FSEntry entry = getEntry(file);
- return (entry != null) && (entry.getAccessRights().canExecute());
+ final FSAccessRights rights = getAccessRights(file);
+ return (rights == null) || rights.canExecute();
}
public boolean setReadable(String file, boolean enable,
boolean owneronly) throws IOException
{
- final FSEntry entry = getEntry(file);
- return (entry != null) && (entry.getAccessRights().setReadable(enable, owneronly));
+ final FSAccessRights rights = getAccessRights(file);
+ if(rights == null)
+ {
+ return false;
+ }
+
+ return rights.setReadable(enable, owneronly);
}
public boolean setWritable(String file, boolean enable,
boolean owneronly) throws IOException
{
- final FSEntry entry = getEntry(file);
- return (entry != null) && (entry.getAccessRights().setWritable(enable, owneronly));
+ final FSAccessRights rights = getAccessRights(file);
+ if(rights == null)
+ {
+ return false;
+ }
+
+ return rights.setWritable(enable, owneronly);
}
public boolean setExecutable(String file, boolean enable,
boolean owneronly) throws IOException
{
- final FSEntry entry = getEntry(file);
- return (entry != null) && (entry.getAccessRights().setExecutable(enable, owneronly));
+ final FSAccessRights rights = getAccessRights(file);
+ if(rights == null)
+ {
+ return false;
+ }
+
+ return rights.setExecutable(enable, owneronly);
}
/**
@@ -269,6 +286,16 @@
}
return list.toArray(new String[list.size()]);
}
+
+ private FSAccessRights getAccessRights(String path) throws IOException
+ {
+ FSEntry entry = getEntry(path);
+ if(entry == null)
+ {
+ throw new FileNotFoundException("file not found: "+path);
+ }
+ return entry.getAccessRights();
+ }
/**
* Gets the FSEntry for the given path, or null if not found.
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|