Changeset 55 in libcf for trunk/src/cf_file.c
- Timestamp:
- 04/06/13 21:44:24 (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/cf_file.c
r50 r55 13 13 #if defined(_WIN32) || defined(_WIN64) 14 14 # include <io.h> 15 # include <direct.h> 15 16 16 17 # define DELIMITER '\\' 17 18 # define mkdir(a,b) _mkdir (a) 18 19 # define access(a,b) _access (a,b) 20 # define snprintf _snprintf 19 21 20 22 # define F_OK 0 … … 46 48 #define FILE_MODE S_IWUSR|S_IRUSR|S_IRGRP|S_IROTH 47 49 50 #define ASSERT_ARGS(x) \ 51 if ((x)) \ 52 return CF_ERROR_FILE_INVALID_ARGS 53 48 54 /** 49 55 * 파일 열기 … … 60 66 const CF_FILE_FLAG flag) 61 67 { 62 int result = open (path, (int)(flag|O_BINARY)); 68 int result = 0; 69 70 ASSERT_ARGS (path == NULL); 71 72 result = open (path, (int)(flag|O_BINARY)); 63 73 64 74 if (result < 0) … … 78 88 CF_File_Create (const char * path) 79 89 { 80 int result = open (path, CF_FILE_CR|CF_FILE_WO|CF_FILE_TR, FILE_MODE); 90 int result = 0; 91 92 ASSERT_ARGS (path == NULL); 93 94 result = open (path, CF_FILE_CR|CF_FILE_WO|CF_FILE_TR, FILE_MODE); 81 95 82 96 if (result < 0) … … 98 112 int result = 0; 99 113 100 if (fd < 0) 101 return CF_ERROR_FILE_INVALID_ARGS; 114 ASSERT_ARGS (fd < 0); 102 115 103 116 result = close (fd); … … 123 136 const size_t len) 124 137 { 125 int result = (int) read (fd, buf, len); 138 int result = 0; 139 140 ASSERT_ARGS (fd < 0); 141 ASSERT_ARGS (buf == NULL); 142 143 result = (int) read (fd, buf, len); 126 144 127 145 if (result < 0) … … 145 163 const size_t len) 146 164 { 147 int result = (int) write (fd, buf, len); 165 int result = 0; 166 167 ASSERT_ARGS (fd < 0); 168 ASSERT_ARGS (buf == NULL); 169 170 (int) write (fd, buf, len); 148 171 149 172 if (result != len) … … 163 186 CF_File_GetSize (const int fd) 164 187 { 165 int result = (int) lseek (fd, 0, SEEK_END); 188 int result = 0; 189 190 ASSERT_ARGS (fd < 0); 191 192 (int) lseek (fd, 0, SEEK_END); 166 193 167 194 if (result < 0 || lseek (fd, 0, SEEK_SET) < 0) … … 187 214 char * f = fullPath; 188 215 char * d = stepPath; 216 217 ASSERT_ARGS (path == NULL); 189 218 190 219 snprintf (fullPath, sizeof (fullPath) - 1, "%s%c", path, DELIMITER);
Note:
See TracChangeset
for help on using the changeset viewer.