[4] | 1 | /**
|
---|
[26] | 2 | * @file cf_file.h
|
---|
| 3 | * @author myusgun <myusgun@gmail.com>
|
---|
| 4 | * @version 0.1
|
---|
[34] | 5 | *
|
---|
[35] | 6 | * @example file.c
|
---|
[4] | 7 | */
|
---|
| 8 | #ifndef __CF_FILE_H__
|
---|
| 9 | #define __CF_FILE_H__
|
---|
| 10 |
|
---|
| 11 | #include "cf_base.h"
|
---|
| 12 | #include <fcntl.h>
|
---|
| 13 |
|
---|
| 14 | #define CF_ERROR_FILE_OPEN CF_ERROR_FILE - 1
|
---|
| 15 | #define CF_ERROR_FILE_INVALID_ARGS CF_ERROR_FILE - 2
|
---|
| 16 | #define CF_ERROR_FILE_READ CF_ERROR_FILE - 3
|
---|
| 17 | #define CF_ERROR_FILE_WRITE CF_ERROR_FILE - 4
|
---|
| 18 | #define CF_ERROR_FILE_CREATE CF_ERROR_FILE - 5
|
---|
| 19 | #define CF_ERROR_FILE_CLOSE CF_ERROR_FILE - 6
|
---|
| 20 | #define CF_ERROR_FILE_GET_SIZE CF_ERROR_FILE - 7
|
---|
| 21 |
|
---|
[26] | 22 | /** 파일 열기 옵션 플래그 */
|
---|
| 23 | typedef enum {
|
---|
| 24 | CF_FILE_RO = O_RDONLY, /**< 읽기 전용 */
|
---|
| 25 | CF_FILE_WO = O_WRONLY, /**< 쓰기 전용 */
|
---|
| 26 | CF_FILE_WR = O_RDWR, /**< 읽기/쓰기 */
|
---|
| 27 | CF_FILE_CR = O_CREAT, /**< 파일이 존재하지 않으면 생성 */
|
---|
| 28 | CF_FILE_TR = O_TRUNC, /**< 파일이 존재하면 비우기 */
|
---|
| 29 | CF_FILE_AP = O_APPEND /**< 파일이 존재하면 이어서 쓰기 */
|
---|
[16] | 30 | } E_CF_FILE_FLAG, CF_FILE_FLAG;
|
---|
[15] | 31 |
|
---|
[4] | 32 | #ifdef __cplusplus
|
---|
| 33 | extern "C" {
|
---|
| 34 | #endif
|
---|
| 35 |
|
---|
| 36 | CF_EXPORT int
|
---|
[16] | 37 | CF_File_Open (const char * path,
|
---|
| 38 | const CF_FILE_FLAG flag);
|
---|
[4] | 39 |
|
---|
| 40 | CF_EXPORT int
|
---|
[35] | 41 | CF_File_Create (const char * path);
|
---|
[4] | 42 |
|
---|
| 43 | CF_EXPORT int
|
---|
[35] | 44 | CF_File_Close (const int fd);
|
---|
[4] | 45 |
|
---|
| 46 | CF_EXPORT int
|
---|
| 47 | CF_File_Read (const int fd,
|
---|
| 48 | void * buf,
|
---|
| 49 | const size_t len);
|
---|
| 50 |
|
---|
| 51 | CF_EXPORT int
|
---|
| 52 | CF_File_Write (const int fd,
|
---|
| 53 | const void * buf,
|
---|
| 54 | const size_t len);
|
---|
| 55 |
|
---|
| 56 | CF_EXPORT int
|
---|
| 57 | CF_File_GetSize (const int fd);
|
---|
| 58 |
|
---|
| 59 | #ifdef __cplusplus
|
---|
| 60 | }
|
---|
| 61 | #endif
|
---|
| 62 |
|
---|
| 63 | #endif // #ifndef __CF_FILE_H__
|
---|