12 readable = writable =
false;
26 mode_t xmode = fcntl(rwfd, F_GETFL);
27 xmode = xmode & (O_RDONLY | O_WRONLY | O_RDWR);
28 readable = (xmode == O_RDONLY) || (xmode == O_RDWR);
29 writable = (xmode == O_WRONLY) || (xmode == O_RDWR);
32 readable = writable =
false;
42 open(filename, mode, create_mode);
48 return new WvFile(s, O_RDONLY, 0666);
53 return new WvFile(s, O_WRONLY|O_CREAT|O_TRUNC, 0666);
58 return new WvFile(s, O_RDWR|O_CREAT, 0666);
66bool WvFile::open(WvStringParm filename,
int mode,
int create_mode)
72 int xmode = (mode & (O_RDONLY | O_WRONLY | O_RDWR));
73 readable = (xmode == O_RDONLY) || (xmode == O_RDWR);
74 writable = (xmode == O_WRONLY) || (xmode == O_RDWR);
82 int rwfd = ::open(filename, mode | O_NONBLOCK, create_mode);
84 int rwfd = ::_open(filename, mode | O_NONBLOCK, create_mode);
92 fcntl(rwfd, F_SETFD, 1);
100bool WvFile::open(
int _rwfd)
109 int mode = fcntl(_rwfd, F_GETFL);
110 int xmode = (mode & (O_RDONLY | O_WRONLY | O_RDWR));
111 readable = (xmode == O_RDONLY) || (xmode == O_RDWR);
112 writable = (xmode == O_WRONLY) || (xmode == O_RDWR);
118 fcntl(_rwfd, F_SETFL, mode | O_NONBLOCK);
119 fcntl(_rwfd, F_SETFD, 1);
131 if (!readable) si.wants.readable =
false;
132 if (!writable) si.wants.writable =
false;
The basic interface which is included by all other XPLC interfaces and objects.
void noerr()
Reset our error state - there's no error condition anymore.
void setfd(int fd)
Sets the file descriptor for both reading and writing.
virtual void close()
Closes the file descriptors.
virtual bool post_select(SelectInfo &si)
post_select() is called after select(), and returns true if this object is now ready.
virtual void pre_select(SelectInfo &si)
pre_select() sets up for eventually calling select().
WvFile implements a stream connected to a file or Unix device.
virtual bool post_select(SelectInfo &si)
post_select() is called after select(), and returns true if this object is now ready.
virtual void pre_select(SelectInfo &si)
pre_select() sets up for eventually calling select().
WvFile()
Create an empty WvFile that you'll open later with open().
A type-safe version of WvMonikerBase that lets you provide create functions for object types other th...
void undo_force_select(bool readable, bool writable, bool isexception=false)
Undo a previous force_select() - ie.
bool stop_read
True if noread()/nowrite()/close() have been called, respectively.
virtual void seterr(int _errnum)
Override seterr() from WvError so that it auto-closes the stream.
the data structure used by pre_select()/post_select() and internally by select().