Package ghidra.formats.gfilesystem
Class FileSystemRefManager
- java.lang.Object
-
- ghidra.formats.gfilesystem.FileSystemRefManager
-
public class FileSystemRefManager extends java.lang.Object
A threadsafe helper class that manages creating and releasingFileSystemRef
instances and broadcasting events toFileSystemEventListener
listeners.
-
-
Constructor Summary
Constructors Constructor Description FileSystemRefManager(GFileSystem fs)
Creates a newFileSystemRefManager
pointing at the specifiedGFileSystem
.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addListener(FileSystemEventListener listener)
boolean
canClose(FileSystemRef callersRef)
Returns true if the onlyFileSystemRef
pinning this filesystem is the caller's ref.FileSystemRef
create()
Creates a newFileSystemRef
that points at the owningfilesystem
.void
finalize()
long
getLastUsedTimestamp()
void
onClose()
Called from theCloseable.close()
before any destructive changes have been made to gracefully shutdown the ref manager.void
release(FileSystemRef ref)
Releases an existingFileSystemRef
and broadcastsFileSystemEventListener.onFilesystemRefChange(GFileSystem, FileSystemRefManager)
to listeners.void
removeListener(FileSystemEventListener listener)
Removes a previously addedlistener
.
-
-
-
Constructor Detail
-
FileSystemRefManager
public FileSystemRefManager(GFileSystem fs)
Creates a newFileSystemRefManager
pointing at the specifiedGFileSystem
.- Parameters:
fs
-GFileSystem
to manage.
-
-
Method Detail
-
addListener
public void addListener(FileSystemEventListener listener)
- Parameters:
listener
-FileSystemEventListener
to receive callbacks, weakly refd and automagically removed if a reference isn't held to the listener somewhere else.
-
removeListener
public void removeListener(FileSystemEventListener listener)
Removes a previously addedlistener
.- Parameters:
listener
-FileSystemEventListener
to remove.
-
create
public FileSystemRef create()
Creates a newFileSystemRef
that points at the owningfilesystem
.- Returns:
- new
FileSystemRef
pointing at the filesystem, never null.
-
release
public void release(FileSystemRef ref)
Releases an existingFileSystemRef
and broadcastsFileSystemEventListener.onFilesystemRefChange(GFileSystem, FileSystemRefManager)
to listeners.- Parameters:
ref
- theFileSystemRef
to release.
-
canClose
public boolean canClose(FileSystemRef callersRef)
Returns true if the onlyFileSystemRef
pinning this filesystem is the caller's ref.- Parameters:
callersRef
-FileSystemRef
to test- Returns:
- boolean true if the tested
FileSystemRef
is the only ref pinning the filesystem.
-
onClose
public void onClose()
Called from theCloseable.close()
before any destructive changes have been made to gracefully shutdown the ref manager.Broadcasts
FileSystemEventListener.onFilesystemClose(GFileSystem)
.
-
finalize
public void finalize()
- Overrides:
finalize
in classjava.lang.Object
-
getLastUsedTimestamp
public long getLastUsedTimestamp()
-
-