Package docking.widgets.filechooser
Class LocalFileChooserModel
- java.lang.Object
-
- docking.widgets.filechooser.LocalFileChooserModel
-
- All Implemented Interfaces:
GhidraFileChooserModel
public class LocalFileChooserModel extends java.lang.Object implements GhidraFileChooserModel
A default implementation of the file chooser model that browses the local file system.
-
-
Constructor Summary
Constructors Constructor Description LocalFileChooserModel()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
createDirectory(java.io.File directory, java.lang.String name)
Creates a directory in the specified directory with the specified name.protected java.lang.String
formatRootPathForDisplay(java.io.File root)
Returns the string path of a file system root, formatted so it doesn't have a trailing backslash in the case of Windows root drive strings such as "c:\\", which becomes "c:"java.lang.String
getDescription(java.io.File file)
Returns a description for the specified file.java.io.File
getDesktopDirectory()
Probes for a "Desktop" directory under the user's home directory.protected java.lang.String
getFastRootDescriptionString(java.io.File root)
Return a description string for a file system root.java.io.File
getHomeDirectory()
Returns the home directory.javax.swing.Icon
getIcon(java.io.File file)
Returns an icon for the specified file.java.io.File[]
getListing(java.io.File directory, java.io.FileFilter filter)
Returns an array of the files that exist in the specified directory.protected java.lang.String
getRootDescriptionString(java.io.File root)
Return a description string for a root location.java.io.File[]
getRoots()
Returns the root drives/directories.char
getSeparator()
Returns the file separator char.boolean
isAbsolute(java.io.File file)
Tests whether this abstract pathname is absolute.boolean
isDirectory(java.io.File file)
Tests whether the file denoted by this abstract pathname is a directory.boolean
renameFile(java.io.File src, java.io.File dest)
Renames the src file to the dest file.void
setListener(GhidraFileChooserListener l)
Set the model listener.
-
-
-
Method Detail
-
getSeparator
public char getSeparator()
Description copied from interface:GhidraFileChooserModel
Returns the file separator char. On windows, '\' On linux, '/'.- Specified by:
getSeparator
in interfaceGhidraFileChooserModel
- Returns:
- the file separator char
- See Also:
GhidraFileChooserModel.getSeparator()
-
setListener
public void setListener(GhidraFileChooserListener l)
Description copied from interface:GhidraFileChooserModel
Set the model listener.- Specified by:
setListener
in interfaceGhidraFileChooserModel
- Parameters:
l
- the new model listener- See Also:
GhidraFileChooserModel.setListener(ghidra.util.filechooser.GhidraFileChooserListener)
-
getHomeDirectory
public java.io.File getHomeDirectory()
Description copied from interface:GhidraFileChooserModel
Returns the home directory.- Specified by:
getHomeDirectory
in interfaceGhidraFileChooserModel
- Returns:
- the home directory
- See Also:
GhidraFileChooserModel.getHomeDirectory()
-
getDesktopDirectory
public java.io.File getDesktopDirectory()
Probes for a "Desktop" directory under the user's home directory.Returns null if the desktop directory is missing.
- Specified by:
getDesktopDirectory
in interfaceGhidraFileChooserModel
- Returns:
- desktop directory
- See Also:
GhidraFileChooserModel.getDesktopDirectory()
-
getRoots
public java.io.File[] getRoots()
Description copied from interface:GhidraFileChooserModel
Returns the root drives/directories. On windows, "C:\", "D:\", etc. On linux, "/".- Specified by:
getRoots
in interfaceGhidraFileChooserModel
- Returns:
- the root drives
- See Also:
GhidraFileChooserModel.getRoots()
-
getFastRootDescriptionString
protected java.lang.String getFastRootDescriptionString(java.io.File root)
Return a description string for a file system root. Avoid slow calls (such asFileSystemView.getSystemDisplayName(File)
.Used when pre-populating the root description map with values before
background thread
finishes.
-
getRootDescriptionString
protected java.lang.String getRootDescriptionString(java.io.File root)
Return a description string for a root location.Called from a
background thread
to avoid blocking the UI while waiting for slow file systems.- Parameters:
root
-- Returns:
- string such as "Local Disk (C:)", "Network Drive (R:)"
-
formatRootPathForDisplay
protected java.lang.String formatRootPathForDisplay(java.io.File root)
Returns the string path of a file system root, formatted so it doesn't have a trailing backslash in the case of Windows root drive strings such as "c:\\", which becomes "c:"
-
getListing
public java.io.File[] getListing(java.io.File directory, java.io.FileFilter filter)
Description copied from interface:GhidraFileChooserModel
Returns an array of the files that exist in the specified directory.- Specified by:
getListing
in interfaceGhidraFileChooserModel
- Parameters:
directory
- the directory- Returns:
- an array of files
- See Also:
GhidraFileChooserModel.getListing(java.io.File, java.io.FileFilter)
-
getIcon
public javax.swing.Icon getIcon(java.io.File file)
Description copied from interface:GhidraFileChooserModel
Returns an icon for the specified file.- Specified by:
getIcon
in interfaceGhidraFileChooserModel
- Parameters:
file
- the file- Returns:
- an icon for the specified file
- See Also:
GhidraFileChooserModel.getIcon(java.io.File)
-
getDescription
public java.lang.String getDescription(java.io.File file)
Description copied from interface:GhidraFileChooserModel
Returns a description for the specified file.- Specified by:
getDescription
in interfaceGhidraFileChooserModel
- Parameters:
file
- the file- Returns:
- a description for the specified file
- See Also:
GhidraFileChooserModel.getDescription(java.io.File)
-
createDirectory
public boolean createDirectory(java.io.File directory, java.lang.String name)
Description copied from interface:GhidraFileChooserModel
Creates a directory in the specified directory with the specified name.- Specified by:
createDirectory
in interfaceGhidraFileChooserModel
- Parameters:
directory
- the directory in which to create the new directoryname
- the name of the directory- Returns:
- true if the new directory was create.
- See Also:
GhidraFileChooserModel.createDirectory(java.io.File, java.lang.String)
-
isDirectory
public boolean isDirectory(java.io.File file)
Description copied from interface:GhidraFileChooserModel
Tests whether the file denoted by this abstract pathname is a directory.- Specified by:
isDirectory
in interfaceGhidraFileChooserModel
- Returns:
true
if and only if the file denoted by this abstract pathname exists and is a directory;false
otherwise- See Also:
GhidraFileChooserModel.isDirectory(java.io.File)
-
isAbsolute
public boolean isAbsolute(java.io.File file)
Description copied from interface:GhidraFileChooserModel
Tests whether this abstract pathname is absolute. The definition of absolute pathname is system dependent. On UNIX systems, a pathname is absolute if its prefix is"/"
. On Microsoft Windows systems, a pathname is absolute if its prefix is a drive specifier followed by"\\"
, or if its prefix is"\\"
.- Specified by:
isAbsolute
in interfaceGhidraFileChooserModel
- Returns:
true
if this abstract pathname is absolute,false
otherwise- See Also:
GhidraFileChooserModel.isAbsolute(java.io.File)
-
renameFile
public boolean renameFile(java.io.File src, java.io.File dest)
Description copied from interface:GhidraFileChooserModel
Renames the src file to the dest file.- Specified by:
renameFile
in interfaceGhidraFileChooserModel
- Parameters:
src
- the file to be renameddest
- the new file- Returns:
- true if the file was renamed
- See Also:
GhidraFileChooserModel.renameFile(java.io.File, java.io.File)
-
-