2 * Copyright (c) 2012, 2013 Samsung Electronics Co., Ltd.
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.
25 #include "mtp_datatype.h"
26 #include "mtp_config.h"
28 #define LINUX_MAX_PATHNAME_LENGTH 4096
29 #define MTP_FILE_ATTR_INVALID 0xFFFFFFFF
30 #define MTP_LOG_FILE "/var/log/mtp.log"
31 #define MTP_LOG_MAX_SIZE 5 * 1024 * 1024 /*5MB*/
40 MTP_FILE_ATTR_MODE_NONE = 0x00000000,
41 MTP_FILE_ATTR_MODE_REG = 0x00000100,
42 MTP_FILE_ATTR_MODE_DIR = 0x00000200,
43 MTP_FILE_ATTR_MODE_READ_ONLY = 0x00000400,
44 MTP_FILE_ATTR_MODE_HIDDEN = 0x00000800,
45 MTP_FILE_ATTR_MODE_SYSTEM = 0x00001000
49 file_attr_mode_t attribute;
51 time_t ctime; /* created time */
52 time_t mtime; /* modified time */
56 mtp_char filename[MTP_MAX_PATHNAME_SIZE + 1];
64 MTP_FILE_APPEND = 0x4,
65 MTP_FILE_TRUNCATE = 0x8
70 mtp_uint64 avail_size;
71 mtp_uint64 reserved_size;
74 FILE* _util_file_open(const mtp_char *filename, file_mode_t mode,
76 void _util_file_read(FILE* fhandle, void *bufptr, mtp_uint32 size,
77 mtp_uint32 *read_count);
78 mtp_uint32 _util_file_write(FILE* fhandle, void *bufptr, mtp_uint32 size);
79 mtp_int32 _util_file_close(FILE* fhandle);
80 mtp_bool _util_file_seek(FILE* fhandle, off_t offset, mtp_int32 whence);
81 mtp_bool _util_file_copy(const mtp_char *origpath, const mtp_char *newpath,
83 mtp_bool _util_copy_dir_children_recursive(const mtp_char *origpath,
84 const mtp_char *newpath, mtp_uint32 store_id, mtp_int32 *error);
85 mtp_bool _util_file_move(const mtp_char *origpath, const mtp_char *newpath,
87 mtp_bool _util_get_file_attrs(const mtp_char *filename, file_attr_t *attrs);
88 mtp_bool _util_set_file_attrs(const mtp_char *filename, mtp_dword attrs);
89 mtp_bool _util_dir_create(const mtp_char *dirname, mtp_int32 *error);
90 mtp_int32 _util_remove_dir_children_recursive(const mtp_char *dirname,
91 mtp_uint32 *num_of_deleted_file, mtp_uint32 *num_of_file, mtp_bool readonly);
92 mtp_bool _util_ifind_next(char *dir_name, DIR *dirp, dir_entry_t *dir_info);
93 mtp_bool _util_ifind_first(char *dir_name, DIR **dirp, dir_entry_t *dir_info);
94 mtp_bool _util_is_file_opened(const mtp_char *fullpath);
95 mtp_bool _util_get_filesystem_info(mtp_char *storepath, fs_info_t *fs_info);
96 void _util_count_num_lines(FILE* fhandle, mtp_uint32 *num_lines);
97 void _util_fill_guid_array(void *guidarray, mtp_uint32 start_index, FILE* fhandle,
99 void FLOGD(const char *fmt, ...);
105 #endif /* _MTP_FS_H_ */