Interface DelphiResources
-
Method Summary
Modifier and TypeMethodDescriptioncreateDirectoryModule
(@NotNull Path path) Create a directory module with the specifiedpath
as the directory.createZipModule
(@NotNull Path zipPath) Create a zip module from the specifiedzipPath
.findModule
(String moduleName) Attempts to locate a module.Gets the module directory.Gets an array list of all module names.boolean
registerModule
(@NotNull String moduleName, @NotNull ResourceModule module) Registers a module.boolean
unregisterModule
(@Nullable String moduleName) Unregisters a module
-
Method Details
-
getModuleDirectory
Path getModuleDirectory()Gets the module directory.The returned path is the
modules
directory inside the Delphi plugin's data folder.- Returns:
- Module directory
-
createDirectoryModule
Create a directory module with the specifiedpath
as the directory.- Parameters:
path
- Directory path- Returns:
- Created module.
- Throws:
NullPointerException
- Ifpath
isnull
-
createZipModule
Create a zip module from the specifiedzipPath
.This method will attempt to immediately open and read the zip file into memory, and will return an erroneous result if it fails to do so for any reason.
Error messages Format Description "No Such File"
zipPath
file doesn't exist"Access Denied: %reason%"
Read access was denied to the zip file "IO Error: %message%"
Threw an IOException
- Parameters:
zipPath
- Zip file path- Returns:
- A successful result if the zip archive was opened, otherwise an erroneous result.
- Throws:
NullPointerException
- IfzipPath
isnull
-
registerModule
boolean registerModule(@NotNull @NotNull String moduleName, @NotNull @NotNull ResourceModule module) Registers a module.This method will return
false
if another module has already been registered with the specifiedmoduleName
.- Parameters:
moduleName
- Name of the module.module
- Module.- Returns:
true
, if the module was registered,false
, if the specified name is already in use.- Throws:
NullPointerException
- If eithermoduleName
ormodule
isnull
.IllegalArgumentException
- If the module name doesn't pass theResourcePath.validateQuery(String)
check.
-
unregisterModule
Unregisters a moduleWhen a module is unregistered, all pages open to the specified module are closed as well.
This method only unregisters modules that were registered with the
registerModule(String, ResourceModule)
method. Any modules inside thegetModuleDirectory()
cannot be unregistered.- Parameters:
moduleName
- Module name- Returns:
true
if a module with themoduleName
was found and was removed,false
otherwise.
-
findModule
Attempts to locate a module.This will first attempt to find a module registered with
registerModule(String, ResourceModule)
. No registered module is found, it will attempt to find a directory or a zip archive with the specified name.This method assumes the input has no file extension.
Result errors Error code Description ERR_EMPTY_MODULE_NAME
The module name was empty or null
ERR_MODULE_DIRECTORY_NOT_FOUND
Couldn't find any registered modules matching the name, and the module directory doesn't exist ERR_MODULE_ZIP_ACCESS_DENIED
Attempted to open a .zip
module file, but access was deniedERR_IO_ERROR
An IO error occurred while trying to read a .zip
module fileERR_MODULE_UNKNOWN
No registered module, directory or .zip
module was found that matched the specifiedmoduleName
- Parameters:
moduleName
- Name of the module- Returns:
- Found module, or an erroneous result if no module was found.
-
getModuleNames
Gets an array list of all module names. This list inclues all registered modules as well as all directory and zip archive modules installed ingetModuleDirectory()
- Returns:
- Module name list.
-