nkeynes@1041: /** nkeynes@1041: * $Id$ nkeynes@1041: * nkeynes@1041: * Various path definitions and helper functions nkeynes@1041: * nkeynes@1041: * Copyright (c) 2005 Nathan Keynes. nkeynes@1041: * nkeynes@1041: * This program is free software; you can redistribute it and/or modify nkeynes@1041: * it under the terms of the GNU General Public License as published by nkeynes@1041: * the Free Software Foundation; either version 2 of the License, or nkeynes@1041: * (at your option) any later version. nkeynes@1041: * nkeynes@1041: * This program is distributed in the hope that it will be useful, nkeynes@1041: * but WITHOUT ANY WARRANTY; without even the implied warranty of nkeynes@1041: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the nkeynes@1041: * GNU General Public License for more details. nkeynes@1041: */ nkeynes@1041: nkeynes@1041: #ifndef lxdream_paths_H nkeynes@1041: #define lxdream_paths_H nkeynes@1041: nkeynes@1296: #include nkeynes@1205: nkeynes@1041: /****************** System paths ****************/ nkeynes@1041: /** nkeynes@1041: * Location of the shared lxdreamrc (e.g. /usr/local/etc/lxdreamrc) nkeynes@1041: */ nkeynes@1041: const char *get_sysconf_path(); nkeynes@1041: nkeynes@1041: /** nkeynes@1041: * Location of the message catalogs (e.g. /usr/local/share/locale) nkeynes@1041: */ nkeynes@1041: const char *get_locale_path(); nkeynes@1041: nkeynes@1041: /** nkeynes@1041: * Location of the plugins, if any (e.g. /usr/local/lib/lxdream) nkeynes@1041: */ nkeynes@1041: const char *get_plugin_path(); nkeynes@1041: nkeynes@1041: /** nkeynes@1041: * Location of the current user's data path (e.g. ~/.lxdream) nkeynes@1041: */ nkeynes@1041: const char *get_user_data_path(); nkeynes@1041: nkeynes@1241: /** nkeynes@1241: * Set the user data path nkeynes@1241: */ nkeynes@1241: void set_user_data_path( const char *p ); nkeynes@1241: nkeynes@1041: /******************** Path helpers *****************/ nkeynes@1041: nkeynes@1041: /** nkeynes@1041: * Escape a pathname if needed to prevent shell substitution. nkeynes@1041: * @return a newly allocated string (or NULL if the input is NULL) nkeynes@1041: */ nkeynes@1041: gchar *get_escaped_path( const gchar *name ); nkeynes@1041: nkeynes@1041: /** nkeynes@1041: * Expand a pathname according to standard shell substitution rules nkeynes@1041: * (excluding command substitutions). nkeynes@1041: * @return a newly allocated string (or NULL if the input is NULL) nkeynes@1041: */ nkeynes@1041: gchar *get_expanded_path( const gchar *name ); nkeynes@1041: nkeynes@1041: /** nkeynes@1041: * Return an absolute path for the given input path, as a newly allocated nkeynes@1041: * string. If the input path is already absolute, the returned string will nkeynes@1041: * be identical to the input string. nkeynes@1041: */ nkeynes@1041: gchar *get_absolute_path( const gchar *path ); nkeynes@1041: nkeynes@1041: /** nkeynes@1041: * Construct a filename in the same directory as the file at. That is, nkeynes@1041: * if at is "/tmp/foo" and filename = "bar", the function returns nkeynes@1041: * "/tmp/bar". nkeynes@1041: * @return a newly allocated string that must be released by the caller. nkeynes@1041: */ nkeynes@1041: gchar *get_filename_at( const gchar *at, const gchar *filename ); nkeynes@1041: nkeynes@1041: nkeynes@1041: /********************* GUI Paths ***********************/ nkeynes@1041: /* The following functions provide a cache for the most recently accessed nkeynes@1041: * path for each config key (ie for GUI file open/save dialogs) nkeynes@1041: */ nkeynes@1041: /** nkeynes@1041: * Get the path corresponding to the given global config key nkeynes@1041: */ nkeynes@1041: const gchar *get_gui_path(int key); nkeynes@1041: nkeynes@1041: /** nkeynes@1041: * Override the path for the given global config key, without changing the nkeynes@1041: * underlying configuration. nkeynes@1041: */ nkeynes@1041: void set_gui_path( int key, const gchar *path ); nkeynes@1041: nkeynes@1041: /** nkeynes@1041: * Notify the helper functions that the config paths have changed, in which nkeynes@1041: * event they will revert to the config-specified versions. nkeynes@1041: */ nkeynes@1041: void reset_gui_paths(); nkeynes@1041: nkeynes@1041: nkeynes@1041: nkeynes@1041: #endif /* !lxdream_paths_H */