Changeset 94 in libcf
- Timestamp:
- 05/25/13 22:36:56 (11 years ago)
- Location:
- trunk
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/include/cf_file.h
r90 r94 49 49 50 50 CF_EXPORT int 51 CF_File_GetSize (const int fd);51 CF_File_GetSize (const char * path); 52 52 53 53 CF_EXPORT int -
trunk/src/cf_file.c
r93 r94 198 198 */ 199 199 int 200 CF_File_GetSize (const int fd) 201 { 202 int result = 0; 203 204 ASSERT_ARGS (fd < 0); 205 206 result = (int) lseek (fd, 0, SEEK_END); 207 if (result < 0 || lseek (fd, 0, SEEK_SET) < 0) 200 CF_File_GetSize (const char * path) 201 { 202 int length = 0; 203 int fd = 0; 204 205 ASSERT_ARGS (path == NULL); 206 207 fd = CF_File_Open (path, CF_FILE_READ); 208 if (fd < 0) 209 return CF_ERROR_FILE_OPEN; 210 211 length = (int) lseek (fd, 0, SEEK_END); 212 if (length < 0) 208 213 return CF_ERROR_FILE_GET_SIZE; 209 214 210 return result; 215 CF_File_Close (fd); 216 217 return length; 211 218 } 212 219 -
trunk/test/file.c
r86 r94 34 34 // error 35 35 } 36 printf ("file size : %d\n", CF_File_GetSize ( fd));36 printf ("file size : %d\n", CF_File_GetSize (name)); 37 37 if (CF_File_Read (fd, buffer, sizeof (buffer)) < 0) { 38 38 // error -
trunk/test/test.c
r90 r94 185 185 "-- %d bytes of %d bytes\n", 186 186 sizeof (buffer), 187 CF_File_GetSize (f d));187 CF_File_GetSize (file)); 188 188 189 189 CF_File_Close (fd);
Note:
See TracChangeset
for help on using the changeset viewer.