Package ghidra.framework.data
Class DefaultProjectData
java.lang.Object
ghidra.framework.data.DefaultProjectData
- All Implemented Interfaces:
ProjectData,Iterable<DomainFile>
- Direct Known Subclasses:
TransientProjectData
Helper class to manage files within a project.
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionDefaultProjectData(ProjectLocator localStorageLocator, boolean isInWritableProject, boolean resetOwner) Constructor for existing projects.DefaultProjectData(ProjectLocator localStorageLocator, RepositoryAdapter repository, boolean isInWritableProject) Constructor for a new project. -
Method Summary
Modifier and TypeMethodDescriptionvoidAdds a listener that will be notified when any folder or file changes in the project.voidclose()Initiate disposal of this project data object.voidconvertProjectToShared(RepositoryAdapter newRepository, TaskMonitor monitor) Convert a local project to a shared project.protected voiddispose()Immediately dispose this project data store instance.findCheckedOutFiles(TaskMonitor monitor) Find all project files which are currently checked-outvoidfindOpenFiles(List<DomainFile> list) Finds all changed domain files and appends them to the specified list.Get domain file specified by an absolute data path.getFileByID(String fileID) Get domain file specified by its unique fileID.intGet the approximate number of files contained within the project.Get domain folder specified by an absolute data path.Generate a local URL which corresponds to this project data if applicable.Class<? extends LocalFileSystem> intgetOwner()Returns the owner of the project that is associated with this DefaultProjectData.Get monitor which will be cancelled if project is closedReturns the projectLocator for the this ProjectData.Return the repository for this project data.Returns the root folder of the project.Generate a repository URL which corresponds to this project data if applicable.getUser()Returns User object associated with remote repository or null if a remote repository is not used.static StringgetUserDataFilename(String associatedFileID) Returns the standard user data filename associated with the specified file ID.booleanhasInvalidCheckouts(List<DomainFile> checkoutList, RepositoryAdapter newRepository, TaskMonitor monitor) Determine if any domain files listed does not correspond to a checkout in the specified newRespository.booleanisClosed()booleanstatic booleanisLocked(ProjectLocator locator) Determine if the specified project location currently has a write lock.makeValidName(String name) Transform the specified name into an acceptable folder or file item name.static PropertiesreadProjectProperties(File projectDir) Read the contents of the project properties file to include the following values if relavent: "OWNER", "SERVER", "REPOSITORY_NAME", "PORT_NUMBER"voidrefresh(boolean force) Sync the Domain folder/file structure with the underlying file structure.voidreleaseDomainFiles(Object consumer) voidRemoves the listener to be notified of folder and file changes.voidremoveFromIndex(String fileID) Remove specified fileID from index.voidtestValidName(String name, boolean isPath) Validate a folder/item name or path.voidupdateFileIndex(GhidraFileData fileData) Update the file index for the specified file datavoidupdateRepositoryInfo(RepositoryAdapter newRepository, boolean force, TaskMonitor monitor) Update the repository for this project; the server may have changed or a different repository is being used.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface java.lang.Iterable
forEach, spliteratorMethods inherited from interface ghidra.framework.model.ProjectData
iterator
-
Field Details
-
MANGLED_DATA_FOLDER_NAME
- See Also:
-
INDEXED_DATA_FOLDER_NAME
- See Also:
-
USER_FOLDER_NAME
- See Also:
-
VERSIONED_FOLDER_NAME
- See Also:
-
SERVER_NAME
- See Also:
-
PORT_NUMBER
- See Also:
-
REPOSITORY_NAME
- See Also:
-
OWNER
- See Also:
-
-
Constructor Details
-
DefaultProjectData
public DefaultProjectData(ProjectLocator localStorageLocator, boolean isInWritableProject, boolean resetOwner) throws NotOwnerException, IOException, LockException Constructor for existing projects.- Parameters:
localStorageLocator- the location of the projectisInWritableProject- true if project content is writable, false if project is read-onlyresetOwner- true to reset the project owner- Throws:
IOException- if an i/o error occursNotOwnerException- if inProject is true and user is not ownerLockException- ifisInWritableProjectis true and unable to establish project write lock (i.e., project in-use)FileNotFoundException- if project directory not found
-
DefaultProjectData
public DefaultProjectData(ProjectLocator localStorageLocator, RepositoryAdapter repository, boolean isInWritableProject) throws IOException, LockException Constructor for a new project.- Parameters:
localStorageLocator- the location of the projectrepository- a repository if this is a shared project or null if it is a private projectisInWritableProject- true if project content is writable, false if project is read-only- Throws:
IOException- if an i/o error occursLockException- ifisInWritableProjectis true and unable to establish project lock (i.e., project in-use)
-
-
Method Details
-
readProjectProperties
Read the contents of the project properties file to include the following values if relavent: "OWNER", "SERVER", "REPOSITORY_NAME", "PORT_NUMBER"- Parameters:
projectDir- project directory (*.rep)- Returns:
- project properties or null if invalid project directory specified
-
isLocked
Determine if the specified project location currently has a write lock.- Parameters:
locator- project storage locator- Returns:
- true if project data current has write-lock else false
-
getMaxNameLength
public int getMaxNameLength()- Specified by:
getMaxNameLengthin interfaceProjectData- Returns:
- the maximum name length permitted for folders or items.
-
testValidName
Description copied from interface:ProjectDataValidate a folder/item name or path.- Specified by:
testValidNamein interfaceProjectData- Parameters:
name- folder or item nameisPath- if true name represents full path- Throws:
InvalidNameException- if name is invalid
-
getUser
Description copied from interface:ProjectDataReturns User object associated with remote repository or null if a remote repository is not used.- Specified by:
getUserin interfaceProjectData- Returns:
- current remote user identity or null
-
getLocalStorageClass
- Specified by:
getLocalStorageClassin interfaceProjectData- Returns:
- local storage implementation class
-
getOwner
Returns the owner of the project that is associated with this DefaultProjectData. A value of null indicates an old multiuser project.- Returns:
- the owner of the project
-
getRootFolder
Description copied from interface:ProjectDataReturns the root folder of the project.- Specified by:
getRootFolderin interfaceProjectData- Returns:
- root
DomainFolderwithin project.
-
getFolder
Description copied from interface:ProjectDataGet domain folder specified by an absolute data path.- Specified by:
getFolderin interfaceProjectData- Parameters:
path- the absolute path of domain folder relative to the data folder.- Returns:
- domain folder or null if folder not found
-
getFileCount
public int getFileCount()Description copied from interface:ProjectDataGet the approximate number of files contained within the project. The number may be reduced if not connected to the shared repository. Only the newer indexed file-system supports this capability, a value of -1 will be returned for older projects utilizing the mangled file-system or if an IO Error occurs. An approximate number is provided since the two underlying file systems are consulted separately and the local private file-system does not distinguish between checked-out files and private files. This number is currently intended as a rough sizing number to disable certain features when very large projects are in use. Generally the larger of the two file counts will be returned.- Specified by:
getFileCountin interfaceProjectData- Returns:
- number of project files or -1 if unknown.
-
getFile
Description copied from interface:ProjectDataGet domain file specified by an absolute data path.- Specified by:
getFilein interfaceProjectData- Parameters:
path- the absolute path of domain file relative to the root folder.- Returns:
- domain file or null if file not found
-
getFileByID
Description copied from interface:ProjectDataGet domain file specified by its unique fileID.- Specified by:
getFileByIDin interfaceProjectData- Parameters:
fileID- domain file ID- Returns:
- domain file or null if file not found
-
releaseDomainFiles
-
findOpenFiles
Finds all changed domain files and appends them to the specified list.- Specified by:
findOpenFilesin interfaceProjectData- Parameters:
list- the list to receive the changed domain files
-
getProjectLocator
Description copied from interface:ProjectDataReturns the projectLocator for the this ProjectData.- Specified by:
getProjectLocatorin interfaceProjectData- Returns:
- project locator object
-
addDomainFolderChangeListener
Description copied from interface:ProjectDataAdds a listener that will be notified when any folder or file changes in the project.- Specified by:
addDomainFolderChangeListenerin interfaceProjectData- Parameters:
l- the listener to be notified of folder and file changes.
-
removeDomainFolderChangeListener
Description copied from interface:ProjectDataRemoves the listener to be notified of folder and file changes.- Specified by:
removeDomainFolderChangeListenerin interfaceProjectData- Parameters:
l- the listener to be removed.
-
getPrivateFileSystem
-
getRepository
Description copied from interface:ProjectDataReturn the repository for this project data.- Specified by:
getRepositoryin interfaceProjectData- Returns:
- null if the project is not associated with a repository
-
refresh
public void refresh(boolean force) Description copied from interface:ProjectDataSync the Domain folder/file structure with the underlying file structure.- Specified by:
refreshin interfaceProjectData- Parameters:
force- if true all folders will be visited and refreshed, if false only those folders previously visited will be refreshed.
-
updateRepositoryInfo
public void updateRepositoryInfo(RepositoryAdapter newRepository, boolean force, TaskMonitor monitor) throws IOException, CancelledException Description copied from interface:ProjectDataUpdate the repository for this project; the server may have changed or a different repository is being used. Any existing checkout which is not recognized/valid by newRepository will be terminated and a local .keep file created. NOTE: The project should be closed and then reopened after this method is called.- Specified by:
updateRepositoryInfoin interfaceProjectData- Parameters:
newRepository- new repository to useforce- if true any existing local checkout which is not recognized/valid for newRepository will be forceably terminated if offline with old repository.monitor- task monitor- Throws:
IOException- thrown if files are still checked out, or if there was a problem accessing the filesystemCancelledException- if the user canceled the update
-
hasInvalidCheckouts
public boolean hasInvalidCheckouts(List<DomainFile> checkoutList, RepositoryAdapter newRepository, TaskMonitor monitor) throws IOException, CancelledException Determine if any domain files listed does not correspond to a checkout in the specified newRespository.- Specified by:
hasInvalidCheckoutsin interfaceProjectData- Parameters:
checkoutList- project domain files to checknewRepository- repository to check against before updatingmonitor- task monitor- Returns:
- true if one or more files are not valid checkouts in newRepository
- Throws:
IOException- if IO error occursCancelledException- if task cancelled
-
findCheckedOutFiles
public List<DomainFile> findCheckedOutFiles(TaskMonitor monitor) throws IOException, CancelledException Find all project files which are currently checked-out- Specified by:
findCheckedOutFilesin interfaceProjectData- Parameters:
monitor- task monitor (no progress updates)- Returns:
- list of current checkout files
- Throws:
IOException- if IO error occursCancelledException- if task cancelled
-
getLocalProjectURL
Description copied from interface:ProjectDataGenerate a local URL which corresponds to this project data if applicable. Remote transient project data will return null;- Specified by:
getLocalProjectURLin interfaceProjectData- Returns:
- local URL which corresponds to this project data or null if not applicable.
-
getUserDataFilename
Returns the standard user data filename associated with the specified file ID.- Parameters:
associatedFileID- the file id- Returns:
- user data filename
-
makeValidName
Description copied from interface:ProjectDataTransform the specified name into an acceptable folder or file item name. Only an individual folder or file name should be specified, since any separators will be stripped-out. NOTE: Uniqueness of name within the intended target folder is not considered.- Specified by:
makeValidNamein interfaceProjectData- Parameters:
name-- Returns:
- valid name or "unknown" if no valid characters exist within name provided
-
getProjectDir
-
isClosed
public boolean isClosed() -
isDisposed
public boolean isDisposed() -
close
public void close()Description copied from interface:ProjectDataInitiate disposal of this project data object. Any files already open will delay disposal until they are closed. NOTE: This should only be invoked by the controlling object which created/opened this instance to avoid premature disposal.- Specified by:
closein interfaceProjectData
-
dispose
protected void dispose()Immediately dispose this project data store instance. If this project has an associatedRepositoryAdapterit will be disconnected as well. This method should generally not be used directly when there may be openDomainObjectinstances which may rely on an associated server connection. TheObject.clone()method should be used when openDomainObjectinstances may exist and should be allowed to persist until they are closed. -
updateFileIndex
Update the file index for the specified file data- Parameters:
fileData- file data
-
removeFromIndex
Remove specified fileID from index.- Parameters:
fileID- the file ID
-
getProjectDisposalMonitor
Get monitor which will be cancelled if project is closed- Returns:
- cancel monitor
-