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 #ifndef _QORE_QOREFILE_H
00026
00027 #define _QORE_QOREFILE_H
00028
00029 #include <fcntl.h>
00030
00031 #include <sys/file.h>
00032 #include <unistd.h>
00033
00034 class QoreTermIOS;
00035 class Queue;
00036
00038
00043 class QoreFile {
00044 private:
00046 struct qore_qf_private *priv;
00047
00048 protected:
00050 DLLLOCAL QoreFile(const QoreFile&);
00051
00053 DLLLOCAL QoreFile& operator=(const QoreFile&);
00054
00055 public:
00057 DLLEXPORT QoreFile(const QoreEncoding *cs = QCS_DEFAULT);
00058
00060 DLLEXPORT ~QoreFile();
00061
00063
00072 DLLEXPORT int open(const char *fn, int flags = O_RDONLY, int mode = 0777, const QoreEncoding *cs = QCS_DEFAULT);
00073
00075
00085 DLLEXPORT int open2(ExceptionSink *xsink, const char *fn, int flags = O_RDONLY, int mode = 0777, const QoreEncoding *cs = QCS_DEFAULT);
00086
00088
00091 DLLEXPORT int close();
00092
00094 DLLEXPORT void setEncoding(const QoreEncoding *cs);
00095
00097 DLLEXPORT const QoreEncoding *getEncoding() const;
00098
00100 DLLEXPORT int sync();
00101
00103
00107 DLLEXPORT QoreStringNode *readLine(ExceptionSink *xsink);
00108
00110
00115 DLLEXPORT int write(const QoreString *str, ExceptionSink *xsink);
00116
00118
00123 DLLEXPORT int write(const BinaryNode *b, ExceptionSink *xsink);
00124
00126
00132 DLLEXPORT int write(const void *data, qore_size_t len, ExceptionSink *xsink);
00133
00135
00140 DLLEXPORT int writei1(char i, ExceptionSink *xsink);
00141
00143
00149 DLLEXPORT int writei2(short i, ExceptionSink *xsink);
00150
00152
00158 DLLEXPORT int writei4(int i, ExceptionSink *xsink);
00159
00161
00167 DLLEXPORT int writei8(int64 i, ExceptionSink *xsink);
00168
00170
00176 DLLEXPORT int writei2LSB(short i, ExceptionSink *xsink);
00177
00179
00185 DLLEXPORT int writei4LSB(int i, ExceptionSink *xsink);
00186
00188
00194 DLLEXPORT int writei8LSB(int64 i, ExceptionSink *xsink);
00195
00197
00203 DLLEXPORT int readu1(unsigned char *val, ExceptionSink *xsink);
00204
00206
00214 DLLEXPORT int readu2(unsigned short *val, ExceptionSink *xsink);
00215
00217
00225 DLLEXPORT int readu4(unsigned int *val, ExceptionSink *xsink);
00226
00228
00236 DLLEXPORT int readu2LSB(unsigned short *val, ExceptionSink *xsink);
00237
00239
00247 DLLEXPORT int readu4LSB(unsigned int *val, ExceptionSink *xsink);
00248
00250
00256 DLLEXPORT int readi1(char *val, ExceptionSink *xsink);
00257
00259
00267 DLLEXPORT int readi2(short *val, ExceptionSink *xsink);
00268
00270
00278 DLLEXPORT int readi4(int *val, ExceptionSink *xsink);
00279
00281
00287 DLLEXPORT int readi8(int64 *val, ExceptionSink *xsink);
00288
00290
00298 DLLEXPORT int readi2LSB(short *val, ExceptionSink *xsink);
00299
00301
00309 DLLEXPORT int readi4LSB(int *val, ExceptionSink *xsink);
00310
00312
00318 DLLEXPORT int readi8LSB(int64 *val, ExceptionSink *xsink);
00319
00321
00327 DLLEXPORT QoreStringNode *read(qore_offset_t size, ExceptionSink *xsink);
00328
00330
00335 DLLEXPORT BinaryNode *readBinary(qore_offset_t size, ExceptionSink *xsink);
00336
00338
00345 DLLEXPORT QoreStringNode *read(qore_offset_t size, int timeout_ms, ExceptionSink *xsink);
00346
00348
00354 DLLEXPORT BinaryNode *readBinary(qore_offset_t size, int timeout_ms, ExceptionSink *xsink);
00355
00357
00359 DLLEXPORT qore_size_t setPos(qore_size_t pos);
00360
00362
00364 DLLEXPORT qore_size_t getPos();
00365
00367
00371 DLLEXPORT QoreStringNode *getchar();
00372
00374 DLLEXPORT QoreStringNode *getFileName() const;
00375
00377 DLLEXPORT int chown(uid_t owner, gid_t group, ExceptionSink *xsink);
00378
00380 DLLEXPORT int lockBlocking(struct flock &fl, ExceptionSink *xsink);
00381
00383 DLLEXPORT int lock(const struct flock &fl, ExceptionSink *xsink);
00384
00386 DLLEXPORT int getLockInfo(struct flock &fl, ExceptionSink *xsink);
00387
00389
00393 DLLEXPORT bool isDataAvailable(int timeout_ms, ExceptionSink *xsink) const;
00394
00395 #if 0
00397 DLLEXPORT int preallocate(fstore_t &fs, ExceptionSink *xsink);
00398 #endif
00399
00401 DLLEXPORT int getFD() const;
00402
00404 DLLLOCAL int setTerminalAttributes(int action, QoreTermIOS *ios, ExceptionSink *xsink) const;
00405
00407 DLLLOCAL int getTerminalAttributes(QoreTermIOS *ios, ExceptionSink *xsink) const;
00408
00409
00410 DLLLOCAL void makeSpecial(int sfd);
00411
00413 DLLLOCAL void setEventQueue(Queue *cbq, ExceptionSink *xsink);
00414
00416 DLLLOCAL void cleanup(ExceptionSink *xsink);
00417 };
00418
00419 #endif // _QORE_QOREFILE_H