Class LocalFileAccess
java.lang.Object
dev.jcputney.elearning.parser.impl.access.LocalFileAccess
- All Implemented Interfaces:
FileAccess
Implementation of FileAccess for local file access. This class provides methods to check file
existence, list files in a directory, and read file contents.
-
Constructor Summary
ConstructorsConstructorDescriptionLocalFileAccess(String rootPath) Constructs a LocalFileAccess instance with the specified root path. -
Method Summary
Modifier and TypeMethodDescriptionbooleanfileExistsInternal(String path) Checks if a file exists at the specified path.Gets the contents of a file as an InputStream.getFileContentsInternal(String path, StreamingProgressListener progressListener) Gets the contents of a file as an InputStream with optional progress tracking.Retrieves the root path for file access.longGets the total size of all files in the module.listFilesInternal(String directoryPath) Lists all files in the specified directory.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface dev.jcputney.elearning.parser.api.FileAccess
clearCaches, fileExists, fileExistsBatch, fullPath, getAllFiles, getFileContents, listFiles, prefetchCommonFiles
-
Constructor Details
-
LocalFileAccess
Constructs a LocalFileAccess instance with the specified root path.- Parameters:
rootPath- The root path for file access.- Throws:
IllegalArgumentException- if the root path is null or not a valid directory.
-
-
Method Details
-
fileExistsInternal
Checks if a file exists at the specified path.- Specified by:
fileExistsInternalin interfaceFileAccess- Parameters:
path- The path to check (guaranteed to be non-null).- Returns:
- True if the file exists, false otherwise.
-
listFilesInternal
Lists all files in the specified directory.- Specified by:
listFilesInternalin interfaceFileAccess- Parameters:
directoryPath- The path of the directory to list files from.- Returns:
- A list of file paths relative to the root path.
- Throws:
IOException- if an error occurs while listing files.
-
getFileContentsInternal
Gets the contents of a file as an InputStream.- Specified by:
getFileContentsInternalin interfaceFileAccess- Parameters:
path- The path of the file to read.- Returns:
- An InputStream for reading the file contents.
- Throws:
IOException- if an error occurs while reading the file.
-
getFileContentsInternal
public InputStream getFileContentsInternal(String path, StreamingProgressListener progressListener) throws IOException Gets the contents of a file as an InputStream with optional progress tracking.- Parameters:
path- The path of the file to read.progressListener- Optional progress listener for tracking large file operations.- Returns:
- An InputStream for reading the file contents.
- Throws:
IOException- if an error occurs while reading the file.
-
getTotalSize
Gets the total size of all files in the module.This method recursively walks the directory tree and sums the sizes of all files.
- Specified by:
getTotalSizein interfaceFileAccess- Returns:
- Total size of all files in bytes
- Throws:
IOException- if there's an error accessing file sizes
-
getRootPath
Retrieves the root path for file access.- Specified by:
getRootPathin interfaceFileAccess- Returns:
- The root path as a String.
-