Class FileManager
java.lang.Object
io.github.monsieurdoceo.filizer.storage.api.FileManager
Provides access to managed files.
This class is responsible for creating, registering,
retrieving, synchronizing, and deleting CustomFile instances.
-
Constructor Summary
ConstructorsConstructorDescriptionFileManager(FileRegistry registry, FileSynchronizationStrategy strategy, AppLogger logger) Constructs a newFileManagerinstance.FileManager(FileRegistry registry, FileSynchronizationStrategy strategy, AppLogger logger, FilizerExceptions errors) Constructs a newFileManagerinstance. -
Method Summary
Modifier and TypeMethodDescriptionbooleancontainsFile(String name) Checks whether a file with the given name exists in storage.createFile(File parent, String name) Creates a newCustomFilefrom a parent directory and file name.createFile(String path, String name) Creates a newCustomFilefrom a parent path and a name.booleandeleteFile(CustomFile customFile) Deletes the givenCustomFilefrom filesystem and removes it from storage.booleandeleteFile(String name) Deletes theCustomFileassociated with the given name.Attempts to retrieve a registered file by its name.Attempts to retrieve a registered file by its path.Retrieves the underlying file storage instance.Retrieves the file synchronization instance.voidremoveFile(CustomFile customFile) Removes the givenCustomFilefrom storage.voidremoveFile(String name) Removes aCustomFilefrom storage by this name.voidremoveFile(Path path, String name) Removes a file from storage by its path and name.requireFile(String name) Retrieves a registered file.voidstoreAllFiles(Path root) Recursively stores all regular files found under the given root path.
-
Constructor Details
-
Method Details
-
containsFile
Checks whether a file with the given name exists in storage.- Parameters:
name- the file name to search for- Returns:
trueif the file exists,falseotherwise
-
findFile
Attempts to retrieve a registered file by its name.- Parameters:
name- the file name- Returns:
- the matching file, if present
-
findFile
Attempts to retrieve a registered file by its path.- Parameters:
path- the parent directory pathname- the file name- Returns:
- the matching file, if present
-
requireFile
Retrieves a registered file.- Parameters:
name- the file name- Returns:
- the matching file
- Throws:
IllegalArgumentException- if the file does not exist
-
createFile
Creates a newCustomFilefrom a parent path and a name.- Parameters:
path- the parent directory pathname- the file name- Returns:
- the created
CustomFile
-
createFile
Creates a newCustomFilefrom a parent directory and file name.This method behaves like
createFile(String, String)but accepts aFileas the parent reference.- Parameters:
parent- the parent directoryname- the file name- Returns:
- the created
CustomFile
-
removeFile
Removes aCustomFilefrom storage by this name.- Parameters:
name- the file name
-
removeFile
Removes a file from storage by its path and name.- Parameters:
path- the parent pathname- the file name
-
removeFile
Removes the givenCustomFilefrom storage.This method behaves like
removeFile(String)but operates directly on aCustomFileinstance.- Parameters:
customFile- the file to remove
-
storeAllFiles
Recursively stores all regular files found under the given root path.If the root path does not exist, it is created automatically.
- Parameters:
root- the root directory to scan- Throws:
IOException- if the directory cannot be created or files cannot be accessed
-
deleteFile
Deletes theCustomFileassociated with the given name.- Parameters:
name- file name- Returns:
trueif the file was deleted successfully, otherwisefalse
-
deleteFile
Deletes the givenCustomFilefrom filesystem and removes it from storage.This method behaves like
deleteFile(String)but operates directly on aCustomFileinstance.- Parameters:
customFile- the file to delete- Returns:
trueif the file was deleted successfully, otherwisefalse
-
getRegistry
Retrieves the underlying file storage instance.- Returns:
- the file storage
-
getSynchronizer
Retrieves the file synchronization instance.- Returns:
- the file synchronization instance
-