Package org.webappos.fs
Interface IFileSystem
-
public interface IFileSystem
File System API. Used by webAppOS apps and services to access Home File System. This API is also implemented in file system drivers, which provide access to remote file systems that can be mounted in the webAppOS user home directory.
-
-
Nested Class Summary
Nested Classes Modifier and Type Interface Description static class
IFileSystem.AllocationInfo
Stores space usage info.static class
IFileSystem.PathInfo
Stores a path element (one level).
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description boolean
copyPath(java.lang.String src, java.lang.String dst)
Copies the given file or folder.boolean
createDirectory(java.lang.String path)
Creates the given directory.boolean
deletePath(java.lang.String path)
Deletes the given file or directory.java.io.InputStream
downloadFile(java.lang.String path)
Reads the content of the given file.IFileSystem.AllocationInfo
getAllocationInfo()
Gets the allocation info for the current file system.IFileSystem.PathInfo
getPathInfo(java.lang.String path)
Returns meta information for the given file or folder.java.util.List<IFileSystem.PathInfo>
listDirectory(java.lang.String path)
Traverses the given directory (non-recursively) and returns the list of files and subdirectories.boolean
pathExists(java.lang.String path)
Checks whether the given file or directory exists.boolean
renamePath(java.lang.String src, java.lang.String dst)
Renames or physically moves the given file or folder to a new location.java.util.List<java.lang.String>
searchForFiles(java.lang.String startDirectory, java.lang.String query)
boolean
uploadFile(java.lang.String path, java.io.InputStream stream, long length, boolean overwrite)
Uploads a file from the given input stream (the stream must be open and will be left open).
-
-
-
Method Detail
-
copyPath
boolean copyPath(java.lang.String src, java.lang.String dst)
Copies the given file or folder.- Parameters:
src
- source path (relative to the file system root)dst
- target path (relative to the file system root)- Returns:
- whether the operation succeeded
-
createDirectory
boolean createDirectory(java.lang.String path)
Creates the given directory.- Parameters:
path
- the directory to create (relative to the file system root)- Returns:
- whether the operation succeeded
-
deletePath
boolean deletePath(java.lang.String path)
Deletes the given file or directory.- Parameters:
path
- the file or directory to delete (relative to the file system root); directories are deleted recursively- Returns:
- whether the operation succeeded
-
downloadFile
java.io.InputStream downloadFile(java.lang.String path)
Reads the content of the given file.- Parameters:
path
- the file name to download (relative to the file system root)- Returns:
- the input stream or null on error; the caller must close the returned input stream after using it!
-
pathExists
boolean pathExists(java.lang.String path)
Checks whether the given file or directory exists.- Parameters:
path
- the file or directory name to check (relative to the file system root)- Returns:
- true, if the given path exists, or false otherwise (also in case of an error)
-
getAllocationInfo
IFileSystem.AllocationInfo getAllocationInfo()
Gets the allocation info for the current file system.- Returns:
- AllocationInfo object (or null, if allocation info is not available or not implemented)
-
listDirectory
java.util.List<IFileSystem.PathInfo> listDirectory(java.lang.String path)
Traverses the given directory (non-recursively) and returns the list of files and subdirectories.- Parameters:
path
- directory name to list (relative to the file system root)- Returns:
- the list of files and subdirectories, or null on error
-
getPathInfo
IFileSystem.PathInfo getPathInfo(java.lang.String path)
Returns meta information for the given file or folder.- Parameters:
path
- the file or directory name to consider (relative to the file system root)- Returns:
- the PathInfo object or null on error
-
renamePath
boolean renamePath(java.lang.String src, java.lang.String dst)
Renames or physically moves the given file or folder to a new location.- Parameters:
src
- source path (relative to the file system root)dst
- target path (relative to the file system root)- Returns:
- whether the operation succeeded
-
searchForFiles
java.util.List<java.lang.String> searchForFiles(java.lang.String startDirectory, java.lang.String query)
-
uploadFile
boolean uploadFile(java.lang.String path, java.io.InputStream stream, long length, boolean overwrite)
Uploads a file from the given input stream (the stream must be open and will be left open).- Parameters:
path
- the target file name (relative to the file system root)stream
- the source streamlength
- the length (in bytes) to read from the streamoverwrite
- whether to overwrite the target file, if exists- Returns:
- whether the operation succeeded; the caller must close the stream
-
-