diff options
author | Mike Buland <eichlan@xagasoft.com> | 2007-06-10 21:28:14 +0000 |
---|---|---|
committer | Mike Buland <eichlan@xagasoft.com> | 2007-06-10 21:28:14 +0000 |
commit | 5f39066a4f561e9a94a6cc9293ab9b978ebf1f81 (patch) | |
tree | a25698caf9594feecae8b71f032a11f81ba6cc3c /src/file.cpp | |
parent | f5352edf3dc23c044a91f1d1537fa0dc0f0babc7 (diff) | |
download | libbu++-5f39066a4f561e9a94a6cc9293ab9b978ebf1f81.tar.gz libbu++-5f39066a4f561e9a94a6cc9293ab9b978ebf1f81.tar.bz2 libbu++-5f39066a4f561e9a94a6cc9293ab9b978ebf1f81.tar.xz libbu++-5f39066a4f561e9a94a6cc9293ab9b978ebf1f81.zip |
Bunch of maintenence type things. Minor tweaks and the like. The file class
has a lot more helper functions and the like, the filters give more info back
to the caller, minor updates to taf.
Diffstat (limited to 'src/file.cpp')
-rw-r--r-- | src/file.cpp | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/src/file.cpp b/src/file.cpp index 26986a5..14b6e54 100644 --- a/src/file.cpp +++ b/src/file.cpp | |||
@@ -1,6 +1,8 @@ | |||
1 | #include "file.h" | 1 | #include "file.h" |
2 | #include "exceptions.h" | 2 | #include "exceptions.h" |
3 | #include <errno.h> | 3 | #include <errno.h> |
4 | #include <sys/types.h> | ||
5 | #include <sys/stat.h> | ||
4 | 6 | ||
5 | Bu::File::File( const char *sName, const char *sFlags ) | 7 | Bu::File::File( const char *sName, const char *sFlags ) |
6 | { | 8 | { |
@@ -11,6 +13,20 @@ Bu::File::File( const char *sName, const char *sFlags ) | |||
11 | } | 13 | } |
12 | } | 14 | } |
13 | 15 | ||
16 | Bu::File::File( const Bu::FString &sName, const char *sFlags ) | ||
17 | { | ||
18 | fh = fopen( sName.getStr(), sFlags ); | ||
19 | if( fh == NULL ) | ||
20 | { | ||
21 | throw Bu::FileException( errno, strerror(errno) ); | ||
22 | } | ||
23 | } | ||
24 | |||
25 | Bu::File::File( int fd, const char *sFlags ) | ||
26 | { | ||
27 | fh = fdopen( fd, sFlags ); | ||
28 | } | ||
29 | |||
14 | Bu::File::~File() | 30 | Bu::File::~File() |
15 | { | 31 | { |
16 | close(); | 32 | close(); |
@@ -108,3 +124,18 @@ void Bu::File::setBlocking( bool bBlocking ) | |||
108 | return; | 124 | return; |
109 | } | 125 | } |
110 | 126 | ||
127 | void Bu::File::truncate( long nSize ) | ||
128 | { | ||
129 | ftruncate( fileno( fh ), nSize ); | ||
130 | } | ||
131 | |||
132 | void Bu::File::flush() | ||
133 | { | ||
134 | fflush( fh ); | ||
135 | } | ||
136 | |||
137 | void Bu::File::chmod( mode_t t ) | ||
138 | { | ||
139 | fchmod( fileno( fh ), t ); | ||
140 | } | ||
141 | |||