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.
21 #include "mtp_datatype.h"
22 #include "mtp_config.h"
24 #define LINUX_MAX_PATHNAME_LENGTH 4096
25 #define MTP_FILE_ATTR_INVALID 0xFFFFFFFF
26 #define MTP_LOG_FILE "/var/log/mtp.log"
27 #define MTP_LOG_MAX_SIZE 5 * 1024 * 1024 /*5MB*/
36 MTP_FILE_ATTR_MODE_NONE = 0x00000000,
37 MTP_FILE_ATTR_MODE_REG = 0x00000100,
38 MTP_FILE_ATTR_MODE_DIR = 0x00000200,
39 MTP_FILE_ATTR_MODE_READ_ONLY = 0x00000400,
40 MTP_FILE_ATTR_MODE_HIDDEN = 0x00000800,
41 MTP_FILE_ATTR_MODE_SYSTEM = 0x00001000
45 file_attr_mode_t attribute;
47 time_t ctime; /* created time */
48 time_t mtime; /* modified time */
52 mtp_char filename[MTP_MAX_PATHNAME_SIZE + 1];
60 MTP_FILE_APPEND = 0x4,
61 MTP_FILE_TRUNCATE = 0x8
66 mtp_uint64 avail_size;
67 mtp_uint64 reserved_size;
70 FILE* _util_file_open(const mtp_char *filename, file_mode_t mode,
72 void _util_file_read(FILE* fhandle, void *bufptr, mtp_uint32 size,
73 mtp_uint32 *read_count);
74 mtp_uint32 _util_file_write(FILE* fhandle, void *bufptr, mtp_uint32 size);
75 mtp_int32 _util_file_close(FILE* fhandle);
76 mtp_bool _util_file_seek(FILE* fhandle, off_t offset, mtp_int32 whence);
77 mtp_bool _util_file_copy(const mtp_char *origpath, const mtp_char *newpath,
79 mtp_bool _util_copy_dir_children_recursive(const mtp_char *origpath,
80 const mtp_char *newpath, mtp_int32 *error);
81 mtp_bool _util_file_move(const mtp_char *origpath, const mtp_char *newpath,
83 mtp_bool _util_get_file_attrs(const mtp_char *filename, file_attr_t *attrs);
84 mtp_bool _util_set_file_attrs(const mtp_char *filename, mtp_dword attrs);
85 mtp_bool _util_dir_create(const mtp_char *dirname, mtp_int32 *error);
86 mtp_int32 _util_remove_dir_children_recursive(const mtp_char *dirname,
87 mtp_uint32 *num_of_deleted_file, mtp_uint32 *num_of_file, mtp_bool readonly);
88 mtp_bool _util_ifind_next(char *dir_name, DIR *dirp, dir_entry_t *dir_info);
89 mtp_bool _util_ifind_first(char *dir_name, DIR **dirp, dir_entry_t *dir_info);
90 mtp_bool _util_is_file_opened(const mtp_char *fullpath);
91 mtp_bool _util_get_filesystem_info(mtp_char *storepath, fs_info_t *fs_info);
92 void _util_count_num_lines(FILE* fhandle, mtp_uint32 *num_lines);
93 void _util_fill_guid_array(void *guidarray, mtp_uint32 start_index, FILE* fhandle,
95 void FLOGD(const char *fmt, ...);
97 #endif /* _MTP_FS_H_ */