From: Kim Gunsoo Date: Mon, 7 Sep 2015 11:06:12 +0000 (+0900) Subject: Redefine the working directory path of the SDB server. X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=bf00b52a94a57597fde4bd62369f3a65836e4db4;p=sdk%2Ftools%2Fsdb.git Redefine the working directory path of the SDB server. - A working directory places in the module path of the SDB server in Windows OS. Change-Id: I0ce8167468997378773138d4cd714f9a069a7802 Signed-off-by: Kim Gunsoo --- diff --git a/src/sdb.c b/src/sdb.c index b7d7c43..ba44497 100755 --- a/src/sdb.c +++ b/src/sdb.c @@ -114,6 +114,43 @@ static void init_map() { #endif } +#ifdef OS_WINDOWS +void change_working_directory(void) +{ + TCHAR currentDir[MAX_PATH] = {0,}; + TCHAR modulePath[MAX_PATH] = {0,}; + DWORD dwRet = 0; + char* p = NULL; + + dwRet = GetCurrentDirectory(MAX_PATH, currentDir); + if (dwRet == 0) { + LOG_INFO("GetCurrentDirectory failed (%d)\n", GetLastError()); + return; + } + if (dwRet > MAX_PATH) { + LOG_INFO("Buffer too small; need %d charactors\n", dwRet); + return; + } + LOG_INFO("Current directory : %s\n", currentDir); + + if (!GetModuleFileName(NULL, modulePath, sizeof(modulePath))) { + LOG_INFO("GetModuleFileName failed (%d)\n", GetLastError()); + return; + } + LOG_INFO("Module path : %s\n", modulePath); + + p = strrchr(modulePath, '\\'); + if (p) { + p[1] = '\0'; + } + + if (!SetCurrentDirectory(modulePath)) { + LOG_INFO("SetCurrentDirectory failed (%d)\n", GetLastError()); + return; + } + LOG_INFO("Set current directory to : %s\n", modulePath); +} +#endif int sdb_main(int is_daemon, int server_port) { @@ -141,6 +178,8 @@ int sdb_main(int is_daemon, int server_port) sdb_usb_init(); #ifdef OS_WINDOWS + change_working_directory(); + sdb_thread_t thr; void* (*func)(void *); func = local_init_thread;