2 * Copyright (c) 2013 Samsung Electronics Co., Ltd All Rights Reserved
4 * Licensed under the Apache License, Version 2.0 (the License);
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an AS IS BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
22 #include <sys/types.h>
25 #include <sys/statfs.h>
28 #include "download-provider-log.h"
30 char *dp_strdup(char *src)
36 TRACE_ERROR("[CHECK PARAM]");
40 src_len = strlen(src);
42 TRACE_ERROR("[CHECK PARAM] len[%zd]", src_len);
46 dest = (char *)calloc(src_len + 1, sizeof(char));
48 TRACE_ERROR("[CHECK] allocation");
51 memcpy(dest, src, src_len * sizeof(char));
57 int dp_is_file_exist(const char *file_path)
59 struct stat file_state;
62 if (file_path == NULL) {
63 TRACE_ERROR("[NULL-CHECK] file path is NULL");
67 stat_ret = stat(file_path, &file_state);
70 if (file_state.st_mode & S_IFREG)
76 long dp_get_file_modified_time(const char *file_path)
78 struct stat file_state;
81 if (file_path == NULL) {
82 TRACE_ERROR("[NULL-CHECK] file path is NULL");
86 stat_ret = stat(file_path, &file_state);
88 return file_state.st_mtime;
92 int dp_remove_file(const char *file_path)
94 if ((file_path != NULL && strlen(file_path) > 0) &&
95 dp_is_file_exist(file_path) == 0) {
96 if (unlink(file_path) != 0) {
97 TRACE_ERROR("failed to remove file");