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
* 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
*/
ase_fio_t* ase_fio_open (
ase_mmgr_t* mmgr,
ase_size_t ext,
ase_mmgr_t* mmgr,
ase_size_t ext,
const ase_char_t* path,
int flags,
int mode
int flags,
int mode
);
/******/
/****f* ase.fio/ase_fio_close
* NAME
* ase_fio_close - close a file
*
* SYNOPSIS
*/
void ase_fio_close (
ase_fio_t* fio
);
/******/
ase_fio_t* ase_fio_init (
ase_fio_t* fio,

View File

@ -139,21 +139,23 @@ ase_fio_t* ase_fio_init (
#endif
/*
* rwa -> RDWR | APPEND
* ra -> RDONLY | APPEND
* ra -> RDWR | APPEND
* wa -> 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_READ) &&
!(flags & ASE_FIO_WRITE)) desired_access |= O_WRONLY;
if ((flags & ASE_FIO_READ)) desired_access |= O_RDWR;
else desired_access |= O_WRONLY;
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_TRUNCATE) desired_access |= O_TRUNC;