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
public class IndexedLocalFileSystem extends LocalFileSystem
IndexedLocalFileSystemimplements 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 Classes Modifier and Type Class Description static classIndexedLocalFileSystem.BadStorageNameExceptionBadStorageNameExceptioninvalid storage name encountered.static classIndexedLocalFileSystem.IndexReadExceptionIndexReadExceptionoccurs when an error occurs while reading/processing the filesystem indexstatic classIndexedLocalFileSystem.IndexVersionExceptionIndexReadExceptionoccurs when an error occurs while reading/processing the filesystem index-
Nested classes/interfaces inherited from class ghidra.framework.store.local.LocalFileSystem
LocalFileSystem.ItemStorage
-
-
Field Summary
Fields Modifier and Type Field Description protected static java.lang.StringINDEX_ITEM_INDENTprotected static java.lang.StringINDEX_ITEM_SEPARATORstatic intLATEST_INDEX_VERSION-
Fields inherited from class ghidra.framework.store.local.LocalFileSystem
HIDDEN_DIR_PREFIX, HIDDEN_DIR_PREFIX_CHAR, HIDDEN_ITEM_PREFIX, isVersioned, listeners, readOnly, root
-
Fields inherited from interface ghidra.framework.store.FileSystem
SEPARATOR, SEPARATOR_CHAR
-
-
Constructor Summary
Constructors Modifier Constructor Description protectedIndexedLocalFileSystem(java.lang.String rootPath)Construct existing indexed filesystem with an empty index.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description protected LocalFileSystem.ItemStorageallocateItemStorage(java.lang.String folderPath, java.lang.String itemName)Allocate a new storage locationvoidcreateFolder(java.lang.String parentPath, java.lang.String folderName)Creates a new subfolder within the specified parent folder.protected voiddeallocateItemStorage(java.lang.String folderPath, java.lang.String itemName)Deallocate item storagevoiddeleteFolder(java.lang.String folderPath)Delete the specified folder.voiddispose()Cleanup & release resourcesprotected LocalFileSystem.ItemStoragefindItemStorage(java.lang.String folderPath, java.lang.String itemName)Find an existing storage locationbooleanfolderExists(java.lang.String folderPath)Returns true if the folder specified by the path exists.java.lang.String[]getFolderNames(java.lang.String folderPath)Return a list of subfolders (by name) that are stored within the specified folder path.intgetIndexImplementationVersion()intgetItemCount()Returns the number of folder items contained within this file-system.protected java.lang.String[]getItemNames(java.lang.String folderPath, boolean includeHiddenFiles)intgetMaxNameLength()static booleanhasIndexedStructure(java.lang.String rootPath)Determine if the specified directory contains a likely indexed filesystem.static booleanisIndexed(java.lang.String rootPath)Determine if the specified directory corresponds to an indexed filesystem.protected voiditemDeleted(java.lang.String folderPath, java.lang.String itemName)Notify the filesystem that the property file and associated data files for an item have been removed from the filesystem.voidmoveFolder(java.lang.String parentPath, java.lang.String folderName, java.lang.String newParentPath)Move the specified folder to the path specified by newFolderPath.voidmoveItem(java.lang.String folderPath, java.lang.String name, java.lang.String newFolderPath, java.lang.String newName)Moves the specified item to a new folder.static intreadIndexVersion(java.lang.String rootPath)static booleanrebuild(java.io.File rootDir)Completely rebuild filesystem index using item information contained within indexed property files.voidrenameFolder(java.lang.String parentPath, java.lang.String folderName, java.lang.String newFolderName)Renames the specified folder to a new name.-
Methods inherited from class ghidra.framework.store.local.LocalFileSystem
addFileSystemListener, 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 Detail
-
LATEST_INDEX_VERSION
public static final int LATEST_INDEX_VERSION
- See Also:
- Constant Field Values
-
INDEX_ITEM_INDENT
protected static final java.lang.String INDEX_ITEM_INDENT
- See Also:
- Constant Field Values
-
INDEX_ITEM_SEPARATOR
protected static final java.lang.String INDEX_ITEM_SEPARATOR
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
IndexedLocalFileSystem
protected IndexedLocalFileSystem(java.lang.String rootPath) throws java.io.IOExceptionConstruct existing indexed filesystem with an empty index. This can be used to prepare for rebuilding the filesystem index.- Parameters:
rootPath-- Throws:
java.io.IOException
-
-
Method Detail
-
getMaxNameLength
public int getMaxNameLength()
- Specified by:
getMaxNameLengthin classLocalFileSystem
-
dispose
public void dispose()
Description copied from interface:FileSystemCleanup & release resources- Specified by:
disposein interfaceFileSystem- Overrides:
disposein classLocalFileSystem
-
getIndexImplementationVersion
public int getIndexImplementationVersion()
-
readIndexVersion
public static int readIndexVersion(java.lang.String rootPath) throws java.io.IOException- Throws:
java.io.IOException
-
findItemStorage
protected LocalFileSystem.ItemStorage findItemStorage(java.lang.String folderPath, java.lang.String itemName) throws java.io.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:
java.io.FileNotFoundException
-
allocateItemStorage
protected LocalFileSystem.ItemStorage allocateItemStorage(java.lang.String folderPath, java.lang.String itemName) throws java.io.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 allocatedjava.io.IOException- if invalid path/item name specifiedInvalidNameException- if folderPath or itemName contains invalid characters
-
deallocateItemStorage
protected void deallocateItemStorage(java.lang.String folderPath, java.lang.String itemName) throws java.io.IOExceptionDeallocate item storage- Specified by:
deallocateItemStoragein classLocalFileSystem- Parameters:
folderPath-itemName-- Throws:
java.io.IOException
-
itemDeleted
protected void itemDeleted(java.lang.String folderPath, java.lang.String itemName) throws java.io.IOExceptionDescription 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- Throws:
java.io.IOException
-
getItemNames
protected java.lang.String[] getItemNames(java.lang.String folderPath, boolean includeHiddenFiles) throws java.io.IOException- Specified by:
getItemNamesin classLocalFileSystem- Throws:
java.io.IOException
-
getItemCount
public int getItemCount() throws java.io.IOExceptionDescription copied from interface:FileSystemReturns the number of folder items contained within this file-system.- Throws:
java.io.IOException
-
getFolderNames
public java.lang.String[] getFolderNames(java.lang.String folderPath) throws java.io.IOExceptionDescription copied from interface:FileSystemReturn a list of subfolders (by name) that are stored within the specified folder path.- Throws:
java.io.FileNotFoundException- if folder path does not exist.java.io.IOException- if IO error occurs.
-
createFolder
public void createFolder(java.lang.String parentPath, java.lang.String folderName) throws InvalidNameException, java.io.IOExceptionDescription 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 alphanumericsDuplicateFileException- if a folder exists with this namejava.io.IOException- thrown if an IO error occurs.
-
deleteFolder
public void deleteFolder(java.lang.String folderPath) throws java.io.IOExceptionDescription copied from interface:FileSystemDelete the specified folder.- Parameters:
folderPath- path of folder to be deleted- Throws:
FolderNotEmptyException- Thrown if the folder is not empty.java.io.FileNotFoundException- if there is no folder with the given path name.java.io.IOException- if error occured during delete.
-
moveItem
public void moveItem(java.lang.String folderPath, java.lang.String name, java.lang.String newFolderPath, java.lang.String newName) throws java.io.IOException, InvalidNameExceptionDescription 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:
java.io.FileNotFoundException- if the item does not exist.DuplicateFileException- if item with the same name exists within the new parent folder.FileInUseException- if the item is in-use or checked-outjava.io.IOException- if an IO error occurs.InvalidNameException- if the newName is invalid
-
moveFolder
public void moveFolder(java.lang.String parentPath, java.lang.String folderName, java.lang.String newParentPath) throws InvalidNameException, java.io.IOExceptionDescription 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.java.io.FileNotFoundException- if the moved folder does not exist.DuplicateFileException- if folder with the same name exists within the new parent folderFileInUseException- if any file within this folder or its decendents are in-use or checked-outjava.io.IOException- if an IO error occurs.
-
renameFolder
public void renameFolder(java.lang.String parentPath, java.lang.String folderName, java.lang.String newFolderName) throws InvalidNameException, java.io.IOExceptionDescription 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.java.io.FileNotFoundException- if the folder to be renamed does not exist.DuplicateFileException- if folder with the new name already exists.FileInUseException- if any file within this folder or its decendents are in-use or checked-outjava.io.IOException- if an IO error occurs.
-
folderExists
public boolean folderExists(java.lang.String folderPath)
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
public static boolean isIndexed(java.lang.String rootPath)
Determine if the specified directory corresponds to an indexed filesystem.- Parameters:
rootPath- filesystem root- Returns:
- true if filesystem contains an index (not mangled)
-
hasIndexedStructure
public static boolean hasIndexedStructure(java.lang.String rootPath)
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
public static boolean rebuild(java.io.File rootDir) throws java.io.IOExceptionCompletely rebuild filesystem index using item information contained within indexed property files. Empty folders will be lost.- Parameters:
rootDir-- Throws:
java.io.IOException
-
-