summaryrefslogtreecommitdiff
path: root/src/stable/file.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/stable/file.h')
-rw-r--r--src/stable/file.h158
1 files changed, 79 insertions, 79 deletions
diff --git a/src/stable/file.h b/src/stable/file.h
index eaf2974..2ecb27e 100644
--- a/src/stable/file.h
+++ b/src/stable/file.h
@@ -17,90 +17,90 @@
17 17
18namespace Bu 18namespace Bu
19{ 19{
20 subExceptionDecl( FileException ); 20 subExceptionDecl( FileException );
21 21
22 /** 22 /**
23 * A file stream. 23 * A file stream.
24 *@ingroup Streams 24 *@ingroup Streams
25 */ 25 */
26 class File : public Bu::Stream 26 class File : public Bu::Stream
27 { 27 {
28 public: 28 public:
29 File( const Bu::String &sName, int iFlags ); 29 File( const Bu::String &sName, int iFlags );
30 File( int fd ); 30 File( int fd );
31 virtual ~File(); 31 virtual ~File();
32 32
33 virtual void close(); 33 virtual void close();
34 virtual Bu::size read( void *pBuf, Bu::size nBytes ); 34 virtual Bu::size read( void *pBuf, Bu::size nBytes );
35 virtual Bu::size write( const void *pBuf, Bu::size nBytes ); 35 virtual Bu::size write( const void *pBuf, Bu::size nBytes );
36 using Stream::write; 36 using Stream::write;
37 37
38 virtual Bu::size tell(); 38 virtual Bu::size tell();
39 virtual void seek( Bu::size offset ); 39 virtual void seek( Bu::size offset );
40 virtual void setPos( Bu::size pos ); 40 virtual void setPos( Bu::size pos );
41 virtual void setPosEnd( Bu::size pos ); 41 virtual void setPosEnd( Bu::size pos );
42 virtual bool isEos(); 42 virtual bool isEos();
43 virtual bool isOpen(); 43 virtual bool isOpen();
44 44
45 virtual void flush(); 45 virtual void flush();
46 46
47 virtual bool canRead(); 47 virtual bool canRead();
48 virtual bool canWrite(); 48 virtual bool canWrite();
49 49
50 virtual bool isReadable(); 50 virtual bool isReadable();
51 virtual bool isWritable(); 51 virtual bool isWritable();
52 virtual bool isSeekable(); 52 virtual bool isSeekable();
53 53
54 virtual bool isBlocking(); 54 virtual bool isBlocking();
55 virtual void setBlocking( bool bBlocking=true ); 55 virtual void setBlocking( bool bBlocking=true );
56 56
57 enum { 57 enum {
58 // Flags 58 // Flags
59 Read = 0x01, ///< Open file for reading 59 Read = 0x01, ///< Open file for reading
60 Write = 0x02, ///< Open file for writing 60 Write = 0x02, ///< Open file for writing
61 Create = 0x04, ///< Create file if it doesn't exist 61 Create = 0x04, ///< Create file if it doesn't exist
62 Truncate = 0x08, ///< Truncate file if it does exist 62 Truncate = 0x08, ///< Truncate file if it does exist
63 Append = 0x10, ///< Always append on every write 63 Append = 0x10, ///< Always append on every write
64 NonBlock = 0x20, ///< Open file in non-blocking mode 64 NonBlock = 0x20, ///< Open file in non-blocking mode
65 Exclusive = 0x44, ///< Create file, if it exists then fail 65 Exclusive = 0x44, ///< Create file, if it exists then fail
66 66
67 // Helpful mixes 67 // Helpful mixes
68 ReadWrite = 0x03, ///< Open for reading and writing 68 ReadWrite = 0x03, ///< Open for reading and writing
69 WriteNew = 0x0E ///< Create a file (or truncate) for writing. 69 WriteNew = 0x0E ///< Create a file (or truncate) for writing.
70 /// Same as Write|Create|Truncate 70 /// Same as Write|Create|Truncate
71 }; 71 };
72 72
73 virtual void setSize( Bu::size iSize ); 73 virtual void setSize( Bu::size iSize );
74 74
75 virtual size getSize() const; 75 virtual size getSize() const;
76 virtual size getBlockSize() const; 76 virtual size getBlockSize() const;
77 virtual Bu::String getLocation() const; 77 virtual Bu::String getLocation() const;
78 78
79 /** 79 /**
80 * Create a temp file and return its handle. The file is opened 80 * Create a temp file and return its handle. The file is opened
81 * Read/Write. 81 * Read/Write.
82 *@param sName (Bu::String) Give in the form: "/tmp/tmpfileXXXXXXXX" 82 *@param sName (Bu::String) Give in the form: "/tmp/tmpfileXXXXXXXX"
83 * It will alter your (sName) setting the 'X's to random 83 * It will alter your (sName) setting the 'X's to random
84 * characters. 84 * characters.
85 *@returns (Bu::File) A file object representing your temp file. 85 *@returns (Bu::File) A file object representing your temp file.
86 */ 86 */
87 static Bu::File tempFile( Bu::String &sName ); 87 static Bu::File tempFile( Bu::String &sName );
88 88
89#ifndef WIN32 89#ifndef WIN32
90 /** 90 /**
91 * Change the file access permissions. 91 * Change the file access permissions.
92 *@param t (mode_t) The new file access permissions. 92 *@param t (mode_t) The new file access permissions.
93 */ 93 */
94 void chmod( mode_t t ); 94 void chmod( mode_t t );
95#endif 95#endif
96 96
97 private: 97 private:
98 int getPosixFlags( int iFlags ); 98 int getPosixFlags( int iFlags );
99 99
100 private: 100 private:
101 int fd; 101 int fd;
102 bool bEos; 102 bool bEos;
103 }; 103 };
104} 104}
105 105
106#endif 106#endif