fixed flags handling of ase_fio_open()

This commit is contained in:
hyung-hwan 2008-12-12 23:47:07 +00:00
parent 596b42a211
commit d28108c996
2 changed files with 24 additions and 13 deletions

View File

@ -65,22 +65,31 @@ extern "C" {
* NAME * NAME
* ase_fio_open - open a file * ase_fio_open - open a file
* *
* PARAMETERS * DESCRIPTION
* To open a file, you should set the flags with at least one of
* ASE_FIO_READ, ASE_FIO_WRITE, ASE_FIO_APPEND.
* *
* SYNOPSIS * SYNOPSIS
*/ */
ase_fio_t* ase_fio_open ( ase_fio_t* ase_fio_open (
ase_mmgr_t* mmgr, ase_mmgr_t* mmgr,
ase_size_t ext, ase_size_t ext,
const ase_char_t* path, const ase_char_t* path,
int flags, int flags,
int mode int mode
); );
/******/ /******/
/****f* ase.fio/ase_fio_close
* NAME
* ase_fio_close - close a file
*
* SYNOPSIS
*/
void ase_fio_close ( void ase_fio_close (
ase_fio_t* fio ase_fio_t* fio
); );
/******/
ase_fio_t* ase_fio_init ( ase_fio_t* ase_fio_init (
ase_fio_t* fio, ase_fio_t* fio,

View File

@ -139,21 +139,23 @@ ase_fio_t* ase_fio_init (
#endif #endif
/* /*
* rwa -> RDWR | APPEND * rwa -> RDWR | APPEND
* ra -> RDONLY | APPEND * ra -> RDWR | APPEND
* wa -> WRONLY | APPEND * wa -> WRONLY | APPEND
* a -> WRONLY | APPEND * a -> WRONLY | APPEND
*/ */
if ((flags & ASE_FIO_READ) &&
(flags & ASE_FIO_WRITE)) desired_access |= O_RDWR;
else if (flags & ASE_FIO_READ) desired_access |= O_RDONLY;
else if (flags & ASE_FIO_WRITE) desired_access |= O_WRONLY;
if (flags & ASE_FIO_APPEND) if (flags & ASE_FIO_APPEND)
{ {
if (!(flags & ASE_FIO_READ) && if ((flags & ASE_FIO_READ)) desired_access |= O_RDWR;
!(flags & ASE_FIO_WRITE)) desired_access |= O_WRONLY; else desired_access |= O_WRONLY;
desired_access |= O_APPEND; desired_access |= O_APPEND;
} }
else
{
if ((flags & ASE_FIO_READ) &&
(flags & ASE_FIO_WRITE)) desired_access |= O_RDWR;
else if (flags & ASE_FIO_READ) desired_access |= O_RDONLY;
else if (flags & ASE_FIO_WRITE) desired_access |= O_WRONLY;
}
if (flags & ASE_FIO_CREATE) desired_access |= O_CREAT; if (flags & ASE_FIO_CREATE) desired_access |= O_CREAT;
if (flags & ASE_FIO_TRUNCATE) desired_access |= O_TRUNC; if (flags & ASE_FIO_TRUNCATE) desired_access |= O_TRUNC;