namespace
{
+ // executable file path
+ CopiedString app_filepath;
+ // directory paths
CopiedString home_path;
CopiedString app_path;
CopiedString lib_path;
CopiedString data_path;
}
+const char* environment_get_app_filepath(){
+ return app_filepath.c_str();
+}
+
const char* environment_get_home_path(){
return home_path.c_str();
}
return app_path.c_str();
}
-
const char *environment_get_lib_path()
{
return lib_path.c_str();
/* Ensure proper NUL termination */
buf[ret] = 0;
+ return buf;
+}
+char const* getexepath( char *buf ) {
/* delete the program name */
*( strrchr( buf, '/' ) ) = '\0';
{
char real[PATH_MAX];
- app_path = getexename( real );
- ASSERT_MESSAGE( !string_empty( app_path.c_str() ), "failed to deduce app path" );
+ app_filepath = getexename( real );
+ ASSERT_MESSAGE( !string_empty( app_filepath.c_str() ), "failed to deduce app path" );
+
+ strncpy( real, app_filepath.c_str(), strlen( app_filepath.c_str() ) );
+ app_path = getexepath( real );
}
{
{
// get path to the editor
char filename[MAX_PATH + 1];
+ StringOutputStream app_filepath_stream( 256 );
+ StringOutputStream app_path_stream( 256 );
+
GetModuleFileName( 0, filename, MAX_PATH );
+
+ app_filepath_stream << PathCleaned( filename );
+ app_filepath = app_filepath_stream.c_str();
+
char* last_separator = strrchr( filename, '\\' );
if ( last_separator != 0 ) {
*( last_separator + 1 ) = '\0';
{
filename[0] = '\0';
}
- StringOutputStream app( 256 );
- app << PathCleaned( filename );
- app_path = app.c_str();
+
+ app_path_stream << PathCleaned( filename );
+ app_path = app_path_stream.c_str();
lib_path = app_path;
data_path = app_path;
#define INCLUDED_ENVIRONMENT_H
void environment_init( int argc, char const* argv[] );
+
+const char* environment_get_app_filepath();
+
const char* environment_get_home_path();
const char* environment_get_app_path();
-
const char *environment_get_lib_path();
-
const char *environment_get_data_path();
extern int g_argc;
}
-// App Path
+// executable file path (full path)
+CopiedString g_strAppFilePath;
-CopiedString g_strAppPath; ///< holds the full path of the executable
+// directory paths
+CopiedString g_strAppPath;
CopiedString g_strLibPath;
CopiedString g_strDataPath;
+const char* AppFilePath_get(){
+ return g_strAppFilePath.c_str();
+}
+
const char* AppPath_get(){
return g_strAppPath.c_str();
}
extern CopiedString g_strPakPath[g_pakPathCount];
const char* PakPath_get( int num );
+extern CopiedString g_strAppFilePath;
extern CopiedString g_strAppPath;
extern CopiedString g_strLibPath;
extern CopiedString g_strDataPath;
+const char* AppFilePath_get();
const char* AppPath_get();
const char *LibPath_get();
const char *DataPath_get();