1 /* Copyright 2009-2010 Yorba Foundation
3 * This software is licensed under the GNU LGPL (version 2.1 or later).
4 * See the COPYING file in this distribution.
7 extern const string _PREFIX;
10 public class AppDirs {
12 static string program_name;
14 public static void init(string arg0, string program_name) {
15 File exec_file = File.new_for_path(Environment.find_program_in_path(arg0));
16 exec_dir = exec_file.get_parent();
17 AppDirs.program_name = program_name;
20 public static void terminate() {
23 public static File get_exec_dir() {
27 public static File get_resources_dir() {
28 File exec_dir = get_exec_dir();
29 File install_dir = get_install_dir();
31 if (install_dir != null) {
32 return_value = install_dir.get_child("share").get_child(program_name);
33 } else { // running locally
34 return_value = exec_dir;
36 return return_value.get_child("resources");
39 static File? get_install_dir() {
40 File prefix_dir = File.new_for_path(_PREFIX);
41 return exec_dir.has_prefix(prefix_dir) ? prefix_dir : null;