12 readable = writable =
false;
15 #ifndef _WIN32 // meaningless to do this on win32 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);
66 bool 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);
99 #ifndef _WIN32 // since win32 doesn't support fcntl 100 bool 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;
WvFile()
Create an empty WvFile that you'll open later with open()
A WvFastString acts exactly like a WvString, but can take (const char *) strings without needing to a...
The basic interface which is included by all other XPLC interfaces and objects.
void undo_force_select(bool readable, bool writable, bool isexception=false)
Undo a previous force_select() - ie.
virtual void pre_select(SelectInfo &si)
pre_select() sets up for eventually calling ::select().
void setfd(int fd)
Sets the file descriptor for both reading and writing.
void noerr()
Reset our error state - there's no error condition anymore.
virtual void pre_select(SelectInfo &si)
pre_select() sets up for eventually calling ::select().
A type-safe version of WvMonikerBase that lets you provide create functions for object types other th...
the data structure used by pre_select()/post_select() and internally by select(). ...
virtual void close()
Closes the file descriptors.
bool stop_read
True if noread()/nowrite()/close() have been called, respectively.
Base class for streams built on Unix 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 seterr(int _errnum)
Override seterr() from WvError so that it auto-closes the stream.
virtual bool post_select(SelectInfo &si)
post_select() is called after ::select(), and returns true if this object is now ready.