Skip to content

Commit

Permalink
Merge pull request #4 from metwork-framework/issue3
Browse files Browse the repository at this point in the history
feat: prefix control files names by "." (dot)
  • Loading branch information
thefab authored Feb 24, 2020
2 parents 3466a3d + a2264dc commit c1b13e6
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 4 deletions.
7 changes: 6 additions & 1 deletion src/control.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

/**
Expand Down
2 changes: 1 addition & 1 deletion src/log_proxy.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
4 changes: 2 additions & 2 deletions src/test_log_proxy.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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);
Expand Down

0 comments on commit c1b13e6

Please sign in to comment.