Changeset 94 in libcf for trunk/src/cf_file.c


Ignore:
Timestamp:
05/25/13 22:36:56 (11 years ago)
Author:
cheese
Message:

#1 change interface to get file size

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/cf_file.c

    r93 r94  
    198198 */
    199199int
    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)
     200CF_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)
    208213        return CF_ERROR_FILE_GET_SIZE;
    209214
    210     return result;
     215    CF_File_Close (fd);
     216
     217    return length;
    211218}
    212219
Note: See TracChangeset for help on using the changeset viewer.