From 62bf3c61f530024284c56a126a407c537220e28f Mon Sep 17 00:00:00 2001 From: Jay Sorg Date: Sat, 26 May 2012 21:20:19 -0700 Subject: xrdp: pid file fixes --- common/os_calls.c | 38 ++++++++++++++++++++++++++++++++++++++ common/os_calls.h | 2 ++ 2 files changed, 40 insertions(+) (limited to 'common') 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 @@ -1404,6 +1404,44 @@ g_create_dir(const char* dirname) #endif } +/*****************************************************************************/ +/* 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 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); -- cgit v1.2.1