Class LocalFileSystem
- java.lang.Object
-
- me.insidezhou.southernquiet.filesystem.driver.LocalFileSystem
-
- All Implemented Interfaces:
FileSystem
public class LocalFileSystem extends java.lang.Object implements FileSystem
基于操作系统本地文件系统的驱动.
-
-
Field Summary
-
Fields inherited from interface me.insidezhou.southernquiet.filesystem.FileSystem
PATH_SEPARATOR, PATH_SEPARATOR_STRING
-
-
Constructor Summary
Constructors Constructor Description LocalFileSystem(FrameworkAutoConfiguration.LocalFileSystemProperties properties)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidcopy(java.lang.String source, java.lang.String destination, boolean replaceExisting)复制文件或目录,PathMeta保持不变。voidcreateDirectory(java.lang.String path)创建目录。目录已存在则忽略。voidcreateSymbolicLink(java.lang.String link, java.lang.String path)创建文件软链接,软链接文件不存在则创建,否则替换voiddelete(java.lang.String path)删除文件或目录。java.util.stream.Stream<? extends PathMeta>directories(java.lang.String path, java.lang.String search, boolean recursive, int offset, int limit, PathMetaSort sort)获取目录下子目录。booleanexists(java.lang.String path)检查路径是否存在。java.util.stream.Stream<? extends PathMeta>files(java.lang.String path, java.lang.String search, boolean recursive, int offset, int limit, PathMetaSort sort)获取目录下文件。<M extends PathMeta>
Mmeta(java.lang.String path)获取路径的元信息。voidmove(java.lang.String source, java.lang.String destination, boolean replaceExisting)移动文件或目录,PathMeta保持不变。java.io.InputStreamopenReadStream(java.lang.String path)用流的方式读取文件内容,调用方负责流的关闭。java.io.OutputStreamopenWriteStream(java.lang.String path)用流的方式写入文件内容,调用方负责流的关闭。 当文件不存在时会自动创建。 以Append的方式写入。voidput(java.lang.String path, java.io.InputStream stream)如果文件未存在,则创建;否则替换。voidput(java.lang.String path, java.lang.CharSequence txt)如果文件未存在,则创建;否则替换。voidtouchCreation(java.lang.String path)刷新文件或目录的PathMeta.getCreationTime()。voidtouchLastAccess(java.lang.String path)刷新文件或目录的PathMeta.getLastAccessTime()。voidtouchLastModified(java.lang.String path)刷新文件或目录的PathMeta.getLastModifiedTime()。-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface me.insidezhou.southernquiet.filesystem.FileSystem
copy, directories, directories, directories, directories, files, files, files, files, move, read, read
-
-
-
-
Constructor Detail
-
LocalFileSystem
public LocalFileSystem(FrameworkAutoConfiguration.LocalFileSystemProperties properties)
-
-
Method Detail
-
createDirectory
public void createDirectory(java.lang.String path)
Description copied from interface:FileSystem创建目录。目录已存在则忽略。- Specified by:
createDirectoryin interfaceFileSystem- Parameters:
path- 路径
-
put
public void put(java.lang.String path, java.io.InputStream stream) throws InvalidFileExceptionDescription copied from interface:FileSystem如果文件未存在,则创建;否则替换。- Specified by:
putin interfaceFileSystem- Parameters:
path- 要写入的路径stream- 输入流- Throws:
InvalidFileException- 无效文件
-
put
public void put(java.lang.String path, java.lang.CharSequence txt) throws InvalidFileExceptionDescription copied from interface:FileSystem如果文件未存在,则创建;否则替换。- Specified by:
putin interfaceFileSystem- Parameters:
path- 要写入的路径txt- 输入文本- Throws:
InvalidFileException- 无效文件
-
exists
public boolean exists(java.lang.String path)
Description copied from interface:FileSystem检查路径是否存在。- Specified by:
existsin interfaceFileSystem- Parameters:
path- 路径
-
openReadStream
public java.io.InputStream openReadStream(java.lang.String path) throws InvalidFileExceptionDescription copied from interface:FileSystem用流的方式读取文件内容,调用方负责流的关闭。- Specified by:
openReadStreamin interfaceFileSystem- Parameters:
path- 路径- Throws:
InvalidFileException- 无效文件
-
openWriteStream
public java.io.OutputStream openWriteStream(java.lang.String path) throws InvalidFileExceptionDescription copied from interface:FileSystem用流的方式写入文件内容,调用方负责流的关闭。- 当文件不存在时会自动创建。
- 以Append的方式写入。
- Specified by:
openWriteStreamin interfaceFileSystem- Parameters:
path- 路径- Throws:
InvalidFileException- 无效文件
-
move
public void move(java.lang.String source, java.lang.String destination, boolean replaceExisting) throws FileSystemExceptionDescription copied from interface:FileSystem移动文件或目录,PathMeta保持不变。- Specified by:
movein interfaceFileSystem- Parameters:
source- 源路径destination- 目标路径replaceExisting- 如果true,替换现存的文件,否则忽略移动。- Throws:
PathNotFoundException- 源路径不存在FileSystemException- 文件系统操作失败
-
copy
public void copy(java.lang.String source, java.lang.String destination, boolean replaceExisting) throws FileSystemExceptionDescription copied from interface:FileSystem复制文件或目录,PathMeta保持不变。- Specified by:
copyin interfaceFileSystem- Parameters:
source- 源路径destination- 目标路径replaceExisting- 如果true,替换现存的文件,否则忽略复制。- Throws:
PathNotFoundException- 源路径不存在FileSystemException- 文件系统操作失败
-
delete
public void delete(java.lang.String path)
Description copied from interface:FileSystem删除文件或目录。- Specified by:
deletein interfaceFileSystem- Parameters:
path- 路径
-
touchCreation
public void touchCreation(java.lang.String path)
Description copied from interface:FileSystem刷新文件或目录的PathMeta.getCreationTime()。- Specified by:
touchCreationin interfaceFileSystem- Parameters:
path- 路径
-
touchLastModified
public void touchLastModified(java.lang.String path)
Description copied from interface:FileSystem刷新文件或目录的PathMeta.getLastModifiedTime()。- Specified by:
touchLastModifiedin interfaceFileSystem- Parameters:
path- 路径
-
touchLastAccess
public void touchLastAccess(java.lang.String path)
Description copied from interface:FileSystem刷新文件或目录的PathMeta.getLastAccessTime()。- Specified by:
touchLastAccessin interfaceFileSystem- Parameters:
path- 路径
-
meta
public <M extends PathMeta> M meta(java.lang.String path)
Description copied from interface:FileSystem获取路径的元信息。- Specified by:
metain interfaceFileSystem- Parameters:
path- 路径- Returns:
- 路径不存在时,返回null。
-
directories
public java.util.stream.Stream<? extends PathMeta> directories(java.lang.String path, java.lang.String search, boolean recursive, int offset, int limit, PathMetaSort sort) throws PathNotFoundException
Description copied from interface:FileSystem获取目录下子目录。- Specified by:
directoriesin interfaceFileSystem- Parameters:
path- 目录路径search- 以contains方式查找目录名。如果为空,返回所有结果。recursive- 如果true,则递归搜索所有子目录。offset- 开始位置索引。小于0则忽略。limit- 数量限制。小于0则忽略。sort- 排序选项。选项之间是互斥的。- Throws:
PathNotFoundException- 目录不存在
-
files
public java.util.stream.Stream<? extends PathMeta> files(java.lang.String path, java.lang.String search, boolean recursive, int offset, int limit, PathMetaSort sort) throws PathNotFoundException
Description copied from interface:FileSystem获取目录下文件。- Specified by:
filesin interfaceFileSystem- Parameters:
path- 目录路径search- 以contains方式查找文件名。如果为空,返回所有结果。recursive- 如果true,则递归搜索所有子目录。offset- 开始位置索引。小于0则忽略。limit- 数量限制。小于0则忽略。sort- 排序选项。选项之间是互斥的。- Throws:
PathNotFoundException- 目录不存在
-
createSymbolicLink
public void createSymbolicLink(java.lang.String link, java.lang.String path) throws InvalidFileExceptionDescription copied from interface:FileSystem创建文件软链接,软链接文件不存在则创建,否则替换- Specified by:
createSymbolicLinkin interfaceFileSystem- Parameters:
link- 软链接路径path- 目标路径- Throws:
InvalidFileException- 无效文件
-
-