Package ghidra.formats.gfilesystem

# Class FileSystemRefManager

java.lang.Object
ghidra.formats.gfilesystem.FileSystemRefManager

public class FileSystemRefManager extends Object
A threadsafe helper class that manages creating and releasing `FileSystemRef` instances and broadcasting events to `FileSystemEventListener` listeners.

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `FileSystemRefManager(GFileSystem fs)`
  Creates a new `FileSystemRefManager` pointing at the specified `GFileSystem`.

- ## Method Summary

  Modifier and Type
  Method
  Description
  `void`
  `addListener(FileSystemEventListener listener)`
  Adds a `listener` that will be called when this filesystem is `closed` or when `refs change`.
  `boolean`
  `canClose(FileSystemRef callersRef)`
  Returns true if the only `FileSystemRef` pinning this filesystem is the caller's ref.
  `FileSystemRef`
  `create()`
  Creates a new `FileSystemRef` that points at the owning `filesystem`.
  `void`
  `finalize()`
  `long`
  `getLastUsedTimestamp()`
  `void`
  `onClose()`
  Called from the `Closeable.close()` before any destructive changes have been made to gracefully shutdown the ref manager.
  `void`
  `release(FileSystemRef ref)`
  Releases an existing `FileSystemRef` and broadcasts `FileSystemEventListener.onFilesystemRefChange(GFileSystem, FileSystemRefManager)` to listeners.
  `void`
  `removeListener(FileSystemEventListener listener)`
  Removes a previously added `listener`.

  ### Methods inherited from class java.lang.Object

  `clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- ## Constructor Details

  - ### FileSystemRefManager

    public FileSystemRefManager(GFileSystem fs)
    Creates a new `FileSystemRefManager` pointing at the specified `GFileSystem`.
    Parameters:
      `fs` - `GFileSystem` to manage.

- ## Method Details

  - ### addListener

    public void addListener(FileSystemEventListener listener)
    Adds a `listener` that will be called when this filesystem is `closed` or when `refs change`.
    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 added `listener`.
    Parameters:
      `listener` - `FileSystemEventListener` to remove.

  - ### create

    public FileSystemRef create()
    Creates a new `FileSystemRef` that points at the owning `filesystem`.
    Returns:
      new `FileSystemRef` pointing at the filesystem, never null.

  - ### release

    public void release(FileSystemRef ref)
    Releases an existing `FileSystemRef` and broadcasts `FileSystemEventListener.onFilesystemRefChange(GFileSystem, FileSystemRefManager)` to listeners.
    Parameters:
      `ref` - the `FileSystemRef` to release.

  - ### canClose

    public boolean canClose(FileSystemRef callersRef)
    Returns true if the only `FileSystemRef` 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 the `Closeable.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 class `Object`

  - ### getLastUsedTimestamp

    public long getLastUsedTimestamp()