org.glassfish.virtualization.spi
Interface FileOperations


public interface FileOperations

Abstraction for local/remote file operations on a machine. Operations on this interface are implemented by a machine which can be local or remote.

Author:
Jerome Dochez

Method Summary
 void copy(File source, File destDir)
          copy the file from the local machine to the remote machine represented by this instance
 boolean delete(String path)
          deletes a file or a directory on the target machine
 boolean exists(String path)
          returns true if the path exists on the machine
 long length(String path)
          Returns a file size
 void localCopy(String source, String destDir)
          copy the file on a remote machine from a source path to a destination path.
 List<String> ls(String path)
          Returns a list of file names in the passed directory
 boolean mkdir(String destPath)
          mkdir on the target machine
 Date mod(String path)
          Returns the Date of the last modification of the file.
 boolean mv(String source, String dest)
          move a file within the file system
 

Method Detail

exists

boolean exists(String path)
               throws IOException
returns true if the path exists on the machine

Parameters:
path - path to a file or directory to check for existence
Returns:
true if the path exists
Throws:
IOException - if the path cannot be checked.

mod

Date mod(String path)
         throws IOException
Returns the Date of the last modification of the file.

Parameters:
path - file path on the machine
Returns:
the last modification time of that file
Throws:
IOException - if the operation fialed.

mkdir

boolean mkdir(String destPath)
              throws IOException
mkdir on the target machine

Parameters:
destPath - path to the directory to create
Returns:
true if the mkdir opertation happened and was successful
Throws:
IOException - if the operation failed

delete

boolean delete(String path)
               throws IOException
deletes a file or a directory on the target machine

Parameters:
path - path to the file to delete
Returns:
true of the file existed and was deleted successfully
Throws:
IOException - if the operation failed

mv

boolean mv(String source,
           String dest)
           throws IOException
move a file within the file system

Parameters:
source - the source path for the file
dest - the destination path to move the file to
Returns:
true if the operation succeeded.
Throws:
IOException - if the operation failed

copy

void copy(File source,
          File destDir)
          throws IOException
copy the file from the local machine to the remote machine represented by this instance

Parameters:
source - the source file path
destDir - the destination directory to copy the file to
Throws:
IOException - if the operation failed

localCopy

void localCopy(String source,
               String destDir)
               throws IOException
copy the file on a remote machine from a source path to a destination path.

Parameters:
source - the source path.
destDir - the destination directory to copy the file to
Throws:
IOException - if the operation failed

length

long length(String path)
            throws IOException
Returns a file size

Parameters:
path - path to the file
Returns:
the file size
Throws:
IOException - if the file is not found

ls

List<String> ls(String path)
                throws IOException
Returns a list of file names in the passed directory

Parameters:
directory - path
Returns:
the list of files in that directory
Throws:
IOException


Copyright © 2012. All Rights Reserved.