diff options
Diffstat (limited to 'src/sfile.cpp')
-rw-r--r-- | src/sfile.cpp | 100 |
1 files changed, 0 insertions, 100 deletions
diff --git a/src/sfile.cpp b/src/sfile.cpp deleted file mode 100644 index 529d8cd..0000000 --- a/src/sfile.cpp +++ /dev/null | |||
@@ -1,100 +0,0 @@ | |||
1 | #include "sfile.h" | ||
2 | #include "exceptions.h" | ||
3 | #include <errno.h> | ||
4 | |||
5 | Bu::SFile::SFile( const char *sName, const char *sFlags ) | ||
6 | { | ||
7 | fh = fopen( sName, sFlags ); | ||
8 | if( fh == NULL ) | ||
9 | { | ||
10 | throw Bu::FileException( errno, strerror(errno) ); | ||
11 | } | ||
12 | } | ||
13 | |||
14 | Bu::SFile::~SFile() | ||
15 | { | ||
16 | close(); | ||
17 | } | ||
18 | |||
19 | void Bu::SFile::close() | ||
20 | { | ||
21 | if( fh ) | ||
22 | { | ||
23 | fclose( fh ); | ||
24 | fh = NULL; | ||
25 | } | ||
26 | } | ||
27 | |||
28 | size_t Bu::SFile::read( void *pBuf, size_t nBytes ) | ||
29 | { | ||
30 | if( !fh ) | ||
31 | throw FileException("File not open."); | ||
32 | |||
33 | int nAmnt = fread( pBuf, 1, nBytes, fh ); | ||
34 | |||
35 | if( nAmnt == 0 ) | ||
36 | throw FileException("End of file."); | ||
37 | |||
38 | return nAmnt; | ||
39 | } | ||
40 | |||
41 | size_t Bu::SFile::write( const void *pBuf, size_t nBytes ) | ||
42 | { | ||
43 | if( !fh ) | ||
44 | throw FileException("File not open."); | ||
45 | |||
46 | return fwrite( pBuf, 1, nBytes, fh ); | ||
47 | } | ||
48 | |||
49 | long Bu::SFile::tell() | ||
50 | { | ||
51 | if( !fh ) | ||
52 | throw FileException("File not open."); | ||
53 | |||
54 | return ftell( fh ); | ||
55 | } | ||
56 | |||
57 | void Bu::SFile::seek( long offset ) | ||
58 | { | ||
59 | if( !fh ) | ||
60 | throw FileException("File not open."); | ||
61 | |||
62 | fseek( fh, offset, SEEK_CUR ); | ||
63 | } | ||
64 | |||
65 | void Bu::SFile::setPos( long pos ) | ||
66 | { | ||
67 | if( !fh ) | ||
68 | throw FileException("File not open."); | ||
69 | |||
70 | fseek( fh, pos, SEEK_SET ); | ||
71 | } | ||
72 | |||
73 | void Bu::SFile::setPosEnd( long pos ) | ||
74 | { | ||
75 | if( !fh ) | ||
76 | throw FileException("File not open."); | ||
77 | |||
78 | fseek( fh, pos, SEEK_END ); | ||
79 | } | ||
80 | |||
81 | bool Bu::SFile::isEOS() | ||
82 | { | ||
83 | return feof( fh ); | ||
84 | } | ||
85 | |||
86 | bool Bu::SFile::canRead() | ||
87 | { | ||
88 | return true; | ||
89 | } | ||
90 | |||
91 | bool Bu::SFile::canWrite() | ||
92 | { | ||
93 | return true; | ||
94 | } | ||
95 | |||
96 | bool Bu::SFile::canSeek() | ||
97 | { | ||
98 | return true; | ||
99 | } | ||
100 | |||