Function

GLibfind_program_in_path

Declaration [src]

gchar*
g_find_program_in_path (
  const gchar* program
)

Description [src]

Locates the first executable named program in the user’s path, in the same way that execvp() would locate it. Returns an allocated string with the absolute path name, or NULL if the program is not found in the path. If program is already an absolute path, returns a copy of program if program exists and is executable, and NULL otherwise.

On Windows, if program does not have a file type suffix, tries with the suffixes .exe, .cmd, .bat and .com, and the suffixes in the PATHEXT environment variable.

On Windows, it looks for the file in the same way as CreateProcess() would. This means first in the directory where the executing program was loaded from, then in the current directory, then in the Windows 32-bit system directory, then in the Windows directory, and finally in the directories in the PATH environment variable. If the program is found, the return value contains the full name including the type suffix.

Parameters

program

Type: const gchar*

A program name in the GLib file name encoding.

The data is owned by the caller of the function.
The value is a platform-native string, using the preferred OS encoding on Unix and UTF-8 on Windows.

Return value

Type: gchar*

A newly-allocated string with the absolute path, or NULL.

The caller of the function takes ownership of the data, and is responsible for freeing it.
The return value can be NULL.
The value is a platform-native string, using the preferred OS encoding on Unix and UTF-8 on Windows.