hi,
I'm looking for an open source library similar to picostorage, who can recommend a few?
I've been using picostorage,but recently i found that the File is very easy to damage. so i want to look for an open source library.
If the file is damaged,I can not get the data and I do not know the file has been damaged.
These two functions is my functions to manipulate files.
My operating system is window7.
static void __store_data_of( IN ps::Dir &rootdir, IN std::string const &key, IN std::string const &data )
{
if ( key == "" )
{
return;
}
ps::File file = rootdir.openFile( key.c_str() );
if ( !file )
{
file = rootdir.createFile( key.c_str() );
if ( !file )
{
thrd_core_dump_tm( __FUNCTION__", faile to createFile\n");
return;
}
}
file.setSize( data.size() );
file.pwrite( data.c_str(), data.size(), 0 );
file.commit();
}
static bool __fetch_data_of( IN ps::Dir &rootdir, IN std::string const &key, OUT std::string &data )
{
if ( key == "" )
{
return false;
}
ps::File file = rootdir.openFile( key.c_str() );
if ( !file || !file.getSize() )
{
return false;
}
size_t len = (size_t)file.getSize();
char *_data = (char*)malloc( len + 1);
LOKI_ON_BLOCK_EXIT( &::free, _data );
memset( _data, 0, len + 1 );
file.pread( _data, len, 0 );
data = std::string( _data, len );
return true;
}