source: libcf/trunk/include/cf_file.h@ 26

Last change on this file since 26 was 26, checked in by cheese, 11 years ago

#1 documentation with doxygen

File size: 2.5 KB
Line 
1/**
2 * @file cf_file.h
3 * @author myusgun <myusgun@gmail.com>
4 * @version 0.1
5 */
6#ifndef __CF_FILE_H__
7#define __CF_FILE_H__
8
9#include "cf_base.h"
10#include <fcntl.h>
11
12#define CF_ERROR_FILE_OPEN CF_ERROR_FILE - 1
13#define CF_ERROR_FILE_INVALID_ARGS CF_ERROR_FILE - 2
14#define CF_ERROR_FILE_READ CF_ERROR_FILE - 3
15#define CF_ERROR_FILE_WRITE CF_ERROR_FILE - 4
16#define CF_ERROR_FILE_CREATE CF_ERROR_FILE - 5
17#define CF_ERROR_FILE_CLOSE CF_ERROR_FILE - 6
18#define CF_ERROR_FILE_GET_SIZE CF_ERROR_FILE - 7
19
20/** 파일 열기 옵션 플래그 */
21typedef enum {
22 CF_FILE_RO = O_RDONLY, /**< 읽기 전용 */
23 CF_FILE_WO = O_WRONLY, /**< 쓰기 전용 */
24 CF_FILE_WR = O_RDWR, /**< 읽기/쓰기 */
25 CF_FILE_CR = O_CREAT, /**< 파일이 존재하지 않으면 생성 */
26 CF_FILE_TR = O_TRUNC, /**< 파일이 존재하면 비우기 */
27 CF_FILE_AP = O_APPEND /**< 파일이 존재하면 이어서 쓰기 */
28} E_CF_FILE_FLAG, CF_FILE_FLAG;
29
30#ifdef __cplusplus
31extern "C" {
32#endif
33
34/**
35 * 파일 열기
36 *
37 * @return 성공 시, 파일 디스크립터; 실패 시, 오류 코드
38 *
39 * @param path 파일 경로
40 * @param flag 파일 열기 플래그
41 *
42 * @see CF_FILE_FLAG
43 */
44CF_EXPORT int
45CF_File_Open (const char * path,
46 const CF_FILE_FLAG flag);
47
48/**
49 * 파일 닫기
50 *
51 * @return 성공 시, CF_OK; 실패 시, 오류 코드
52 *
53 * @param fd 파일 디스크립터
54 */
55CF_EXPORT int
56CF_File_Close (const int fd);
57
58/**
59 * 파일 생성
60 *
61 * @return 성공 시, 파일 디스크립터; 실패 시, 오류 코드
62 *
63 * @param path 파일 경로
64 */
65CF_EXPORT int
66CF_File_Create (const char * path);
67
68/**
69 * 파일 읽기
70 *
71 * @return 성공 시, 읽은 바이트 수; 실패 시, 오류 코드
72 *
73 * @param fd 파일 디스크립터
74 * @param buf 데이터를 저장할 메모리
75 * @param len 데이터를 저장할 메모리의 크기
76 */
77CF_EXPORT int
78CF_File_Read (const int fd,
79 void * buf,
80 const size_t len);
81
82/**
83 * 파일 쓰기
84 *
85 * @return 성공 시, CF_OK; 실패 시, 오류 코드
86 *
87 * @param fd 파일 디스크립터
88 * @param buf 데이터가 저장된 메모리
89 * @param len 쓸 데이터의 길이
90 */
91CF_EXPORT int
92CF_File_Write (const int fd,
93 const void * buf,
94 const size_t len);
95
96/**
97 * 파일 크기 얻기
98 *
99 * @return 성공 시, 파일 크기; 실패 시, 오류 코드
100 *
101 * @param fd 파일 디스크립터
102 */
103CF_EXPORT int
104CF_File_GetSize (const int fd);
105
106#ifdef __cplusplus
107}
108#endif
109
110#endif // #ifndef __CF_FILE_H__
Note: See TracBrowser for help on using the repository browser.