diff options
| author | Jakob Fries <jakob.fries@gmail.com> | 2007-08-05 15:56:32 +0000 |
|---|---|---|
| committer | Jakob Fries <jakob.fries@gmail.com> | 2007-08-05 15:56:32 +0000 |
| commit | e4829981b1d3e746a8f2b6c6cc41b8ba965c5e0e (patch) | |
| tree | 126f12b869d45d12365d16d1b01e05d4099c4151 /src/engine/config.cpp | |
| parent | 9abbb0899b3770d29937c5b761a09d0ce42ed76b (diff) | |
| download | zcatch-e4829981b1d3e746a8f2b6c6cc41b8ba965c5e0e.tar.gz zcatch-e4829981b1d3e746a8f2b6c6cc41b8ba965c5e0e.zip | |
Diffstat (limited to 'src/engine/config.cpp')
| -rw-r--r-- | src/engine/config.cpp | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/src/engine/config.cpp b/src/engine/config.cpp index fc4dff1e..fb378190 100644 --- a/src/engine/config.cpp +++ b/src/engine/config.cpp @@ -66,6 +66,18 @@ void config_set(const char *line) void config_load(const char *filename) { + if (filename[0] == '~') + { + char *home = getenv("HOME"); + if (home) + { + char full_path[1024]; + sprintf(full_path, "%s%s", home, filename+1); + filename = full_path; + } + } + + dbg_msg("config/load", "loading %s", filename); file_stream file; @@ -84,6 +96,18 @@ void config_load(const char *filename) void config_save(const char *filename) { + if (filename[0] == '~') + { + char *home = getenv("HOME"); + if (home) + { + char full_path[1024]; + sprintf(full_path, "%s%s", home, filename+1); + filename = full_path; + } + } + + dbg_msg("config/save", "saving config to %s", filename); file_stream file; @@ -101,6 +125,8 @@ void config_save(const char *filename) file.close(); } + else + dbg_msg("config/save", "couldn't open %s for writing. :(", filename); } #define MACRO_CONFIG_INT(name,def,min,max) int config_get_ ## name (configuration *c) { return c->name; } |