You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@httpd.apache.org by rb...@hyperreal.org on 1999/02/22 14:04:11 UTC
cvs commit: apache-apr/apr/file_io/unix open.c
rbb 99/02/22 05:04:10
Added: apr/file_io/unix open.c
Log:
This is the initial revision of the apr_open routine. Hasn't been tested
yet, but I'll get to it later this week.
Revision Changes Path
1.1 apache-apr/apr/file_io/unix/open.c
Index: open.c
===================================================================
#include "file_io.h"
API_EXPORT(APRFile *) apr_open(char *fname, int flag, mode_t mode)
{
int oflags = 0;
APR_FILE *dafile;
struct stat info;
if ((flag && APR_READ) && (flag && APR_WRITE))
oflags = O_RDWR;
else if (flag && APR_READ)
oflags = O_RDONLY;
else if (flag && APR_WRITE)
oflags = O_WRONLY;
else {
errno = EACCESS;
return NULL;
}
if (flag && APR_BUFFERED)
dafile->buffered = TRUE
strcpy(dafile->fname, fname);
if (flag && APR_CREATE) {
oflags |= O_CREAT;
if (flag && APR_EXCL)
oflags |= O_EXCL;
}
if ((flag && APR_EXCL) && !(flag && APR_CREATE)) {
errno = EACCESS;
return NULL;
}
if (flag && APR_APPEND)
oflags |= O_APPEND;
if (flag && APR_TRUNCATE)
oflags = O_TRUNC;
if (flag && APR_NONBLOCK)
oflags = O_NONBLOCK;
else
oflags = O_SYNC;
dafile->filedes = open(fname, oflags, mode);
if (dafile->filedes < 0)
return NULL;
if (stat(dafile->filedes, &info) == 0) {
dafile->protection = info.st_mode;
dafile->user = info.st_uid;
dafile->group = info.st_gid;
dafile->size = info.st_size;
dafile->atime = info.st_atime;
dafile->mtime = info.st_mtime;
dafile->ctime = info.st_ctime;
return dafile;
} else {
errno = ENOSTAT;
return NULL;
}
}