|
From: <ls...@us...> - 2008-06-06 20:52:06
|
Revision: 4205
http://jnode.svn.sourceforge.net/jnode/?rev=4205&view=rev
Author: lsantha
Date: 2008-06-06 13:52:02 -0700 (Fri, 06 Jun 2008)
Log Message:
-----------
SMB FS improvements.
Modified Paths:
--------------
trunk/fs/fs.iml
trunk/fs/src/fs/org/jnode/fs/smbfs/SMBFSDirectory.java
trunk/fs/src/fs/org/jnode/fs/smbfs/SMBFSEntry.java
trunk/fs/src/fs/org/jnode/fs/smbfs/SMBFSFile.java
trunk/fs/src/fs/org/jnode/fs/smbfs/SMBFileSystem.java
Modified: trunk/fs/fs.iml
===================================================================
--- trunk/fs/fs.iml 2008-06-06 20:07:37 UTC (rev 4204)
+++ trunk/fs/fs.iml 2008-06-06 20:52:02 UTC (rev 4205)
@@ -1,5 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<module relativePaths="true" type="JAVA_MODULE" version="4">
+ <component name="DBNavigator.Module.ConnectionManager">
+ <connections />
+ </component>
<component name="NewModuleRootManager" inherit-compiler-output="false">
<output url="file://$MODULE_DIR$/classes" />
<exclude-output />
@@ -26,11 +29,10 @@
<orderEntry type="module-library">
<library>
<CLASSES>
- <root url="file://$MODULE_DIR$/lib" />
+ <root url="jar://$MODULE_DIR$/lib/jcifs-1.2.6.jar!/" />
</CLASSES>
<JAVADOC />
<SOURCES />
- <jarDirectory url="file://$MODULE_DIR$/lib" recursive="false" />
</library>
</orderEntry>
<orderEntryProperties />
Modified: trunk/fs/src/fs/org/jnode/fs/smbfs/SMBFSDirectory.java
===================================================================
--- trunk/fs/src/fs/org/jnode/fs/smbfs/SMBFSDirectory.java 2008-06-06 20:07:37 UTC (rev 4204)
+++ trunk/fs/src/fs/org/jnode/fs/smbfs/SMBFSDirectory.java 2008-06-06 20:52:02 UTC (rev 4205)
@@ -86,7 +86,7 @@
* All elements returned by the iterator must be instanceof FSEntry.
*/
public Iterator<? extends SMBFSEntry> iterator() throws IOException {
- SmbFile[] smb_list = null;
+ SmbFile[] smb_list;
try{
smb_list = smbFile.listFiles();
} catch(SmbException e){
@@ -94,13 +94,17 @@
throw e;
}
entries.clear();
+
for(SmbFile f : smb_list){
if(f.isDirectory()){
- entries.put(f.getName(), new SMBFSDirectory(this, f));
+ String name = getSimpleName(f);
+ entries.put(name, new SMBFSDirectory(this, f));
} else if(f.isFile()){
- entries.put(f.getName(), new SMBFSFile(this, f));
+ String name = getSimpleName(f);
+ entries.put(name, new SMBFSFile(this, f));
}
}
+
return entries.values().iterator();
}
Modified: trunk/fs/src/fs/org/jnode/fs/smbfs/SMBFSEntry.java
===================================================================
--- trunk/fs/src/fs/org/jnode/fs/smbfs/SMBFSEntry.java 2008-06-06 20:07:37 UTC (rev 4204)
+++ trunk/fs/src/fs/org/jnode/fs/smbfs/SMBFSEntry.java 2008-06-06 20:52:02 UTC (rev 4205)
@@ -18,7 +18,7 @@
* along with this library; If not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
-
+
package org.jnode.fs.smbfs;
import org.jnode.fs.FSEntry;
@@ -84,9 +84,16 @@
* Gets the name of this entry.
*/
public String getName() {
- return smbFile.getName();
+ return getSimpleName(smbFile);
}
+ static String getSimpleName(SmbFile smbFile) {
+ String name = smbFile.getName();
+ if(name.endsWith("/"))
+ name = name.substring(0, name.length() - 1);
+ return name;
+ }
+
/**
* Gets the directory this entry is a part of.
*/
Modified: trunk/fs/src/fs/org/jnode/fs/smbfs/SMBFSFile.java
===================================================================
--- trunk/fs/src/fs/org/jnode/fs/smbfs/SMBFSFile.java 2008-06-06 20:07:37 UTC (rev 4204)
+++ trunk/fs/src/fs/org/jnode/fs/smbfs/SMBFSFile.java 2008-06-06 20:52:02 UTC (rev 4205)
@@ -24,9 +24,11 @@
import org.jnode.fs.FSFile;
import java.io.IOException;
+import java.io.InputStream;
import java.nio.ByteBuffer;
import jcifs.smb.SmbFile;
+import jcifs.smb.SmbFileInputStream;
/**
* @author Levente S\u00e1ntha
@@ -65,9 +67,24 @@
* @throws java.io.IOException
*/
public void read(long fileOffset, ByteBuffer dest) throws IOException {
- byte[] data = new byte[(int) getLength()];
- smbFile.getInputStream().read(data);
- dest.put(data, (int) fileOffset, dest.remaining());
+ if(fileOffset > smbFile.length())
+ return;
+
+ int b_len = 32 * 1024;
+ byte[] buf = new byte[b_len];
+
+ SmbFileInputStream is = (SmbFileInputStream) smbFile.getInputStream();
+
+ long s = is.skip(fileOffset);
+ if(s < fileOffset)
+ is.skip(fileOffset);
+
+ int bc;
+ int rem = 1;
+ while((bc = is.read(buf)) > 0 && rem > 0){
+ dest.put(buf, 0, Math.min(bc, dest.remaining()));
+ rem = dest.remaining();
+ }
}
/**
Modified: trunk/fs/src/fs/org/jnode/fs/smbfs/SMBFileSystem.java
===================================================================
--- trunk/fs/src/fs/org/jnode/fs/smbfs/SMBFileSystem.java 2008-06-06 20:07:37 UTC (rev 4204)
+++ trunk/fs/src/fs/org/jnode/fs/smbfs/SMBFileSystem.java 2008-06-06 20:52:02 UTC (rev 4205)
@@ -26,6 +26,7 @@
import jcifs.smb.NtlmAuthenticator;
import jcifs.smb.NtlmPasswordAuthentication;
import jcifs.smb.SmbFile;
+import jcifs.smb.SmbException;
import org.jnode.fs.FileSystem;
@@ -99,9 +100,12 @@
}
public long getFreeSpace() {
- // TODO implement me
- return 0;
- }
+ try {
+ return root.smbFile.getDiskFreeSpace();
+ } catch (SmbException e){
+ return 0;
+ }
+ }
public long getTotalSpace() {
// TODO implement me
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|