00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026 #ifndef _QORE_QOREFILE_H
00027
00028 #define _QORE_QOREFILE_H
00029
00030 #include <fcntl.h>
00031
00032 #include <sys/file.h>
00033 #include <unistd.h>
00034
00035 class QoreTermIOS;
00036 class Queue;
00037
00039
00044 class QoreFile {
00045 private:
00047 struct qore_qf_private *priv;
00048
00049 protected:
00051 DLLLOCAL QoreFile(const QoreFile&);
00052
00054 DLLLOCAL QoreFile& operator=(const QoreFile&);
00055
00056 public:
00058 DLLEXPORT QoreFile(const QoreEncoding *cs = QCS_DEFAULT);
00059
00061 DLLEXPORT ~QoreFile();
00062
00064
00073 DLLEXPORT int open(const char *fn, int flags = O_RDONLY, int mode = 0777, const QoreEncoding *cs = QCS_DEFAULT);
00074
00076
00086 DLLEXPORT int open2(ExceptionSink *xsink, const char *fn, int flags = O_RDONLY, int mode = 0777, const QoreEncoding *cs = QCS_DEFAULT);
00087
00089
00092 DLLEXPORT int close();
00093
00095 DLLEXPORT void setEncoding(const QoreEncoding *cs);
00096
00098 DLLEXPORT const QoreEncoding *getEncoding() const;
00099
00101 DLLEXPORT int sync();
00102
00104
00108 DLLEXPORT QoreStringNode *readLine(ExceptionSink *xsink);
00109
00111
00116 DLLEXPORT int write(const QoreString *str, ExceptionSink *xsink);
00117
00119
00124 DLLEXPORT int write(const BinaryNode *b, ExceptionSink *xsink);
00125
00127
00133 DLLEXPORT int write(const void *data, qore_size_t len, ExceptionSink *xsink);
00134
00136
00141 DLLEXPORT int writei1(char i, ExceptionSink *xsink);
00142
00144
00150 DLLEXPORT int writei2(short i, ExceptionSink *xsink);
00151
00153
00159 DLLEXPORT int writei4(int i, ExceptionSink *xsink);
00160
00162
00168 DLLEXPORT int writei8(int64 i, ExceptionSink *xsink);
00169
00171
00177 DLLEXPORT int writei2LSB(short i, ExceptionSink *xsink);
00178
00180
00186 DLLEXPORT int writei4LSB(int i, ExceptionSink *xsink);
00187
00189
00195 DLLEXPORT int writei8LSB(int64 i, ExceptionSink *xsink);
00196
00198
00204 DLLEXPORT int readu1(unsigned char *val, ExceptionSink *xsink);
00205
00207
00215 DLLEXPORT int readu2(unsigned short *val, ExceptionSink *xsink);
00216
00218
00226 DLLEXPORT int readu4(unsigned int *val, ExceptionSink *xsink);
00227
00229
00237 DLLEXPORT int readu2LSB(unsigned short *val, ExceptionSink *xsink);
00238
00240
00248 DLLEXPORT int readu4LSB(unsigned int *val, ExceptionSink *xsink);
00249
00251
00257 DLLEXPORT int readi1(char *val, ExceptionSink *xsink);
00258
00260
00268 DLLEXPORT int readi2(short *val, ExceptionSink *xsink);
00269
00271
00279 DLLEXPORT int readi4(int *val, ExceptionSink *xsink);
00280
00282
00288 DLLEXPORT int readi8(int64 *val, ExceptionSink *xsink);
00289
00291
00299 DLLEXPORT int readi2LSB(short *val, ExceptionSink *xsink);
00300
00302
00310 DLLEXPORT int readi4LSB(int *val, ExceptionSink *xsink);
00311
00313
00319 DLLEXPORT int readi8LSB(int64 *val, ExceptionSink *xsink);
00320
00322
00328 DLLEXPORT QoreStringNode *read(qore_offset_t size, ExceptionSink *xsink);
00329
00331
00338 DLLEXPORT int read(QoreString &str, qore_offset_t size, ExceptionSink *xsink);
00339
00341
00346 DLLEXPORT BinaryNode *readBinary(qore_offset_t size, ExceptionSink *xsink);
00347
00349
00355 DLLEXPORT int readBinary(BinaryNode &b, qore_offset_t size, ExceptionSink *xsink);
00356
00358
00365 DLLEXPORT QoreStringNode *read(qore_offset_t size, int timeout_ms, ExceptionSink *xsink);
00366
00368
00374 DLLEXPORT BinaryNode *readBinary(qore_offset_t size, int timeout_ms, ExceptionSink *xsink);
00375
00377
00379 DLLEXPORT qore_size_t setPos(qore_size_t pos);
00380
00382
00384 DLLEXPORT qore_size_t getPos();
00385
00387
00391 DLLEXPORT QoreStringNode *getchar();
00392
00394 DLLEXPORT QoreStringNode *getFileName() const;
00395
00397 DLLEXPORT int chown(uid_t owner, gid_t group, ExceptionSink *xsink);
00398
00400 DLLEXPORT int lockBlocking(struct flock &fl, ExceptionSink *xsink);
00401
00403 DLLEXPORT int lock(const struct flock &fl, ExceptionSink *xsink);
00404
00406 DLLEXPORT int getLockInfo(struct flock &fl, ExceptionSink *xsink);
00407
00409
00413 DLLEXPORT bool isDataAvailable(int timeout_ms, ExceptionSink *xsink) const;
00414
00415 #if 0
00417 DLLEXPORT int preallocate(fstore_t &fs, ExceptionSink *xsink);
00418 #endif
00419
00421 DLLEXPORT int getFD() const;
00422
00424 DLLLOCAL int setTerminalAttributes(int action, QoreTermIOS *ios, ExceptionSink *xsink) const;
00425
00427 DLLLOCAL int getTerminalAttributes(QoreTermIOS *ios, ExceptionSink *xsink) const;
00428
00429
00430 DLLLOCAL void makeSpecial(int sfd);
00431
00433 DLLLOCAL void setEventQueue(Queue *cbq, ExceptionSink *xsink);
00434
00436 DLLLOCAL void cleanup(ExceptionSink *xsink);
00437 };
00438
00439 #endif // _QORE_QOREFILE_H