diff options
author | Sascha Volkenandt <sascha (at) akv-soft (dot) de> | 2007-05-30 20:26:14 +0000 |
---|---|---|
committer | Sascha Volkenandt <sascha (at) akv-soft (dot) de> | 2007-05-30 20:26:14 +0000 |
commit | 2bff302c8a8eb6768313df248b06e7f725a4ae87 (patch) | |
tree | 580511702ea74ed4a9e2689be804104746eb7caa /filecache.cpp | |
parent | 1043c52409de2c44e5707177ee9dc1977126ca67 (diff) | |
download | vdr-plugin-live-2bff302c8a8eb6768313df248b06e7f725a4ae87.tar.gz vdr-plugin-live-2bff302c8a8eb6768313df248b06e7f725a4ae87.tar.bz2 |
- new files
Diffstat (limited to 'filecache.cpp')
-rw-r--r-- | filecache.cpp | 57 |
1 files changed, 57 insertions, 0 deletions
diff --git a/filecache.cpp b/filecache.cpp new file mode 100644 index 0000000..a5912d0 --- /dev/null +++ b/filecache.cpp @@ -0,0 +1,57 @@ +#include <algorithm> +#include <fstream> +#include <istream> +#include "filecache.h" + +namespace vdrlive { + +std::time_t FileObject::get_filetime( std::string const& path ) +{ + return 9999; +} + +bool FileObject::is_current() const +{ + return m_ctime < get_filetime( m_path ); + /*struct stat statBuf = { 0 }; + * if ( ::stat( m_path.c_str(), &statBuf ) < 0 ) { + * } + if ( m_ctime == 0 ) + return true; + m_ctime = get_filetime( m_path ); + return timestamp < m_ctime;*/ +} + +bool FileObject::load() +{ + std::ifstream ifs( m_path.c_str(), std::ios::in | std::ios::binary | std::ios::ate ); + if ( !ifs ) + return false; + + std::streamsize size = ifs.tellg(); + ifs.seekg( 0, std::ios::beg ); + + std::vector< char > data( size ); + data.resize( size ); + ifs.read( &data[0], size ); + ifs.close(); + + m_ctime = get_filetime( m_path ); + m_data.swap( data ); + return true; +} + +FileCache& LiveFileCache() +{ + static FileCache instance( 1000000 ); + return instance; +} + +} // namespace vdrlive + +using namespace vdrlive; + +int main() +{ + FileCache::ptr_type f = LiveFileCache().get("/tmp/live/active.png"); +} |