diff options
author | Jay Sorg <jay.sorg@gmail.com> | 2012-05-26 21:20:19 -0700 |
---|---|---|
committer | Jay Sorg <jay.sorg@gmail.com> | 2012-05-26 21:20:19 -0700 |
commit | 62bf3c61f530024284c56a126a407c537220e28f (patch) | |
tree | 633da4552bc740ffa652f0b6c0adb1758479b5e7 /common | |
parent | 0566da74ebd6427a0e716a7a771209045f3dafe9 (diff) | |
download | xrdp-proprietary-62bf3c61f530024284c56a126a407c537220e28f.tar.gz xrdp-proprietary-62bf3c61f530024284c56a126a407c537220e28f.zip |
xrdp: pid file fixes
Diffstat (limited to 'common')
-rw-r--r-- | common/os_calls.c | 38 | ||||
-rw-r--r-- | common/os_calls.h | 2 |
2 files changed, 40 insertions, 0 deletions
diff --git a/common/os_calls.c b/common/os_calls.c index 65c6808a..211adc82 100644 --- a/common/os_calls.c +++ b/common/os_calls.c @@ -1405,6 +1405,44 @@ g_create_dir(const char* dirname) } /*****************************************************************************/ +/* will try to create directories up to last / in name + example /tmp/a/b/c/readme.txt will try to create /tmp/a/b/c + returns boolean */ +int APP_CC +g_create_path(const char* path) +{ + char* pp; + char* sp; + char* copypath; + int status; + + status = 1; + copypath = g_strdup(path); + pp = copypath; + sp = strchr(pp, '/'); + while (sp != 0) + { + if (sp != pp) + { + *sp = 0; + if (!g_directory_exist(copypath)) + { + if (!g_create_dir(copypath)) + { + status = 0; + break; + } + } + *sp = '/'; + } + pp = sp + 1; + sp = strchr(pp, '/'); + } + g_free(copypath); + return status; +} + +/*****************************************************************************/ /* returns boolean */ int APP_CC g_remove_dir(const char* dirname) diff --git a/common/os_calls.h b/common/os_calls.h index 009a9079..ddcb59d8 100644 --- a/common/os_calls.h +++ b/common/os_calls.h @@ -161,6 +161,8 @@ g_directory_exist(const char* dirname); int APP_CC g_create_dir(const char* dirname); int APP_CC +g_create_path(const char* path); +int APP_CC g_remove_dir(const char* dirname); int APP_CC g_file_delete(const char* filename); |