diff options
author | Mike Buland <eichlan@xagasoft.com> | 2007-04-03 05:09:12 +0000 |
---|---|---|
committer | Mike Buland <eichlan@xagasoft.com> | 2007-04-03 05:09:12 +0000 |
commit | c884da672645231b5ec47706c886381dab1b391a (patch) | |
tree | f9c0a0c4fb9006c2c1aa10c8c65de2f6e42894de /src/old | |
parent | da89e6d30e57bd6dbb10b4d36b093ce9bbf5c666 (diff) | |
download | libbu++-c884da672645231b5ec47706c886381dab1b391a.tar.gz libbu++-c884da672645231b5ec47706c886381dab1b391a.tar.bz2 libbu++-c884da672645231b5ec47706c886381dab1b391a.tar.xz libbu++-c884da672645231b5ec47706c886381dab1b391a.zip |
The file stream is imported and works, as does our first test, and the new
tweaks to archive. The && operator is now a template function, and as such
requires no special handling. It could be worth it to check this out for other
types, yet dangerous, since it would let you archive anything, even a class,
without writing the proper functions for it...we shall see what happens...
Diffstat (limited to '')
-rw-r--r-- | src/old/sfile.h | 29 | ||||
-rw-r--r-- | src/sfile.cpp (renamed from src/old/sfile.cpp) | 36 |
2 files changed, 26 insertions, 39 deletions
diff --git a/src/old/sfile.h b/src/old/sfile.h deleted file mode 100644 index b51e5bc..0000000 --- a/src/old/sfile.h +++ /dev/null | |||
@@ -1,29 +0,0 @@ | |||
1 | #ifndef SFILE_H | ||
2 | #define SFILE_H | ||
3 | |||
4 | #include <stdint.h> | ||
5 | |||
6 | #include "stream.h" | ||
7 | |||
8 | class SFile : public Stream | ||
9 | { | ||
10 | public: | ||
11 | SFile( const char *sName, const char *sFlags ); | ||
12 | virtual ~SFile(); | ||
13 | |||
14 | virtual void close(); | ||
15 | virtual size_t read( char *pBuf, size_t nBytes ); | ||
16 | virtual size_t write( const char *pBuf, size_t nBytes ); | ||
17 | |||
18 | virtual long tell(); | ||
19 | virtual void seek( long offset ); | ||
20 | virtual void setPos( long pos ); | ||
21 | virtual void setPosEnd( long pos ); | ||
22 | virtual bool isEOS(); | ||
23 | |||
24 | private: | ||
25 | FILE *fh; | ||
26 | |||
27 | }; | ||
28 | |||
29 | #endif | ||
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 | |||