Re: [hatari-devel] OSx problems |
[ Thread Index |
Date Index
| More lists.tuxfamily.org/hatari-devel Archives
]
There is also some changes in path.c
diff -r f7dcf5df7170 src/paths.c
--- a/src/paths.c Sat May 31 20:09:07 2014 +0200
+++ b/src/paths.c Sun Jun 01 00:05:13 2014 +0200
@@ -20,10 +20,16 @@
#define mkdir(name,mode) mkdir(name)
#endif /* WIN32 */
-static char sWorkingDir[FILENAME_MAX]; /* Working directory */
-static char sDataDir[FILENAME_MAX]; /* Directory where data files
of Hatari can be found */
-static char sUserHomeDir[FILENAME_MAX]; /* User's home directory
($HOME) */
-static char sHatariHomeDir[FILENAME_MAX]; /* Hatari's home directory
($HOME/.hatari/) */
+#if defined(__MACOSX__)
+ #define dirSave "Library/Application Support/Hatari"
+#else
+ #define dirSave ".hatari"
+#endif
+
+static char sWorkingDir[FILENAME_MAX]; // Working directory
+static char sDataDir[FILENAME_MAX]; // Directory where data files
of Hatari can be found
+static char sUserHomeDir[FILENAME_MAX]; // User's home directory ($HOME)
+static char sHatariHomeDir[FILENAME_MAX]; // Hatari's home directory
($HOME/.hatari/)
/**
@@ -93,8 +99,8 @@
pAct = strtok (pPathEnv, pToken);
while (pAct)
{
- snprintf(pTmpName, FILENAME_MAX, "%s%c%s",
- pAct, PATHSEP, argv0);
+ snprintf(pTmpName, FILENAME_MAX, "%s%c%s", pAct, PATHSEP, argv0);
+
if (File_Exists(pTmpName))
{
/* Found the executable - so use the corresponding path: */
@@ -214,8 +220,7 @@
sUserHomeDir[FILENAME_MAX-1] = 0;
/* Try to use a .hatari directory in the users home directory */
- snprintf(sHatariHomeDir, FILENAME_MAX, "%s%c.hatari",
- sUserHomeDir, PATHSEP);
+ snprintf(sHatariHomeDir, FILENAME_MAX, "%s%c%s", sUserHomeDir,
PATHSEP, dirSave);
if (!File_DirExists(sHatariHomeDir))
{
/* Hatari home directory does not exists yet...
@@ -240,38 +245,26 @@
*/
void Paths_Init(const char *argv0)
{
- char *psExecDir; /* Path string where the hatari executable can be
found */
+char *psExecDir; // Path
string where the hatari executable can be found
+
+ if (getcwd(sWorkingDir, FILENAME_MAX) == NULL) // Init
working directory string
+ strcpy(sWorkingDir, ".") ; // This
should never happen... just in case...
- /* Init working directory string */
- if (getcwd(sWorkingDir, FILENAME_MAX) == NULL)
- {
- /* This should never happen... just in case... */
- strcpy(sWorkingDir, ".");
- }
+ Paths_InitHomeDirs(); // Init
the user's home directory string
+ psExecDir = Paths_InitExecDir(argv0); // Get the
directory where the executable resides
+
+ if (psExecDir && strlen(psExecDir) > 0) // Now create the
datadir path name from the bindir path name
+ {
+ snprintf(sDataDir, sizeof(sDataDir), "%s%c%s", psExecDir,
PATHSEP, BIN2DATADIR);
+ }
+ else
+ { // bindir
could not be determined, let's assume datadir
+ strcpy(sDataDir, BIN2DATADIR); // is
relative to current working directory...
+ } ;
- /* Init the user's home directory string */
- Paths_InitHomeDirs();
+ File_MakeAbsoluteName(sDataDir); // And
finally make a proper absolute path out of datadir
- /* 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);
- }
-
- /* And finally make a proper absolute path out of datadir: */
- File_MakeAbsoluteName(sDataDir);
-
- free(psExecDir);
+ free(psExecDir) ;
/* fprintf(stderr, " WorkingDir = %s\n DataDir = %s\n UserHomeDir
= %s\n HatariHomeDir = %s\n",
sWorkingDir, sDataDir, sUserHomeDir, sHatariHomeDir); */