Package ghidra.framework.store.local
Class IndexedLocalFileSystem
java.lang.Object
ghidra.framework.store.local.LocalFileSystem
ghidra.framework.store.local.IndexedLocalFileSystem
- All Implemented Interfaces:
FileSystem
- Direct Known Subclasses:
IndexedV1LocalFileSystem
IndexedLocalFileSystem implements a case-sensitive indexed filesystem
which uses a shallow storage hierarchy with no restriction on file name or path
length. This filesystem is identified by the existence of an index file (~index.dat)
and recovery journal (~index.jrn).-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classBadStorageNameExceptioninvalid storage name encountered.static classIndexReadExceptionoccurs when an error occurs while reading/processing the filesystem indexstatic classIndexReadExceptionoccurs when an error occurs while reading/processing the filesystem indexNested classes/interfaces inherited from class ghidra.framework.store.local.LocalFileSystem
LocalFileSystem.ItemStorage -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected static final Stringprotected static final Stringstatic final intFields inherited from class ghidra.framework.store.local.LocalFileSystem
eventManager, HIDDEN_DIR_PREFIX, HIDDEN_DIR_PREFIX_CHAR, HIDDEN_ITEM_PREFIX, isVersioned, readOnly, rootFields inherited from interface ghidra.framework.store.FileSystem
SEPARATOR, SEPARATOR_CHAR -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedIndexedLocalFileSystem(String rootPath) Construct existing indexed filesystem with an empty index. -
Method Summary
Modifier and TypeMethodDescriptionprotected LocalFileSystem.ItemStorageallocateItemStorage(String folderPath, String itemName) Allocate a new storage locationvoidcreateFolder(String parentPath, String folderName) Creates a new subfolder within the specified parent folder.protected voiddeallocateItemStorage(String folderPath, String itemName) Deallocate item storagevoiddeleteFolder(String folderPath) Delete the specified folder.voiddispose()Cleanup and release resourcesprotected LocalFileSystem.ItemStoragefindItemStorage(String folderPath, String itemName) Find an existing storage locationbooleanfolderExists(String folderPath) Returns true if the folder specified by the path exists.String[]getFolderNames(String folderPath) Return a list of subfolders (by name) that are stored within the specified folder path.intintReturns the number of folder items contained within this file-system.String[]getItemNames(String folderPath, boolean includeHiddenFiles) Returns a list of the folder items contained in the given folder.intstatic booleanhasIndexedStructure(String rootPath) Determine if the specified directory contains a likely indexed filesystem.static booleanDetermine if the specified directory corresponds to an indexed filesystem.protected voiditemDeleted(String folderPath, String itemName) Notify the filesystem that the property file and associated data files for an item have been removed from the filesystem.voidmoveFolder(String parentPath, String folderName, String newParentPath) Move the specified folder to the path specified by newFolderPath.voidMoves the specified item to a new folder.static intreadIndexVersion(String rootPath) static booleanCompletely rebuild filesystem index using item information contained within indexed property files.voidrenameFolder(String parentPath, String folderName, String newFolderName) Renames the specified folder to a new name.Methods inherited from class ghidra.framework.store.local.LocalFileSystem
addFileSystemListener, checkDisposed, cleanupAfterConstruction, createDatabase, createDatabase, createDataFile, createFile, createTemporaryDatabase, deleteEmptyVersionedFolders, escapeHiddenDirPrefixChars, fileExists, fileIdChanged, getItem, getItem, getItemNames, getLocalFileSystem, getName, getParentPath, getPath, getUserName, isHiddenDirName, isOnline, isReadOnly, isRefreshRequired, isShared, isValidNameCharacter, isVersioned, log, migrationInProgress, removeFileSystemListener, setAssociatedRepositoryLogger, setValidationRequired, testValidName, unescapeHiddenDirPrefixChars
-
Field Details
-
LATEST_INDEX_VERSION
public static final int LATEST_INDEX_VERSION- See Also:
-
INDEX_ITEM_INDENT
- See Also:
-
INDEX_ITEM_SEPARATOR
- See Also:
-
-
Constructor Details
-
IndexedLocalFileSystem
Construct existing indexed filesystem with an empty index. This can be used to prepare for rebuilding the filesystem index.- Parameters:
rootPath-- Throws:
IOException
-
-
Method Details
-
getMaxNameLength
public int getMaxNameLength()- Specified by:
getMaxNameLengthin classLocalFileSystem- Returns:
- the maximum name length permitted for folders or items.
-
getItems
Description copied from interface:FileSystemReturns a list of the folder items contained in the given folder.- Specified by:
getItemsin interfaceFileSystem- Overrides:
getItemsin classLocalFileSystem- Parameters:
folderPath- the path of the folder.- Returns:
- a list of folder items. Null items may exist if index contained item name
while storage was not found. An
UnknownFolderItemmay be returned if unsupported item storage encountered. - Throws:
IOException
-
dispose
public void dispose()Description copied from interface:FileSystemCleanup and release resources- Specified by:
disposein interfaceFileSystem- Overrides:
disposein classLocalFileSystem
-
getIndexImplementationVersion
public int getIndexImplementationVersion() -
readIndexVersion
- Throws:
IOException
-
findItemStorage
protected LocalFileSystem.ItemStorage findItemStorage(String folderPath, String itemName) throws FileNotFoundException Find an existing storage location- Specified by:
findItemStoragein classLocalFileSystem- Parameters:
folderPath-itemName-- Returns:
- storage location. A non-null value does not guarantee that the associated item actually exists.
- Throws:
FileNotFoundException
-
allocateItemStorage
protected LocalFileSystem.ItemStorage allocateItemStorage(String folderPath, String itemName) throws IOException, InvalidNameException Allocate a new storage location- Specified by:
allocateItemStoragein classLocalFileSystem- Parameters:
folderPath-itemName-- Returns:
- storage location
- Throws:
DuplicateFileException- if item path has previously been allocatedIOException- if invalid path/item name specifiedInvalidNameException- if folderPath or itemName contains invalid characters
-
deallocateItemStorage
Deallocate item storage- Specified by:
deallocateItemStoragein classLocalFileSystem- Parameters:
folderPath-itemName-- Throws:
IOException
-
itemDeleted
Description copied from class:LocalFileSystemNotify the filesystem that the property file and associated data files for an item have been removed from the filesystem.- Overrides:
itemDeletedin classLocalFileSystem- Parameters:
folderPath-itemName-- Throws:
IOException
-
getItemNames
- Specified by:
getItemNamesin classLocalFileSystem- Throws:
IOException
-
getItemCount
Description copied from interface:FileSystemReturns the number of folder items contained within this file-system.- Throws:
IOException
-
getFolderNames
Description copied from interface:FileSystemReturn a list of subfolders (by name) that are stored within the specified folder path.- Throws:
IOException- if IO error occurs.
-
createFolder
public void createFolder(String parentPath, String folderName) throws InvalidNameException, IOException Description copied from interface:FileSystemCreates a new subfolder within the specified parent folder.- Parameters:
parentPath- folder path of parentfolderName- name of new subfolder- Throws:
InvalidNameException- if the name does not have all alphanumericsIOException- thrown if an IO error occurs.
-
deleteFolder
Description copied from interface:FileSystemDelete the specified folder.- Parameters:
folderPath- path of folder to be deleted- Throws:
IOException- if error occurred during delete.
-
moveItem
public void moveItem(String folderPath, String name, String newFolderPath, String newName) throws IOException, InvalidNameException Description copied from interface:FileSystemMoves the specified item to a new folder.- Specified by:
moveItemin interfaceFileSystem- Overrides:
moveItemin classLocalFileSystem- Parameters:
folderPath- path of folder containing the item.name- name of the item to be moved.newFolderPath- path of folder where item is to be moved.- Throws:
IOException- if an IO error occurs.InvalidNameException- if the newName is invalid
-
moveFolder
public void moveFolder(String parentPath, String folderName, String newParentPath) throws InvalidNameException, IOException Description copied from interface:FileSystemMove the specified folder to the path specified by newFolderPath. The moved folder must not be an ancestor of the new Parent.- Parameters:
parentPath- path of parent folder that the moving folder currently resides in.folderName- name of the folder within the parentPath to be moved.newParentPath- path to where the folder is to be moved.- Throws:
InvalidNameException- if the new FolderPath contains an illegal file name.IOException- if an IO error occurs.
-
renameFolder
public void renameFolder(String parentPath, String folderName, String newFolderName) throws InvalidNameException, IOException Description copied from interface:FileSystemRenames the specified folder to a new name.- Parameters:
parentPath- the parent folder of the folder to be renamed.folderName- the current name of the folder to be renamed.newFolderName- the name the folder to be renamed to.- Throws:
InvalidNameException- if the new FolderName contains an illegal file name.IOException- if an IO error occurs.
-
folderExists
Description copied from interface:FileSystemReturns true if the folder specified by the path exists.- Specified by:
folderExistsin interfaceFileSystem- Specified by:
folderExistsin classLocalFileSystem- Parameters:
folderPath- the name of the folder to check for existence.- Returns:
- true if the folder exists.
-
isIndexed
Determine if the specified directory corresponds to an indexed filesystem.- Parameters:
rootPath- filesystem root- Returns:
- true if filesystem contains an index (not mangled)
-
hasIndexedStructure
Determine if the specified directory contains a likely indexed filesystem.- Parameters:
rootPath- filesystem root- Returns:
- true if filesystem appears to be indexed (not mangled)
-
rebuild
Completely rebuild filesystem index using item information contained within indexed property files. Empty folders will be lost.- Parameters:
rootDir-- Throws:
IOException
-