Search
lxdream.org :: lxdream/src/lxpaths.h
lxdream 0.9.1
released Jun 29
Download Now
filename src/lxpaths.h
changeset 1241:74f8e11ab4b8
prev1205:a486ac64f34b
next1296:30ecee61f811
author nkeynes
date Tue Feb 28 17:27:39 2012 +1000 (8 years ago)
permissions -rw-r--r--
last change Pass the application home dir through to the native code, so we can use it
as the default data directory
file annotate diff log raw
nkeynes@1041
     1
/**
nkeynes@1041
     2
 * $Id$
nkeynes@1041
     3
 *
nkeynes@1041
     4
 * Various path definitions and helper functions
nkeynes@1041
     5
 *
nkeynes@1041
     6
 * Copyright (c) 2005 Nathan Keynes.
nkeynes@1041
     7
 *
nkeynes@1041
     8
 * This program is free software; you can redistribute it and/or modify
nkeynes@1041
     9
 * it under the terms of the GNU General Public License as published by
nkeynes@1041
    10
 * the Free Software Foundation; either version 2 of the License, or
nkeynes@1041
    11
 * (at your option) any later version.
nkeynes@1041
    12
 *
nkeynes@1041
    13
 * This program is distributed in the hope that it will be useful,
nkeynes@1041
    14
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
nkeynes@1041
    15
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
nkeynes@1041
    16
 * GNU General Public License for more details.
nkeynes@1041
    17
 */
nkeynes@1041
    18
nkeynes@1041
    19
#ifndef lxdream_paths_H
nkeynes@1041
    20
#define lxdream_paths_H
nkeynes@1041
    21
nkeynes@1205
    22
#include <glib/gtypes.h>
nkeynes@1205
    23
nkeynes@1041
    24
/****************** System paths ****************/
nkeynes@1041
    25
/**
nkeynes@1041
    26
 * Location of the shared lxdreamrc (e.g. /usr/local/etc/lxdreamrc)
nkeynes@1041
    27
 */
nkeynes@1041
    28
const char *get_sysconf_path();
nkeynes@1041
    29
nkeynes@1041
    30
/**
nkeynes@1041
    31
 * Location of the message catalogs (e.g. /usr/local/share/locale)
nkeynes@1041
    32
 */
nkeynes@1041
    33
const char *get_locale_path();
nkeynes@1041
    34
nkeynes@1041
    35
/**
nkeynes@1041
    36
 * Location of the plugins, if any (e.g. /usr/local/lib/lxdream)
nkeynes@1041
    37
 */
nkeynes@1041
    38
const char *get_plugin_path();
nkeynes@1041
    39
nkeynes@1041
    40
/**
nkeynes@1041
    41
 * Location of the current user's data path (e.g. ~/.lxdream)
nkeynes@1041
    42
 */
nkeynes@1041
    43
const char *get_user_data_path();
nkeynes@1041
    44
nkeynes@1241
    45
/**
nkeynes@1241
    46
 * Set the user data path
nkeynes@1241
    47
 */
nkeynes@1241
    48
void set_user_data_path( const char *p );
nkeynes@1241
    49
nkeynes@1041
    50
/******************** Path helpers *****************/
nkeynes@1041
    51
nkeynes@1041
    52
/**
nkeynes@1041
    53
 * Escape a pathname if needed to prevent shell substitution.
nkeynes@1041
    54
 * @return a newly allocated string (or NULL if the input is NULL)
nkeynes@1041
    55
 */
nkeynes@1041
    56
gchar *get_escaped_path( const gchar *name );
nkeynes@1041
    57
nkeynes@1041
    58
/**
nkeynes@1041
    59
 * Expand a pathname according to standard shell substitution rules
nkeynes@1041
    60
 * (excluding command substitutions).
nkeynes@1041
    61
 * @return a newly allocated string (or NULL if the input is NULL)
nkeynes@1041
    62
 */
nkeynes@1041
    63
gchar *get_expanded_path( const gchar *name );
nkeynes@1041
    64
nkeynes@1041
    65
/**
nkeynes@1041
    66
 * Return an absolute path for the given input path, as a newly allocated
nkeynes@1041
    67
 * string. If the input path is already absolute, the returned string will
nkeynes@1041
    68
 * be identical to the input string.
nkeynes@1041
    69
 */
nkeynes@1041
    70
gchar *get_absolute_path( const gchar *path );
nkeynes@1041
    71
nkeynes@1041
    72
/**
nkeynes@1041
    73
 * Construct a filename in the same directory as the file at. That is,
nkeynes@1041
    74
 * if at is "/tmp/foo" and filename = "bar", the function returns 
nkeynes@1041
    75
 * "/tmp/bar".
nkeynes@1041
    76
 * @return a newly allocated string that must be released by the caller.
nkeynes@1041
    77
 */
nkeynes@1041
    78
gchar *get_filename_at( const gchar *at, const gchar *filename );
nkeynes@1041
    79
nkeynes@1041
    80
nkeynes@1041
    81
/********************* GUI Paths ***********************/
nkeynes@1041
    82
/* The following functions provide a cache for the most recently accessed
nkeynes@1041
    83
 * path for each config key (ie for GUI file open/save dialogs)
nkeynes@1041
    84
 */
nkeynes@1041
    85
/**
nkeynes@1041
    86
 * Get the path corresponding to the given global config key
nkeynes@1041
    87
 */
nkeynes@1041
    88
const gchar *get_gui_path(int key);
nkeynes@1041
    89
nkeynes@1041
    90
/**
nkeynes@1041
    91
 * Override the path for the given global config key, without changing the
nkeynes@1041
    92
 * underlying configuration.
nkeynes@1041
    93
 */
nkeynes@1041
    94
void set_gui_path( int key, const gchar *path );
nkeynes@1041
    95
nkeynes@1041
    96
/**
nkeynes@1041
    97
 * Notify the helper functions that the config paths have changed, in which
nkeynes@1041
    98
 * event they will revert to the config-specified versions.
nkeynes@1041
    99
 */
nkeynes@1041
   100
void reset_gui_paths();
nkeynes@1041
   101
nkeynes@1041
   102
nkeynes@1041
   103
nkeynes@1041
   104
#endif /* !lxdream_paths_H */
.