/* LCOV_EXCL_START */
static int
-_tbm_surface_check_file_is_valid(const char* path, int del_link)
+_tbm_surface_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;
}
/* LCOV_EXCL_STOP */
FILE *fp;
unsigned int *blocks;
- if (!_tbm_surface_check_file_is_valid(file, 1))
+ if (_tbm_surface_check_file_is_symbolic_link(file))
TBM_LOG_E("%s is symbolic link\n", file);
fp = fopen(file, "w+");
png_bytep *row_pointers;
int depth = 8, y;
- if (!_tbm_surface_check_file_is_valid(file, 1))
+ if (_tbm_surface_check_file_is_symbolic_link(file))
TBM_LOG_E("%s is symbolic link\n", file);
fp = fopen(file, "wb");