1 /* -*- Mode: C ; c-basic-offset: 3 -*- */
2 /*****************************************************************************
4 * $Id: path.c,v 1.1 2005/02/18 02:10:10 nedko Exp $
7 * Access to project specific data files.
9 *****************************************************************************/
11 #include <sys/types.h>
20 static gchar
*pszPathToExecutable
= NULL
;
21 static gchar
*pszExecutable
= NULL
;
24 path_init(const char * argv0
)
26 /* FIXME: pszPathToExecutable calculation is ugly workaround
27 * that assumes that current directory is nevere changed for our process.
28 * We should better get full path (/proc/pid/maps in Linux ?) */
29 pszExecutable
= g_path_get_basename(argv0
);
30 pszPathToExecutable
= g_path_get_dirname(argv0
);
34 path_check_initialization()
36 if (pszPathToExecutable
== NULL
||
37 pszExecutable
== NULL
)
39 g_warning("path_init() not called.");
45 path_get_data_filename(const gchar
* filename
)
50 path_check_initialization();
52 full_path
= g_strdup_printf("%s/%s", pszPathToExecutable
, filename
);
53 if (stat(full_path
, &st
) == 0)
65 path_check_initialization();
67 g_free(pszExecutable
);
68 g_free(pszPathToExecutable
);
71 /*****************************************************************************
75 * !!! WARNING !!! Following lines are automatically updated by the CVS system.
78 * Revision 1.1 2005/02/18 02:10:10 nedko
79 * Access to project specific data files - initial revision.
81 *****************************************************************************/