bug fixes
This commit is contained in:
parent
2e6bd7253f
commit
0995ce7e31
4 changed files with 27 additions and 4 deletions
|
|
@ -25,15 +25,19 @@ namespace fc {
|
||||||
class ifstream : virtual public istream {
|
class ifstream : virtual public istream {
|
||||||
public:
|
public:
|
||||||
enum mode { in, binary };
|
enum mode { in, binary };
|
||||||
|
enum seekdir { beg, cur, end };
|
||||||
|
|
||||||
ifstream();
|
ifstream();
|
||||||
ifstream( const fc::path& file, int m );
|
ifstream( const fc::path& file, int m );
|
||||||
~ifstream();
|
~ifstream();
|
||||||
|
|
||||||
void open( const fc::path& file, int m );
|
void open( const fc::path& file, int m );
|
||||||
size_t readsome( char* buf, size_t len );
|
size_t readsome( char* buf, size_t len );
|
||||||
ifstream& read( char* buf, size_t len );
|
ifstream& read( char* buf, size_t len );
|
||||||
void close();
|
ifstream& seekg( size_t p, seekdir d = beg );
|
||||||
bool eof()const;
|
void get( char& c ) { read( &c, 1 ); }
|
||||||
|
void close();
|
||||||
|
bool eof()const;
|
||||||
private:
|
private:
|
||||||
class impl;
|
class impl;
|
||||||
fc::shared_ptr<impl> my;
|
fc::shared_ptr<impl> my;
|
||||||
|
|
|
||||||
|
|
@ -61,6 +61,9 @@ namespace fc {
|
||||||
uint32_t _hash[5];
|
uint32_t _hash[5];
|
||||||
};
|
};
|
||||||
|
|
||||||
|
class value;
|
||||||
|
void pack( fc::value& , const fc::sha1& );
|
||||||
|
void unpack( const fc::value& , fc::sha1& );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -55,6 +55,13 @@ namespace fc {
|
||||||
my->ifs.read(buf,len);
|
my->ifs.read(buf,len);
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
ifstream& ifstream::seekg( size_t p, seekdir d ) {
|
||||||
|
switch( d ) {
|
||||||
|
case beg: my->ifs.seekg( p, std::ios_base::beg ); return *this;
|
||||||
|
case cur: my->ifs.seekg( p, std::ios_base::cur ); return *this;
|
||||||
|
case end: my->ifs.seekg( p, std::ios_base::end ); return *this;
|
||||||
|
}
|
||||||
|
}
|
||||||
void ifstream::close() { return my->ifs.close(); }
|
void ifstream::close() { return my->ifs.close(); }
|
||||||
|
|
||||||
bool ifstream::eof()const { return my->ifs.eof(); }
|
bool ifstream::eof()const { return my->ifs.eof(); }
|
||||||
|
|
|
||||||
|
|
@ -5,6 +5,8 @@
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <fc/filesystem.hpp>
|
#include <fc/filesystem.hpp>
|
||||||
#include <fc/interprocess/file_mapping.hpp>
|
#include <fc/interprocess/file_mapping.hpp>
|
||||||
|
#include <fc/value.hpp>
|
||||||
|
#include <fc/value_cast.hpp>
|
||||||
|
|
||||||
namespace fc {
|
namespace fc {
|
||||||
|
|
||||||
|
|
@ -93,5 +95,12 @@ namespace fc {
|
||||||
return memcmp( h1._hash, h2._hash, sizeof(h1._hash) ) == 0;
|
return memcmp( h1._hash, h2._hash, sizeof(h1._hash) ) == 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void pack( fc::value& v, const fc::sha1& s ) {
|
||||||
|
v = fc::string(s);
|
||||||
|
}
|
||||||
|
void unpack( const fc::value& v, fc::sha1& s ) {
|
||||||
|
s = sha1(fc::value_cast<fc::string>(v));
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace fc
|
} // namespace fc
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue