summaryrefslogtreecommitdiff
path: root/src/file.cpp
diff options
context:
space:
mode:
authorMike Buland <eichlan@xagasoft.com>2007-06-10 21:28:14 +0000
committerMike Buland <eichlan@xagasoft.com>2007-06-10 21:28:14 +0000
commit5f39066a4f561e9a94a6cc9293ab9b978ebf1f81 (patch)
treea25698caf9594feecae8b71f032a11f81ba6cc3c /src/file.cpp
parentf5352edf3dc23c044a91f1d1537fa0dc0f0babc7 (diff)
downloadlibbu++-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.cpp31
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
5Bu::File::File( const char *sName, const char *sFlags ) 7Bu::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
16Bu::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
25Bu::File::File( int fd, const char *sFlags )
26{
27 fh = fdopen( fd, sFlags );
28}
29
14Bu::File::~File() 30Bu::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
127void Bu::File::truncate( long nSize )
128{
129 ftruncate( fileno( fh ), nSize );
130}
131
132void Bu::File::flush()
133{
134 fflush( fh );
135}
136
137void Bu::File::chmod( mode_t t )
138{
139 fchmod( fileno( fh ), t );
140}
141