diff --git a/src/control.c b/src/control.c index 00095f7..9f51aea 100644 --- a/src/control.c +++ b/src/control.c @@ -8,7 +8,12 @@ #include "control.h" gchar *_get_control_file_path(const gchar *path) { - return g_strdup_printf("%s.control", path); + gchar *dirpath = g_path_get_dirname(path); + gchar *basename = g_path_get_basename(path); + gchar *cfile = g_strdup_printf("%s/.%s.control", dirpath, basename); + g_free(dirpath); + g_free(basename); + return(cfile); } /** diff --git a/src/log_proxy.c b/src/log_proxy.c index 9a57c62..d68f22a 100644 --- a/src/log_proxy.c +++ b/src/log_proxy.c @@ -33,7 +33,7 @@ void clean_too_old_files() { return; } gchar *basename = g_path_get_basename(log_file); - gchar *control = g_strdup_printf("%s.control", basename); + gchar *control = g_strdup_printf(".%s.control", basename); GList *list = NULL; while (TRUE) { const gchar *name = g_dir_read_name(dir); diff --git a/src/test_log_proxy.c b/src/test_log_proxy.c index 2c96262..295dcd7 100644 --- a/src/test_log_proxy.c +++ b/src/test_log_proxy.c @@ -82,7 +82,7 @@ void test_create_empty() //tests on control.c void test_manage_control_file() { - g_unlink("log_file.control"); + g_unlink(".log_file.control"); // check init control file g_assert(init_control_file("log_file", "start")); // check content @@ -93,7 +93,7 @@ void test_manage_control_file() int fd1 = lock_control_file("log_file"); g_assert(fd1 >= 0); // check inode - int fd2 = g_open("log_file.control", O_RDONLY); + int fd2 = g_open(".log_file.control", O_RDONLY); g_assert_cmpint(get_fd_inode(fd1), ==, get_fd_inode(fd2)); // unlock control file unlock_control_file(fd1);