ini: not using getenv
[platform/core/uifw/libtdm.git] / src / tdm_helper.c
index cd6426f..e3d5f3f 100644 (file)
@@ -61,26 +61,20 @@ tdm_helper_get_time(void)
 }
 
 static int
-_tdm_helper_check_file_is_valid(const char* path, int del_link)
+_tdm_helper_check_file_is_symbolic_link(const char* path)
 {
-       char *real_path;
+       struct stat sb;
 
        if (!path)
                return 0;
 
-       real_path = realpath(path, NULL);
-       if (real_path && strncmp(path, real_path, strlen(path))) {
-               if (del_link)
-                       unlink(path);
-               free(real_path);
-
+       if (stat(path, &sb) != 0)
                return 0;
-       }
 
-       if (real_path)
-               free(real_path);
+       if (S_ISLNK(sb.st_mode))
+               return 1;
 
-       return 1;
+       return 0;
 }
 
 static void
@@ -90,8 +84,10 @@ _tdm_helper_dump_raw(const char *file, void *data1, int size1, void *data2,
        unsigned int *blocks;
        FILE *fp;
 
-       if (!_tdm_helper_check_file_is_valid(file, 1))
-               TDM_WRN("'%s' may be symbolic link\n", file);
+       if (_tdm_helper_check_file_is_symbolic_link(file)) {
+               TDM_ERR("'%s' may be symbolic link\n", file);
+               return;
+       }
 
        fp = fopen(file, "w+");
        TDM_RETURN_IF_FAIL(fp != NULL);
@@ -118,8 +114,10 @@ _tdm_helper_dump_png(const char *file, const void *data, int width,
 {
        FILE *fp;
 
-       if (!_tdm_helper_check_file_is_valid(file, 1))
-               TDM_WRN("'%s' may be symbolic link\n", file);
+       if (_tdm_helper_check_file_is_symbolic_link(file)) {
+               TDM_ERR("'%s' may be symbolic link\n", file);
+               return;
+       }
 
        fp = fopen(file, "wb");
        TDM_RETURN_IF_FAIL(fp != NULL);
@@ -725,7 +723,6 @@ tdm_helper_capture_output(tdm_output *output, tbm_surface_h dst_buffer,
        TDM_RETURN_VAL_IF_FAIL(w >= 0, TDM_ERROR_INVALID_PARAMETER);
        TDM_RETURN_VAL_IF_FAIL(h >= 0, TDM_ERROR_INVALID_PARAMETER);
        TDM_RETURN_VAL_IF_FAIL(func != NULL, TDM_ERROR_INVALID_PARAMETER);
-       TDM_RETURN_VAL_IF_FAIL(data != NULL, TDM_ERROR_INVALID_PARAMETER);
 
        err = tdm_output_get_layer_count(output, &count);
        if (err != TDM_ERROR_NONE) {