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


Ignore:
Timestamp:
04/06/13 21:44:24 (11 years ago)
Author:
cheese
Message:

#1 arrange definition and fix for windows

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/cf_file.c

    r50 r55  
    1313#if defined(_WIN32) || defined(_WIN64)
    1414# include <io.h>
     15# include <direct.h>
    1516
    1617# define DELIMITER      '\\'
    1718# define mkdir(a,b)     _mkdir (a)
    1819# define access(a,b)    _access (a,b)
     20# define snprintf       _snprintf
    1921
    2022# define F_OK           0
     
    4648#define FILE_MODE       S_IWUSR|S_IRUSR|S_IRGRP|S_IROTH
    4749
     50#define ASSERT_ARGS(x)                  \
     51    if ((x))                            \
     52        return CF_ERROR_FILE_INVALID_ARGS
     53
    4854/**
    4955 * 파일 열기
     
    6066              const CF_FILE_FLAG    flag)
    6167{
    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));
    6373
    6474    if (result < 0)
     
    7888CF_File_Create (const char * path)
    7989{
    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);
    8195
    8296    if (result < 0)
     
    98112    int result = 0;
    99113
    100     if (fd < 0)
    101         return CF_ERROR_FILE_INVALID_ARGS;
     114    ASSERT_ARGS (fd < 0);
    102115
    103116    result = close (fd);
     
    123136              const size_t  len)
    124137{
    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);
    126144
    127145    if (result < 0)
     
    145163               const size_t len)
    146164{
    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);
    148171
    149172    if (result != len)
     
    163186CF_File_GetSize (const int fd)
    164187{
    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);
    166193
    167194    if (result < 0 || lseek (fd, 0, SEEK_SET) < 0)
     
    187214    char    * f = fullPath;
    188215    char    * d = stepPath;
     216
     217    ASSERT_ARGS (path == NULL);
    189218
    190219    snprintf (fullPath, sizeof (fullPath) - 1, "%s%c", path, DELIMITER);
Note: See TracChangeset for help on using the changeset viewer.