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