diff options
Diffstat (limited to 'wizards/source/scriptforge/SF_FileSystem.xba')
-rw-r--r-- | wizards/source/scriptforge/SF_FileSystem.xba | 42 |
1 files changed, 41 insertions, 1 deletions
diff --git a/wizards/source/scriptforge/SF_FileSystem.xba b/wizards/source/scriptforge/SF_FileSystem.xba index d71937d6e64a..935c559f5c8e 100644 --- a/wizards/source/scriptforge/SF_FileSystem.xba +++ b/wizards/source/scriptforge/SF_FileSystem.xba @@ -86,7 +86,7 @@ End Property ' ScriptForge.SF_FileSystem.ConfigFolder REM ----------------------------------------------------------------------------- Property Get ExtensionsFolder() As String -''' Return the folder containing the installed extensions +''' Return the folder containing the extensions installed for the current user Dim oMacro As Object ' /singletons/com.sun.star.util.theMacroExpander Const cstThisSub = "FileSystem.getExtensionsFolder" @@ -651,6 +651,45 @@ Catch: End Function ' ScriptForge.SF_FileSystem.DeleteFolder REM ----------------------------------------------------------------------------- +Public Function ExtensionFolder(Optional ByVal Extension As Variant) As String +''' Return the folder where the given extension is installed. The argument must +''' be in the list of extensions provided by the SF_Platform.Extensions property +''' Args: +''' Extension: a valid extension name +''' Returns: +''' The requested folder using the FileNaming notation +''' Example: +''' MsgBox FSO.ExtensionFolder("apso.python.script.organizer") + +Dim sFolder As String ' Return value +Static vExtensions As Variant ' Cached list of existing extension names +Dim oPackage As Object ' /singletons/com.sun.star.deployment.PackageInformationProvider +Const cstThisSub = "FileSystem.ExtensionFolder" +Const cstSubArgs = "Extension" + + If SF_Utils._ErrorHandling() Then On Local Error GoTo Catch + sFolder = "" + +Check: + If IsEmpty(vExtensions) Then vExtensions = SF_Platform.Extensions + If SF_Utils._EnterFunction(cstThisSub, cstSubArgs) Then + If Not SF_Utils._Validate(Extension, "Extension", V_STRING, vExtensions) Then GoTo Finally + End If + +Try: + ' Search an individual folder + Set oPackage = SF_Utils._GetUnoService("PackageInformationProvider") + sFolder = oPackage.getPackageLocation(Extension) + +Finally: + ExtensionFolder = SF_FileSystem._ConvertFromUrl(sFolder) + SF_Utils._ExitFunction(cstThisSub) + Exit Function +Catch: + GoTo Finally +End Function ' ScritForge.SF_FileSystem.ExtensionFolder + +REM ----------------------------------------------------------------------------- Public Function FileExists(Optional ByVal FileName As Variant) As Boolean ''' Return True if the given file exists ''' Args: @@ -1215,6 +1254,7 @@ Public Function Methods() As Variant , "CreateTextFile" _ , "DeleteFile" _ , "DeleteFolder" _ + , "ExtensionFolder" _ , "FileExists" _ , "Files" _ , "FolderExists" _ |