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 booleancreateDirectory(java.io.File directory, java.lang.String name)Creates a directory in the specified directory with the specified name.protected java.lang.StringformatRootPathForDisplay(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.StringgetDescription(java.io.File file)Returns a description for the specified file.java.io.FilegetDesktopDirectory()Probes for a "Desktop" directory under the user's home directory.protected java.lang.StringgetFastRootDescriptionString(java.io.File root)Return a description string for a file system root.java.io.FilegetHomeDirectory()Returns the home directory.javax.swing.IcongetIcon(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.StringgetRootDescriptionString(java.io.File root)Return a description string for a root location.java.io.File[]getRoots()Returns the root drives/directories.chargetSeparator()Returns the file separator char.booleanisAbsolute(java.io.File file)Tests whether this abstract pathname is absolute.booleanisDirectory(java.io.File file)Tests whether the file denoted by this abstract pathname is a directory.booleanrenameFile(java.io.File src, java.io.File dest)Renames the src file to the dest file.voidsetListener(GhidraFileChooserListener l)Set the model listener.
-
-
-
Method Detail
-
getSeparator
public char getSeparator()
Description copied from interface:GhidraFileChooserModelReturns the file separator char. On windows, '\' On linux, '/'.- Specified by:
getSeparatorin interfaceGhidraFileChooserModel- Returns:
- the file separator char
- See Also:
GhidraFileChooserModel.getSeparator()
-
setListener
public void setListener(GhidraFileChooserListener l)
Description copied from interface:GhidraFileChooserModelSet the model listener.- Specified by:
setListenerin 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:GhidraFileChooserModelReturns the home directory.- Specified by:
getHomeDirectoryin 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:
getDesktopDirectoryin interfaceGhidraFileChooserModel- Returns:
- desktop directory
- See Also:
GhidraFileChooserModel.getDesktopDirectory()
-
getRoots
public java.io.File[] getRoots()
Description copied from interface:GhidraFileChooserModelReturns the root drives/directories. On windows, "C:\", "D:\", etc. On linux, "/".- Specified by:
getRootsin 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 threadfinishes.
-
getRootDescriptionString
protected java.lang.String getRootDescriptionString(java.io.File root)
Return a description string for a root location.Called from a
background threadto 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:GhidraFileChooserModelReturns an array of the files that exist in the specified directory.- Specified by:
getListingin 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:GhidraFileChooserModelReturns an icon for the specified file.- Specified by:
getIconin 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:GhidraFileChooserModelReturns a description for the specified file.- Specified by:
getDescriptionin 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:GhidraFileChooserModelCreates a directory in the specified directory with the specified name.- Specified by:
createDirectoryin 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:GhidraFileChooserModelTests whether the file denoted by this abstract pathname is a directory.- Specified by:
isDirectoryin interfaceGhidraFileChooserModel- Returns:
trueif and only if the file denoted by this abstract pathname exists and is a directory;falseotherwise- See Also:
GhidraFileChooserModel.isDirectory(java.io.File)
-
isAbsolute
public boolean isAbsolute(java.io.File file)
Description copied from interface:GhidraFileChooserModelTests 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:
isAbsolutein interfaceGhidraFileChooserModel- Returns:
trueif this abstract pathname is absolute,falseotherwise- See Also:
GhidraFileChooserModel.isAbsolute(java.io.File)
-
renameFile
public boolean renameFile(java.io.File src, java.io.File dest)Description copied from interface:GhidraFileChooserModelRenames the src file to the dest file.- Specified by:
renameFilein 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)
-
-