#include <file.hpp>
Static Public Member Functions | |
static int | open (const char *path, file::mode md, int fls, error &err) |
static bool | close (int fd, error &err) |
static int | read (int fd, void *buf, int n, error &err) |
static int | write (int fd, const void *buf, int n, error &err) |
static int | seek (int fd, int off, file::whence wh, error &err) |
Static Public Attributes | |
static const int | in = 0 |
static const int | out = 1 |
static const int | err = 2 |
Definition at line 160 of file file.hpp.
int ders::fd::open | ( | const char * | path, | |
file::mode | md, | |||
int | fls, | |||
error & | err | |||
) | [static] |
Definition at line 35 of file posix/fdimpl.cpp.
00036 { 00037 int m=0; 00038 switch (md) { 00039 case file::rdo: m=O_RDONLY; break; 00040 case file::wro: m=O_WRONLY; break; 00041 case file::rdwr: m=O_RDWR; break; 00042 default: assert(false); 00043 } 00044 00045 if (fls&file::app) m|=O_APPEND; 00046 if (fls&file::crt) m|=O_CREAT; 00047 if (fls&file::excl) m|=O_EXCL; 00048 if (fls&file::trnc) m|=O_TRUNC; 00049 00050 return setErr(::open(path, m, S_IREAD|S_IWRITE), err); 00051 }
bool ders::fd::close | ( | int | fd, | |
error & | err | |||
) | [static] |
int ders::fd::read | ( | int | fd, | |
void * | buf, | |||
int | n, | |||
error & | err | |||
) | [static] |
Definition at line 58 of file posix/fdimpl.cpp.
00059 { 00060 assert(n>0); 00061 int rc=::read(fd, buf, n); 00062 assert(rc<=n); 00063 00064 return setErr(rc, err); 00065 }
int ders::fd::write | ( | int | fd, | |
const void * | buf, | |||
int | n, | |||
error & | err | |||
) | [static] |
Definition at line 67 of file posix/fdimpl.cpp.
00068 { 00069 assert(n>0); 00070 int rc=::write(fd, buf, n); 00071 assert(rc<=n); 00072 00073 return setErr(rc, err); 00074 }
int ders::fd::seek | ( | int | fd, | |
int | off, | |||
file::whence | wh, | |||
error & | err | |||
) | [static] |
Definition at line 76 of file posix/fdimpl.cpp.
00077 { 00078 int w=0; 00079 switch (wh) { 00080 case file::set: w=SEEK_SET; break; 00081 case file::cur: w=SEEK_CUR; break; 00082 case file::end: w=SEEK_END; break; 00083 default: assert(false); 00084 } 00085 00086 return setErr(::lseek(fd, off, w), err); 00087 }
const int ders::fd::in = 0 [static] |
const int ders::fd::out = 1 [static] |
const int ders::fd::err = 2 [static] |