Search
lxdream.org :: lxdream/src/lxpaths.h :: diff
lxdream 0.9.1
released Jun 29
Download Now
filename src/lxpaths.h
changeset 1041:5fcc39857c5c
next1205:a486ac64f34b
author nkeynes
date Fri Jun 26 05:47:04 2009 +0000 (13 years ago)
permissions -rw-r--r--
last change Refactor path operations into lxpaths.[ch]
file annotate diff log raw
1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/src/lxpaths.h Fri Jun 26 05:47:04 2009 +0000
1.3 @@ -0,0 +1,97 @@
1.4 +/**
1.5 + * $Id$
1.6 + *
1.7 + * Various path definitions and helper functions
1.8 + *
1.9 + * Copyright (c) 2005 Nathan Keynes.
1.10 + *
1.11 + * This program is free software; you can redistribute it and/or modify
1.12 + * it under the terms of the GNU General Public License as published by
1.13 + * the Free Software Foundation; either version 2 of the License, or
1.14 + * (at your option) any later version.
1.15 + *
1.16 + * This program is distributed in the hope that it will be useful,
1.17 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
1.18 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1.19 + * GNU General Public License for more details.
1.20 + */
1.21 +
1.22 +#ifndef lxdream_paths_H
1.23 +#define lxdream_paths_H
1.24 +
1.25 +/****************** System paths ****************/
1.26 +/**
1.27 + * Location of the shared lxdreamrc (e.g. /usr/local/etc/lxdreamrc)
1.28 + */
1.29 +const char *get_sysconf_path();
1.30 +
1.31 +/**
1.32 + * Location of the message catalogs (e.g. /usr/local/share/locale)
1.33 + */
1.34 +const char *get_locale_path();
1.35 +
1.36 +/**
1.37 + * Location of the plugins, if any (e.g. /usr/local/lib/lxdream)
1.38 + */
1.39 +const char *get_plugin_path();
1.40 +
1.41 +/**
1.42 + * Location of the current user's data path (e.g. ~/.lxdream)
1.43 + */
1.44 +const char *get_user_data_path();
1.45 +
1.46 +/******************** Path helpers *****************/
1.47 +
1.48 +/**
1.49 + * Escape a pathname if needed to prevent shell substitution.
1.50 + * @return a newly allocated string (or NULL if the input is NULL)
1.51 + */
1.52 +gchar *get_escaped_path( const gchar *name );
1.53 +
1.54 +/**
1.55 + * Expand a pathname according to standard shell substitution rules
1.56 + * (excluding command substitutions).
1.57 + * @return a newly allocated string (or NULL if the input is NULL)
1.58 + */
1.59 +gchar *get_expanded_path( const gchar *name );
1.60 +
1.61 +/**
1.62 + * Return an absolute path for the given input path, as a newly allocated
1.63 + * string. If the input path is already absolute, the returned string will
1.64 + * be identical to the input string.
1.65 + */
1.66 +gchar *get_absolute_path( const gchar *path );
1.67 +
1.68 +/**
1.69 + * Construct a filename in the same directory as the file at. That is,
1.70 + * if at is "/tmp/foo" and filename = "bar", the function returns
1.71 + * "/tmp/bar".
1.72 + * @return a newly allocated string that must be released by the caller.
1.73 + */
1.74 +gchar *get_filename_at( const gchar *at, const gchar *filename );
1.75 +
1.76 +
1.77 +/********************* GUI Paths ***********************/
1.78 +/* The following functions provide a cache for the most recently accessed
1.79 + * path for each config key (ie for GUI file open/save dialogs)
1.80 + */
1.81 +/**
1.82 + * Get the path corresponding to the given global config key
1.83 + */
1.84 +const gchar *get_gui_path(int key);
1.85 +
1.86 +/**
1.87 + * Override the path for the given global config key, without changing the
1.88 + * underlying configuration.
1.89 + */
1.90 +void set_gui_path( int key, const gchar *path );
1.91 +
1.92 +/**
1.93 + * Notify the helper functions that the config paths have changed, in which
1.94 + * event they will revert to the config-specified versions.
1.95 + */
1.96 +void reset_gui_paths();
1.97 +
1.98 +
1.99 +
1.100 +#endif /* !lxdream_paths_H */
.