}
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
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);
{
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);
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) {