head 1.1;
branch 1.1.1;
access ;
symbols cyoun:1.1.1.1 gateway:1.1.1;
locks ; strict;
comment @# @;
1.1
date 2000.08.03.03.41.31; author cyoun; state Exp;
branches 1.1.1.1;
next ;
1.1.1.1
date 2000.08.03.03.41.31; author cyoun; state Exp;
branches ;
next ;
desc
@@
1.1
log
@Initial revision
@
text
@
This documenty describes interface of two modules: RemoteFile and MoveFile
interface RemoteFile : BeanContextChild
exception FileException { string message; };
exception EOFFileException {};
- void open(String file_name, String options) throws FileException;
- instantiate a new object file of type RandomAccessFile
corrsponding to a file named file_name. The string
Options is method argurment of the RandomAccessFile class
constructor ("r" or "rw" for read and read/write access).
The newly created object file is a global attribute of RemoteFile (this
module), so it can be accessed in subsequent invocation of methods of
RemoteFile.
- void close();
- invokes file.close()
- byte[] getBlock() throws FileException, EOFFileException;
- reads block of bytes from the file and returns it to the user.
The default block size is 1024, and can be changed by invoking
RemoteFile.setBlockSize decribed below
- void get(org.omg.CORBA.ByteHolder c) throws FileException, EOFFileException;
- gets one byte from the file and returns it to the user
- void putBlock(byte arr[]) throws FileException;
- writes one block of bytes to the file
- void put(byte c) raises FileException;
- writes one byte to the file
- void setBlockSize(in short aSize);
- set block size for reading file
- int getFileSize() throws FileException; ;
- gets the size of the file
- boolean delete(String file_name);
- deletes file or directory specified by file_name
- directory must be empty to be deleted
- use rmdir to delete not empty directory
- returns true if opercation copmleted sucessfully
- boolean mkdir(String dir_name);
- creates directory with the specified name
- returns true if opercation copmleted sucessfully
- boolean rmdir(String dir_name);
- deletes directory with the specified name dir_name together with its
contents (so it works like Unix rm -r dirname)
- returns true if opercation copmleted sucessfully
- boolean rename(String source, String dest);
- renames source file (or directory) to dest
- returns true if opercation copmleted sucessfully
- boolean copy(String source, String dest);
- copies file (or directory) source to dest. If source
is a directory, its contents is recursively copied as well
- returns true if opercation copmleted sucessfully
- boolean exists(String file_name);
- returns true if named file or directory exists
- boolean saveAsFile(String filename, String body);
- saves string body as a file filename
- returns true if opercation copmleted sucessfully
- void saveIOR(String ir, String fileName);
- the same as saveAs above: saves string ir to file fileName
- returns true if opercation copmleted sucessfully
interface MoveFile:BeanContextChild
- void Init(RemoteFile remote_file);
- instantiates a new instance of FileTransfer class (an ft object is a
global attribute of this class (MoveFile). ft constructor takes object
reference to an object of type RemoteFile as input argument
- void FileReceive(in string dest, in string source);
- receives a file (for details, see FileTransfer)
- void FileSend(in string dest, in string source);
- sends file (for details, see FileTransfer)
class FileTransfer
FileTransfer is used to send and receive files to and from remote host
It uses RemoteFile CORBA object to work with the remote file.
- FileTransfer(RemoteFile rf);
- a constructor that requires object reference to an object of type RemoteFile;
- FileTransfer(ORB anOrb, String obj_ior);
- a constructor that creates object reference to RemoteFile by
deserializing its IOR; (note it means that the RemoteFile object must exist
before FileTransfer object is instatiated).
- FileTransfer(ORB anOrb, String obj_ior, FTcallback aCallback);
- as above, with object reference of TFcallback instance.
- void FileSend(String source, String dest) throws FileNotFoundException, FileException, IOException
- FileSend sends local file to the remote host:
opens local source file
opens remote dest file using RemoteFile.open(dest)
reads one block at a time from source and writes it to
dest using RemoteFile.putBlock(buffer) method. This step is
repeated until all file is read (and written on the remote host).
The default buffer size is 8912
If FTcallback is instantiated, after each block transfered
FTcallback.trasfered(n) is invoked, where
total bytes transfered so far
n = (int) -------------------------------
lenght of the file in bytes
- void FileReceive(String dest, String source) throws FileNotFoundException, FileException, IOException
- FileReceive copies a remote file to a local file:
opens local dest file
opens remote source file using RemoteFile.open(dest)
reads one block at a time from source using
RemoteFile.getBlock(buffer) method and writes it to
source file. This step is repeated until all file is read
(and written on the local host).
If FTcallback is instantiated, after each block transfered
FTcallback.trasfered(n) is invoked, where
total bytes transfered so far
n = (int) -------------------------------
lenght of the file in bytes
- void SetBlockSize(short aSize);
- SetBlockSize sets size of the block of data to be sent for each transfer
interface FTcallback
package WebFlow.RemoteFile;
public interface FTcallback {
public void transfered(int bytes);
}
Usage: How to transfer a file
MoveFile mf;
FileTransfer file;
String dst,src;
dst="/tmp/file1";
src="/tmp/file2";
mf.Init(orb.object_to_string(file));
mf.FileReceive(dst,src);
// or
mf.FileSend(src,dest)
At NPAC: see AppletFT source in /npac/home/webflow/WEBFLOW/JIGSAW/Jigsaw/WWW/MoveFile/src/AppletFT.java
@
1.1.1.1
log
@Imported Gateway Middle Tier
@
text
@@