summaryrefslogtreecommitdiff
path: root/src/file.cpp
diff options
context:
space:
mode:
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