com.lightdev.lib.filesystem
Interface FileSystem

All Known Implementing Classes:
LocalFileSystem

public interface FileSystem

Classes that represent a file system in the context of this package need to implement this interface.

Version:
2, 12.01.2008
Author:
Ulrich Hilger, Light Development, http://www.lightdev.com, info@lightdev.com, published under the terms and conditions of the BSD License, for details see file license.txt in the distribution package of this software

Field Summary
static String LOCAL_FILE_SYSTEM
          url string for a local file system
 
Method Summary
 void addFileSystemListener(FileSystemListener listener)
          add a listener to this file system
 boolean copy(FileRef[] filesToCopy, FileRef toFolder)
          copy files to a given folder.
 boolean createFolder(FileRef folder)
          create a new folder
 boolean delete(FileRef[] filesToDelete)
          delete one or more files
 void exportFiles(FileRef[] exportFiles, FileRef targetFolder, FileSystem targetFs)
          export from this file system to a given target file system
 boolean extract(FileRef archive, FileRef toFolder)
          extract a given ZIP archive to a given folder
 boolean fileExists(FileRef file)
          determine whether or not a given file exists in this instance of file system
 String getFileSeparator()
          get the string that is used to separate file and folder names in path expressions for the machine this file system refers to
 double getFolderSize(FileRef folder)
          determine the size of a folder in bytes
 FileRef getParentFile(FileRef file)
          get the file that is directly on top of a given file in the file hierarchy of this file system
 FileRef[] getRoots()
          get the root directories of this file system
 double getSize(FileRef[] files)
          get the total size of a number of files
 String getUrl()
          get the url string of the machine this file system is located
 void importFiles(FileRef[] sourceFiles, FileRef importFolder, FileSystem sourceFs)
          import from a given file system to this file system
 FileRef[] list(FileRef folder)
          get the files that are contained in a given folder
 boolean move(FileRef[] filesToMove, FileRef toFolder)
          move one or more files to a given folder.
 boolean pack(FileRef folder, FileRef archive)
          pack the contents of a given folder into a new ZIP compressed archive
 byte[] read(FileRef file)
          read contents of a file using a byte array in memory as a buffer
 void removeFileSystemListener(FileSystemListener listener)
          remove a listener from this file system
 FileRef rename(FileRef file, String newName)
          rename a file, i.e. change the name of a file but not its location
 boolean write(FileRef file, byte[] contents)
          write contents of a file using a byte array in memory as a buffer
 

Field Detail

LOCAL_FILE_SYSTEM

static final String LOCAL_FILE_SYSTEM
url string for a local file system

See Also:
Constant Field Values
Method Detail

addFileSystemListener

void addFileSystemListener(FileSystemListener listener)
                           throws Throwable
add a listener to this file system

Parameters:
listener - the listener to add
Throws:
Throwable

removeFileSystemListener

void removeFileSystemListener(FileSystemListener listener)
                              throws Throwable
remove a listener from this file system

Parameters:
listener - the listener to remove
Throws:
Throwable

getFileSeparator

String getFileSeparator()
                        throws Throwable
get the string that is used to separate file and folder names in path expressions for the machine this file system refers to

Returns:
the separator string
Throws:
Throwable

getRoots

FileRef[] getRoots()
                   throws Throwable
get the root directories of this file system

Returns:
the root directories of this file system
Throws:
Throwable

getParentFile

FileRef getParentFile(FileRef file)
                      throws Throwable
get the file that is directly on top of a given file in the file hierarchy of this file system

Parameters:
file - the file to get the parent file for
Returns:
the parent file
Throws:
Throwable

list

FileRef[] list(FileRef folder)
               throws Throwable
get the files that are contained in a given folder

Parameters:
folder - the directory to get the files for
Returns:
the list of files contained in the given directory
Throws:
Throwable

rename

FileRef rename(FileRef file,
               String newName)
               throws Throwable
rename a file, i.e. change the name of a file but not its location

Parameters:
file - the file to rename
newName - the new name; just the name, no path
Throws:
Throwable

copy

boolean copy(FileRef[] filesToCopy,
             FileRef toFolder)
             throws Throwable
copy files to a given folder.

Parameters:
filesToCopy - the files to copy
toFolder - the directory to copy to
Throws:
Throwable

move

boolean move(FileRef[] filesToMove,
             FileRef toFolder)
             throws Throwable
move one or more files to a given folder.

Parameters:
filesToMove - the files to move
toFolder - the folder to move to
Throws:
Throwable

createFolder

boolean createFolder(FileRef folder)
                     throws Throwable
create a new folder

Parameters:
folder - the folder to create
Throws:
Throwable

delete

boolean delete(FileRef[] filesToDelete)
               throws Throwable
delete one or more files

Parameters:
filesToDelete - the list of files to delete
Throws:
Throwable

pack

boolean pack(FileRef folder,
             FileRef archive)
             throws Throwable
pack the contents of a given folder into a new ZIP compressed archive

Parameters:
folder - the folder to pack
archive - the archive to create from the given files
Throws:
Throwable

extract

boolean extract(FileRef archive,
                FileRef toFolder)
                throws Throwable
extract a given ZIP archive to a given folder

Parameters:
archive - the archive to extract
toFolder - the folder to extract the contents of the archive to
Throws:
Throwable

fileExists

boolean fileExists(FileRef file)
                   throws Throwable
determine whether or not a given file exists in this instance of file system

Parameters:
file - the file to determine existence for
Returns:
true if the given files exists in this instance of file system, false if not
Throws:
Throwable

getFolderSize

double getFolderSize(FileRef folder)
                     throws Throwable
determine the size of a folder in bytes

Parameters:
folder - the folder to determine the size for
Returns:
the size of the folder in bytes
Throws:
Throwable

getSize

double getSize(FileRef[] files)
               throws Throwable
get the total size of a number of files

Parameters:
files - the files to determine the total size for
Returns:
the number of byte the given files have in total
Throws:
Throwable

getUrl

String getUrl()
              throws Throwable
get the url string of the machine this file system is located

Returns:
url string of machine this file system is located
Throws:
Throwable

write

boolean write(FileRef file,
              byte[] contents)
              throws Throwable
write contents of a file using a byte array in memory as a buffer

Parameters:
file - reference to the file to write
contents - the contents to write to the referenced file
Throws:
Throwable

read

byte[] read(FileRef file)
            throws Throwable
read contents of a file using a byte array in memory as a buffer

Parameters:
file - reference to the file to read
Returns:
the file contents
Throws:
Throwable

importFiles

void importFiles(FileRef[] sourceFiles,
                 FileRef importFolder,
                 FileSystem sourceFs)
                 throws Throwable
import from a given file system to this file system

Parameters:
sourceFiles - references to the files in the source file system that are to be imported
importFolder - folder of this file system to import to
sourceFs - the file system to import from
Throws:
Throwable

exportFiles

void exportFiles(FileRef[] exportFiles,
                 FileRef targetFolder,
                 FileSystem targetFs)
                 throws Throwable
export from this file system to a given target file system

Parameters:
exportFiles - references to the files in this file system to export
targetFolder - the folder of the target files system to export to
targetFs - the file system to export to
Throws:
Throwable