summaryrefslogtreecommitdiff
blob: 4f10d6d9e3ce821a7181c477906a85a2395a8beb (plain)
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
99
100
101
102
103
104
105
106
107
108
109
110
111
112
--- hatari-1.4.0.orig/src/paths.c
+++ hatari-1.4.0/src/paths.c
@@ -109,71 +109,6 @@
 	free(pTmpName);
 }
 
-
-/**
- * Locate the directory where the hatari executable resides
- */
-static char *Paths_InitExecDir(const char *argv0)
-{
-	char *psExecDir;  /* Path string where the hatari executable can be found */
-
-	/* Allocate memory for storing the path string of the executable */
-	psExecDir = malloc(FILENAME_MAX);
-	if (!psExecDir)
-	{
-		fprintf(stderr, "Out of memory (Paths_Init)\n");
-		exit(-1);
-	}
-
-	/* Determine the bindir...
-	 * Start with empty string, then try to use OS specific functions,
-	 * and finally analyze the PATH variable if it has not been found yet. */
-	psExecDir[0] = '\0';
-
-#if defined(__linux__)
-	{
-		int i;
-		/* On Linux, we can analyze the symlink /proc/self/exe */
-		i = readlink("/proc/self/exe", psExecDir, FILENAME_MAX);
-		if (i > 0)
-		{
-			char *p;
-			psExecDir[i] = '\0';
-			p = strrchr(psExecDir, '/');    /* Search last slash */
-			if (p)
-				*p = 0;                     /* Strip file name from path */
-		}
-	}
-//#elif defined(WIN32) || defined(__CEGCC__)
-//	/* On Windows we can use GetModuleFileName for getting the exe path */
-//	GetModuleFileName(NULL, psExecDir, FILENAME_MAX);
-#endif
-
-	/* If we do not have the execdir yet, analyze argv[0] and the PATH: */
-	if (psExecDir[0] == 0)
-	{
-		if (strchr(argv0, PATHSEP) == 0)
-		{
-			/* No separator in argv[0], we have to explore PATH... */
-			Paths_GetExecDirFromPATH(argv0, psExecDir, FILENAME_MAX);
-		}
-		else
-		{
-			/* There was a path separator in argv[0], so let's assume a
-			 * relative or absolute path to the current directory in argv[0] */
-			char *p;
-			strncpy(psExecDir, argv0, FILENAME_MAX);
-			psExecDir[FILENAME_MAX-1] = 0;
-			p = strrchr(psExecDir, PATHSEP);  /* Search last slash */
-			if (p)
-				*p = 0;                       /* Strip file name from path */
-		}
-	}
-
-	return psExecDir;
-}
-
-
 /**
  * Initialize the users home directory string
  * and Hatari's home directory (~/.hatari)
@@ -226,8 +161,6 @@
  */
 void Paths_Init(const char *argv0)
 {
-	char *psExecDir;  /* Path string where the hatari executable can be found */
-
 	/* Init working directory string */
 	if (getcwd(sWorkingDir, FILENAME_MAX) == NULL)
 	{
@@ -238,27 +171,11 @@
 	/* Init the user's home directory string */
 	Paths_InitHomeDirs();
 
-	/* Get the directory where the executable resides */
-	psExecDir = Paths_InitExecDir(argv0);
-
-	/* Now create the datadir path name from the bindir path name: */
-	if (psExecDir && strlen(psExecDir) > 0)
-	{
-		snprintf(sDataDir, sizeof(sDataDir), "%s%c%s",
-		         psExecDir, PATHSEP, BIN2DATADIR);
-	}
-	else
-	{
-		/* bindir could not be determined, let's assume datadir is relative
-		 * to current working directory... */
-		strcpy(sDataDir, BIN2DATADIR);
-	}
+	strcpy(sDataDir, BIN2DATADIR);
 
 	/* And finally make a proper absolute path out of datadir: */
 	File_MakeAbsoluteName(sDataDir);
 
-	free(psExecDir);
-
 	/* fprintf(stderr, " WorkingDir = %s\n DataDir = %s\n UserHomeDir = %s\n HatariHomeDir = %s\n",
 	        sWorkingDir, sDataDir, sUserHomeDir, sHatariHomeDir); */
 }