At line 3 changed one line |
In the user manager, make a new VFS item. Set its protocol to be CUSTOM, and use a URL like this: |
In the user manager, make a new VFS item. Set its protocol to be FILE. Save your changes, and close the user manager. Now go find the users folder, your server group, then your user, then the VFS folder, and finally the name of the VFS item you just saved. Edit it with a text editor, and set the URL to be: |
At line 5 changed one line |
CUSTOM_com.myprotocol.VFS_MyProtocol://any_data_you_want_on_the_url/ |
CUSTOM_com.myprotocol.MyProtocol://any_data_you_want_on_the_url:port/ |
At line 7 added 2 lines |
Now you are ready to login. This class must be on the class path for CrushFTP for it to work. |
|
At line 16 changed one line |
public class VFS_MyProtocol |
public class MyProtocol |
At line 22 changed one line |
public VFS_MyProtocol(VFS uVFS, String urlStr, Properties vItem) |
public MyProtocol(VFS uVFS, String urlStr, Properties vItem) |
At line 34 added one line |
File f = new File(url.getPath()+path); |
At line 33 changed one line |
dir_item.put("url",url+path); |
dir_item.put("url",url+path+(f.isDirectory()?"/":"")); |
At line 35 changed 3 lines |
dir_item.put("protocol", "ftp"); |
dir_item.put("type", "FILE"); |
dir_item.put("permissions", "drwxrwxrwx"); |
dir_item.put("protocol", "file"); |
dir_item.put("type", f.isFile()?"FILE":"DIR"); |
dir_item.put("permissions", (f.isFile()?"-":"d")+"rwxrwxrwx"); |
At line 41 changed one line |
dir_item.put("size", "0"); |
dir_item.put("size", f.length()+""); |
At line 45 changed 3 lines |
dir_item.put("name", "test"); |
dir_item.put("local", "false"); |
dir_item.put("dir", path); |
dir_item.put("name", f.getName()); |
dir_item.put("local", "true"); |
dir_item.put("root_dir", path); |
At line 54 changed one line |
Common.debug(2,"ls "+url+path); |
Common.debug(0,"ls "+url+path); |
File fs[] = new File(url.getPath()+path).listFiles(); |
if (fs != null) |
{ |
for (int x=0; x<fs.length; x++) |
{ |
File f = fs[x]; |
Properties p = get_item(path+"/"+f.getName()); |
list.addElement(p); |
} |
} |
At line 59 changed 13 lines |
Common.debug(2,"get "+item.getProperty("url")); |
|
InputStream inStream = null; |
long skipped = 0; |
long amt = seekPos - skipped; |
while(skipped < seekPos) |
{ |
long l = inStream.skip(amt); |
if (l > 0) skipped += l; |
else break; |
amt = seekPos - skipped; |
} |
|
Common.debug(0,"get "+item.getProperty("url")); |
VRL u = new VRL(item.getProperty("url")); |
InputStream inStream = new FileInputStream(u.getPath()); |
inStream.skip(seekPos.longValue()); |
At line 77 changed 4 lines |
Common.debug(2,"put "+item.getProperty("url")); |
|
OutputStream outStream = null; |
|
Common.debug(0,"put "+item.getProperty("url")); |
VRL u = new VRL(item.getProperty("url")); |
RandomAccessFile raf = new RandomAccessFile(u.getPath(),"rw"); |
if (raf.length() > seekPos.longValue()) raf.setLength(seekPos.longValue()); |
raf.close(); |
OutputStream outStream = new FileOutputStream(u.getPath(),true); |
At line 86 changed one line |
Common.debug(2,command +" "+item.getProperty("url")); |
Common.debug(0,command +" "+item.getProperty("url")); |
VRL u = new VRL(item.getProperty("url")); |
At line 99 added one line |
new File(u.getPath()).delete(); |
At line 104 added one line |
new File(u.getPath()).delete(); |
At line 109 added one line |
new File(u.getPath()).mkdirs(); |
At line 105 changed one line |
s = "213 " + sdf.format(new Date()); |
if (new File(u.getPath()).exists()) s = "213 " + sdf.format(new Date(new File(u.getPath()).lastModified())); |
else throw new Exception("File does not exist."); |
At line 109 changed one line |
s = "213 0"; |
if (new File(u.getPath()).exists()) |
{ |
if (new File(u.getPath()).isDirectory() && new File(u.getPath()).listFiles() != null) s = "213 "+new File(u.getPath()).listFiles().length; |
else s = "213 "+new File(u.getPath()).length(); |
} |
else throw new Exception("File does not exist."); |
At line 123 changed 2 lines |
Common.debug(2,"rename "+item1.getProperty("url") + " to " + item2.getProperty("url")); |
return new Boolean(false); |
Common.debug(0,"rename "+item1.getProperty("url") + " to " + item2.getProperty("url")); |
VRL u1 = new VRL(item1.getProperty("url")); |
VRL u2 = new VRL(item2.getProperty("url")); |
return new Boolean(new File(u1.getPath()).renameTo(new File(u2.getPath()))); |
At line 146 added one line |
|