org.mockftpserver.fake.filesystem
Interface FileSystem

All Known Implementing Classes:
AbstractFakeFileSystem, UnixFakeFileSystem, WindowsFakeFileSystem

public interface FileSystem

Interface for a file system for managing files and directories.

Version:
$Revision: 182 $ - $Date: 2008-11-30 21:37:49 -0500 (Sun, 30 Nov 2008) $
Author:
Chris Mair

Method Summary
 void add(FileSystemEntry entry)
          Add the specified file system entry (file or directory) to this file system
 boolean delete(String path)
          Delete the file or directory specified by the path.
 boolean exists(String path)
          Return true if there exists a file or directory at the specified path
 String formatDirectoryListing(FileSystemEntry fileSystemEntry)
          Return the formatted directory listing entry for the file represented by the specified FileSystemEntry
 FileSystemEntry getEntry(String path)
          Returns the FileSystemEntry object representing the file system entry at the specified path, or null if the path does not specify an existing file or directory within this file system.
 String getParent(String path)
          Return the parent path of the specified path.
 boolean isAbsolute(String path)
          Return true if the specified path designates an absolute file path.
 boolean isDirectory(String path)
          Return true if the specified path designates an existing directory, false otherwise
 boolean isFile(String path)
          Return true if the specified path designates an existing file, false otherwise
 List listFiles(String path)
          Return the List of FileSystemEntry objects for the files in the specified directory path.
 List listNames(String path)
          Return the List of filenames in the specified directory path.
 String path(String path1, String path2)
          Build a path from the two path components.
 void rename(String fromPath, String toPath)
          Rename the file or directory.
 

Method Detail

add

void add(FileSystemEntry entry)
Add the specified file system entry (file or directory) to this file system

Parameters:
entry - - the FileSystemEntry to add

listFiles

List listFiles(String path)
Return the List of FileSystemEntry objects for the files in the specified directory path. If the path does not refer to a valid directory, then an empty List is returned.

Parameters:
path - - the path of the directory whose contents should be returned
Returns:
the List of FileSystemEntry objects for all files in the specified directory may be empty

listNames

List listNames(String path)
Return the List of filenames in the specified directory path. The returned filenames do not include a path. If the path does not refer to a valid directory, then an empty List is returned.

Parameters:
path - - the path of the directory whose contents should be returned
Returns:
the List of filenames (not including paths) for all files in the specified directory may be empty
Throws:
AssertionError - - if path is null

delete

boolean delete(String path)
Delete the file or directory specified by the path. Return true if the file is successfully deleted, false otherwise. If the path refers to a directory, it must be empty. Return false if the path does not refer to a valid file or directory or if it is a non-empty directory.

Parameters:
path - - the path of the file or directory to delete
Returns:
true if the file or directory is successfully deleted
Throws:
AssertionError - - if path is null

rename

void rename(String fromPath,
            String toPath)
Rename the file or directory. Specify the FROM path and the TO path. Throw an exception if the FROM path or the parent directory of the TO path do not exist; or if the rename fails for another reason.

Parameters:
fromPath - - the source (old) path + filename
toPath - - the target (new) path + filename
Throws:
AssertionError - - if fromPath or toPath is null
FileSystemException - - if the rename fails.

formatDirectoryListing

String formatDirectoryListing(FileSystemEntry fileSystemEntry)
Return the formatted directory listing entry for the file represented by the specified FileSystemEntry

Parameters:
fileSystemEntry - - the FileSystemEntry representing the file or directory entry to be formatted
Returns:
the the formatted directory listing entry

exists

boolean exists(String path)
Return true if there exists a file or directory at the specified path

Parameters:
path - - the path
Returns:
true if the file/directory exists
Throws:
AssertionError - - if path is null

isDirectory

boolean isDirectory(String path)
Return true if the specified path designates an existing directory, false otherwise

Parameters:
path - - the path
Returns:
true if path is a directory, false otherwise
Throws:
AssertionError - - if path is null

isFile

boolean isFile(String path)
Return true if the specified path designates an existing file, false otherwise

Parameters:
path - - the path
Returns:
true if path is a file, false otherwise
Throws:
AssertionError - - if path is null

isAbsolute

boolean isAbsolute(String path)
Return true if the specified path designates an absolute file path. What constitutes an absolute path is dependent on the file system implementation.

Parameters:
path - - the path
Returns:
true if path is absolute, false otherwise
Throws:
AssertionError - - if path is null

path

String path(String path1,
            String path2)
Build a path from the two path components. Concatenate path1 and path2. Insert the file system-dependent separator character in between if necessary (i.e., if both are non-empty and path1 does not already end with a separator character AND path2 does not begin with one).

Parameters:
path1 - - the first path component may be null or empty
path2 - - the second path component may be null or empty
Returns:
the path resulting from concatenating path1 to path2

getEntry

FileSystemEntry getEntry(String path)
Returns the FileSystemEntry object representing the file system entry at the specified path, or null if the path does not specify an existing file or directory within this file system.

Parameters:
path - - the path of the file or directory within this file system
Returns:
the FileSystemEntry containing the information for the file or directory, or else null

getParent

String getParent(String path)
Return the parent path of the specified path. If path specifies a filename, then this method returns the path of the directory containing that file. If path specifies a directory, the this method returns its parent directory. If path is empty or does not have a parent component, then return an empty string.

All path separators in the returned path are converted to the system-dependent separator character.

Parameters:
path - - the path
Returns:
the parent of the specified path, or null if path has no parent
Throws:
AssertionError - - if path is null


Copyright © 2014. All rights reserved.