company logo

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 details