diff options
| author | oy <Tom_Adams@web.de> | 2010-12-11 23:10:13 +0100 |
|---|---|---|
| committer | oy <Tom_Adams@web.de> | 2010-12-11 23:10:13 +0100 |
| commit | 49bea07df704cca9366203082d458b3d90438fbc (patch) | |
| tree | beb29a5dfb54c725b26306b68b2f87865a262e12 | |
| parent | 48cd9372342b44ced021f04ed98eb608a0c405ca (diff) | |
| download | zcatch-49bea07df704cca9366203082d458b3d90438fbc.tar.gz zcatch-49bea07df704cca9366203082d458b3d90438fbc.zip | |
show the path of $CURRENTDIR. Closes #323
| -rw-r--r-- | src/base/system.c | 11 | ||||
| -rw-r--r-- | src/base/system.h | 9 | ||||
| -rw-r--r-- | src/engine/shared/storage.cpp | 7 |
3 files changed, 26 insertions, 1 deletions
diff --git a/src/base/system.c b/src/base/system.c index bf0c6aa9..a7eb205d 100644 --- a/src/base/system.c +++ b/src/base/system.c @@ -999,6 +999,17 @@ int fs_chdir(const char *path) return 1; } +char *fs_getcwd(char *buffer, int buffer_size) +{ + if(buffer == 0) + return 0; +#if defined(CONF_FAMILY_WINDOWS) + return _getcwd(buffer, buffer_size); +#else + return getcwd(buffer, buffer_size); +#endif +} + int fs_parent_dir(char *path) { char *parent = 0; diff --git a/src/base/system.h b/src/base/system.h index 2aca4de1..b3beb056 100644 --- a/src/base/system.h +++ b/src/base/system.h @@ -994,6 +994,15 @@ int fs_is_dir(const char *path); int fs_chdir(const char *path); /* + Function: fs_getcwd + Gets the current working directory. + + Returns: + Returns a pointer to the buffer on success, 0 on failure. +*/ +char *fs_getcwd(char *buffer, int buffer_size); + +/* Function: fs_parent_dir Get the parent directory of a directory diff --git a/src/engine/shared/storage.cpp b/src/engine/shared/storage.cpp index 0274ea19..d19be8a8 100644 --- a/src/engine/shared/storage.cpp +++ b/src/engine/shared/storage.cpp @@ -21,6 +21,7 @@ public: int m_NumPaths; char m_aDatadir[MAX_PATH_LENGTH]; char m_aUserdir[MAX_PATH_LENGTH]; + char m_aCurrentdir[MAX_PATH_LENGTH]; CStorage() { @@ -38,6 +39,10 @@ public: // get datadir FindDatadir(ppArguments[0]); + // get currentdir + if(!fs_getcwd(m_aCurrentdir, sizeof(m_aCurrentdir))) + m_aCurrentdir[0] = 0; + // load paths from storage.cfg LoadPaths(ppArguments[0]); @@ -134,7 +139,7 @@ public: else if(!str_comp(pPath, "$CURRENTDIR")) { m_aaStoragePaths[m_NumPaths++][0] = 0; - dbg_msg("storage", "added path '$CURRENTDIR'"); + dbg_msg("storage", "added path '$CURRENTDIR' ('%s')", m_aCurrentdir); } else { |