Add some chains to separate monitoring and restriction
[platform/core/connectivity/stc-manager.git] / src / helper / helper-file.c
index 636ef5d..73b93bd 100644 (file)
@@ -24,14 +24,17 @@ int fwrite_str(const char *path, const char *str)
        _cleanup_fclose_ FILE *f = NULL;
        int ret;
        char * t;
+       struct stat stat_buf;
 
        assert(path);
        assert(str);
 
-       t = realpath(path, NULL);
-       ret_value_errno_msg_if(!t, -errno,
-                              "Fail to get realpath %s", path);
-       free(t);
+       if (stat(path, &stat_buf) == 0) {
+               t = realpath(path, NULL);
+               ret_value_errno_msg_if(!t, -errno,
+                                      "Fail to get realpath %s", path);
+               free(t);
+       }
 
        f = fopen(path, "w");
        ret_value_errno_msg_if(!f, -errno,