GrafX2 2.9.3227
The ultimate 256-color painting program
setup.c File Reference
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <sys/types.h>
#include <FindDirectory.h>
#include "haiku.h"
#include "struct.h"
#include "io.h"
#include "setup.h"
#include "global.h"
#include "gfx2log.h"
+ Include dependency graph for setup.c:

Macros

#define PATH_MAX   32768
 

Functions

char * Get_program_directory (const char *argv0)
 Determine which directory contains the executable. More...
 
char * Get_data_directory (const char *program_dir)
 Determine which directory contains the read-only data. More...
 
char * Get_config_directory (const char *program_dir)
 Determine which directory should store the user's configuration. More...
 

Macro Definition Documentation

◆ PATH_MAX

#define PATH_MAX   32768

Function Documentation

◆ Get_program_directory()

char * Get_program_directory ( const char *  argv0)

Determine which directory contains the executable.

Parameters
argv0Main's argv[0], some platforms need it, some don't.
Returns
malloc'ed string. Trailing / or \ is kept. Note : in fact this is only used to check for the datafiles and fonts in this same directory.

References Extract_path(), Get_current_directory(), GFX2_DEBUG, GFX2_Log(), GFX2_WARNING, haiku_get_app_path(), MAX_PATH_CHARACTERS, NULL, PATH_MAX, and PATH_SEPARATOR.

Referenced by Init_program().

◆ Get_data_directory()

char * Get_data_directory ( const char *  program_dir)

Determine which directory contains the read-only data.

Parameters
program_dirThe directory containing the executable
Returns
the path. Trailing / or \ is kept.

References Filepath_append_to_dir(), Get_data_directory(), and PATH_MAX.

Referenced by Get_data_directory(), and Init_program().

◆ Get_config_directory()

char * Get_config_directory ( const char *  program_dir)

Determine which directory should store the user's configuration.

For most Unix and Windows platforms: If a config file already exists in program_dir, it will return it in priority (Useful for development, and possibly for upgrading from DOS version) If the standard directory doesn't exist yet, this function will attempt to create it (/root/.grafx2, or APPDATA%\GrafX2) If it cannot be created, this function will return the executable's own directory.

Parameters
program_dirThe directory containing the executable
Returns
malloc'ed string. Trailing / or \ is kept.

References CONFIG_FILENAME, Directory_create(), Directory_exists(), File_exists(), Filepath_append_to_dir(), GFX2_INFO, GFX2_Log(), GFX2_WARNING, MAX_PATH_CHARACTERS, PATH_SEPARATOR, and Portable_Installation_Detected.

Referenced by Init_program().