String :: executePath - Execute action according to file type
The function executes the file passed in the string according to the file type, which is associated with the file extension. Usually, the action passed to the function in sShellAction is open, which will open the file according to its extension type. One may, however, pass any other action name and parameters, which are supported by the program called for the file extension. Typical actions are edit, print, browse and find.
By default, the function returns without waiting for terminating the process. In order to wait for process termination true has to be passed in bWait.
File associations have to be defined in an option section FileAssociations, which has to be provided in the configuration file or via database option settings. The structure of this section is as follows:
FileAssociations
extension1 default_call
action_name1 action_call
...
action_nameN action_call
...
extensionM (section for next extension ...)
...
The option hierarchy has three levels, which requires extended ini-file specification or use of xml configuration files, instead.
extension - name of extension (e.g. odt for open office documents)
action_name - name of action to be executed. For a file association, any number of actions may be defined. Typical actions used are open, print, browse, but any other kind of action may be defined.
action_call, default_call - function call for the required action
Action call strings may contain following placeholders:
- %f - replaced by complete file path as passed to the function
- %p - replaced by parameter(s) passed to the function
- %a - replaced by action name
The call string may also contain any number of option settings as %option%., which are replaced by appropriate option values before calling the action.
When no action has been passed to the function, the default call as being defined for the extension option is used. The default call is also used, when passing an unknown action. When passing an unknown action and not defining a default call, the function throws an exception.
The function also throws an exception, when the action call could not be executed.
FileAssociations ACCEPT
odt libreoffice "%f" %p
open libreoffice "%f" %p
print libreoffice -p "%f" %p
to_pdf libreoffice --invisible --convert-to pdf "%f" %p
Implementation overview
- Call action with action name and parameters
String :: executePath ( sShellAction, sParameter ) - Execute path with default action
String :: executePath (  ) - Call default action with parameters
String :: executePath ( sParameter ) - Call action asynchronously
String :: executePath ( sShellAction, sParameter, bWait )
Implementation details
-
Call action with action name and parameters
String  :: executePath ( odaba::String &sShellAction, odaba::String &sParameter )
The function is called with an action name and a parameter list. The action name must be defined as action (sub-option for the file extension name). When no such option could be found, the default action defined fir the extension name option is executed.
- sShellAction
- Action
Name of the action to be called. Typical actions are open, print, find, edit and browse.
- sParameter
- Parameter value
Parameter values allow passing one or more parameters in a parameter string. Usually, parameters are separated by spaces. Parameters containing spaces have to be quoted using double quotes.
to list
- sShellAction
- Action
-
Execute path with default action
String  :: executePath (  )
The path is executed with the default action defined for the extension.
to list
-
Call default action with parameters
String  :: executePath ( odaba::String &sParameter )
The function is called with parameters for replacing %p variables in default call definition for extension.
- sParameter
- Parameter value
Parameter values allow passing one or more parameters in a parameter string. Usually, parameters are separated by spaces. Parameters containing spaces have to be quoted using double quotes.
to list
- sParameter
- Parameter value
-
Call action asynchronously
String  :: executePath ( odaba::String &sShellAction, odaba::String &sParameter, bool bWait )
The function is called with an action name and a parameter list. The action name must be defined as action (sub-option for the file extension name). When no such option could be found, the default action defined fir the extension name option is executed. In order to call the default action in any case, the action name may be left empty.
Usually, the function does not wait until the action is completed (bWait is false). In order to call action and wait for termination, true has to be passed in bWait.
- sShellAction
- Action
Name of the action to be called. Typical actions are open, print, find, edit and browse.
- sParameter
- Parameter value
Parameter values allow passing one or more parameters in a parameter string. Usually, parameters are separated by spaces. Parameters containing spaces have to be quoted using double quotes.
- bWait
- Wait option
When true is passed, the submitting process or thread is forced to wait un til the submitted process or thread has finished.
to list
- sShellAction
- Action