summaryrefslogtreecommitdiff
path: root/graphics/geomorph/files/patch-src-app-main.c
blob: f2efd5de2a6d95bc4299ae474aac92107e1634d0 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
--- src/app/main.c.orig	2010-10-30 08:17:00.000000000 +0400
+++ src/app/main.c	2013-08-28 03:51:05.535226256 +0400
@@ -18,6 +18,7 @@
  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
  */
 
+#include <sys/param.h>
 #include "./main.h"
 #include "./globals.h"
 #include "./app.h"
@@ -68,6 +69,12 @@
 	if (command) x_free(command);
 }
 
+char *get_current_dir_name() {
+	char *buf = malloc(MAXPATHLEN);
+	getwd(buf);
+	return buf;
+}
+
 gchar *find_config_file() {
 //	Returns the config file name (name OPTION_FILE, defined in globals.h),
 //	with its full path
@@ -83,59 +90,23 @@
 //	if $HOME/DEF_DIR_NAME doesn't exist, we create the required files
 //	The directory where OPTION_FILE is found becomes the default one (DEF_DIR)
 
-	// Try ./OPTION_FILE
-	default_dir = (gchar *) get_current_dir_name();
-	path_n_file = concat_dname_fname(default_dir,OPTION_FILE);
-	if (!filexists(path_n_file)) { // Try ./DEF_DIR_NAME/OPTION_FILE
-		default_dir = concat_dname_fname(default_dir,DEF_DIR_NAME);
-		if (path_n_file)
-			x_free(path_n_file);
-		path_n_file = concat_dname_fname(default_dir,OPTION_FILE);
-		if (!filexists(path_n_file)) { // Try in the home directory - ~/OPTION_FILE
-			default_dir = getenv("HOME");
-			if (path_n_file)
-				x_free(path_n_file);
-			path_n_file = concat_dname_fname(default_dir, OPTION_FILE);
-			if (!filexists(path_n_file)) { // Try ~/DEFAULT_DIR/OPTION_FILE
-				default_dir = concat_dname_fname(default_dir,DEF_DIR_NAME);
-				if (path_n_file) x_free(path_n_file);
-				path_n_file = concat_dname_fname(default_dir, OPTION_FILE);
-				if (directory_exists(default_dir)) {
-					if (!filexists(path_n_file)) {
-						// Big problem, create a default rc file
-						create_config_file(path_n_file);
-					}
-				}
-				else {
-					// Geomorph directory ("default_dir") doesn't exist
-					// Create one with default scenes and rc file
-					buf = (gchar *) x_malloc(strlen(_("Creation of the default working directory?"))+1+strlen(default_dir), "const gchar (buf - Creation of the default working directory MSG)");
-					sprintf(buf,_("Creation of the default working directory?"),default_dir);
-					if (!yes_no(buf,TRUE))
-						exit(0);
-//					if (buf) x_free(buf);
-					shortcuts = yes_no(_("Add shortcuts on the KDE and GNOME desktops?"), TRUE);
-					command = concat_dname_fname(get_data_dir(),"install-step1-dir");
-					if (system(command))
-						my_msg(_("Fatal error during the creation of the default working directory"),ABORT);
-					if (command) x_free(command);
-					create_config_file(path_n_file);
-					command = concat_dname_fname(get_data_dir(),"install-step3-menu");
-					if (system(command))
-						my_msg(_("Error during the creation of Geomorph in the Gnome or KDE menu"),WARNING);
-					if (command) x_free(command);
-					if (shortcuts) {
-						command = concat_dname_fname(get_data_dir(),"install-step4-desktop");
-						if (system(command))
-							my_msg(_("Error during the creation of one shortcut or both"),WARNING);
-//						if (buf) x_free(buf);
-						if (command) x_free(command);
-					}
-				if (path_n_file) x_free(path_n_file);
-				}
-			}
+	default_dir = concat_dname_fname(getenv("HOME"), DEF_DIR_NAME);
+	path_n_file = path_n_file = concat_dname_fname(default_dir, OPTION_FILE);
+
+	if (directory_exists(default_dir)) {
+		if (!filexists(path_n_file)) {
+			// Big problem, create a default rc file
+			create_config_file(path_n_file);
 		}
 	}
+	else {
+		command = concat_dname_fname(get_data_dir(),"install-step1-dir");
+		if (system(command))
+			my_msg(_("Fatal error during the creation of the default working directory"),ABORT);
+		if (command) free(command);
+		create_config_file(path_n_file);
+	}
+	if (path_n_file) free(path_n_file);
 	return add_filesep(default_dir);
 }