Sync with tizen 2.4
[platform/core/messaging/msg-service.git] / include / utils / MsgUtilFile.h
1 /*
2  * Copyright (c) 2014 Samsung Electronics Co., Ltd. All rights reserved
3  *
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
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
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.
15 */
16
17 #ifndef MSG_UTIL_FILE_H
18 #define MSG_UTIL_FILE_H
19
20 #include <stdio.h>
21 /*==================================================================================================
22                                         DEFINES
23 ==================================================================================================*/
24 #define FM_READ_WRITE_BUFFER_MAX (1024*1024*3)
25
26 /*==================================================================================================
27                                         FUNCTION PROTOTYPES
28 ==================================================================================================*/
29 /**  file operation wrapper - for avoding runtime error */
30 FILE* MsgOpenFile(const char* filepath, const char* opt);
31 void MsgCloseFile(FILE* pFile);
32 int MsgFseek(FILE* pFile, long int offset, int origin);
33 size_t MsgWriteFile(const char* pData, size_t size, size_t count, FILE  *pFile);
34 size_t MsgReadFile(void *pData, size_t size, size_t count, FILE *pFile);
35 long int MsgFtell(FILE *pFile);
36 int MsgFflush(FILE *pFile);
37 int MsgFsync(FILE *pFile);
38
39 bool MsgCreateFileName(char *pFileName);
40 bool MsgOpenAndReadFile(const char *pFileName, char **ppData, int *pDataSize);
41 bool MsgReadFileForDecode(FILE* pFile, char* pBuf, int length, int* nSize);
42 bool    MsgWriteDataFromEncodeBuffer(FILE* pFile, char* pInBuffer, int *pPtr, int maxLen, int* pOffset );
43 bool MsgWriteIpcFile(const char *pFileName, const char *pData, int DataSize);
44 void MsgDeleteFile(const char *pFileName);
45 bool MsgGetFileSize(const char *pFilePath, int* nSize);
46 int MsgGetFileSize(const char *pFileName);
47 FILE*  MsgOpenMMSFile(char *pFileName);
48 bool MsgOpenCreateAndOverwriteFile(char *pFullPath, char *pBuff, int TotalLength);
49 char* MsgOpenAndReadMmsFile(const char* szFilePath, int offset, int size, int* npSize );
50 bool MsgWriteSmilFile(const char *pFilePath,char *pData, int DataSize);
51 int     MsgReadSmilFile(const char *pFileName, char **ppData);
52 void MsgDeleteSmilFile(const char *pFilePath);
53 int MsgRmRf(char *pDirPath);
54 unsigned int MsgDu(const char *pDirPath);
55 bool MsgAppendFile(const char *pFilePath, const char *pData, int DataSize);
56 void MsgMmsInitDir();
57 bool MsgAccessFile(const char *filepath, int mode);
58 bool MsgChmod(const char *filepath, int mode);
59 bool MsgChown(const char *filepath, int uid, int gid);
60 bool MsgCreateFile(const char *pFilePath,char *pData, int DataSize);
61 char *MsgGetDirName(char *file_path);
62 char *MsgGetFileName(char *file_path);
63
64 #endif // MSG_UTIL_FILE_H
65