48 G_EXCEPTION( Error ,
"cache error" ) ;
50 explicit Cache(
const G::Path & base_dir ,
const std::string & name ,
size_t size ) ;
57 const std::string & commit_path_other = std::string() ,
58 const std::string & same_as = std::string() ) ;
71 void commit(
bool other =
false ) ;
74 std::string
base()
const ;
80 Entry(
int fd_ = -1 ,
const std::string & cache_path_ = std::string() ,
const std::string & commit_path_ = std::string() ) :
82 cache_path(cache_path_) ,
83 commit_path(commit_path_)
87 std::string cache_path ;
88 std::string commit_path ;
89 std::string commit_path_other ;
90 std::string same_as_path ;
95 void operator=(
const Cache & ) ;
96 std::string commitPath(
const std::string & ,
G::EpochTime )
const ;
97 void fail(
const char * where ) ;
98 void open( Entry & e ) ;
100 void commit( Entry & e ,
bool ) ;
101 void close( Entry & e ) ;
102 bool move(
const std::string & src ,
const std::string & dst ) ;
103 void mkdirs(
const G::Path & path ) ;
106 typedef std::vector<Entry> List ;
108 std::string m_prefix ;
A subsecond-resolution timestamp based on a time_t.
Vectors ImageBuffer
An ImageBuffer is used to hold raw image data, typically in more than one chunk.
Cache(const G::Path &base_dir, const std::string &name, size_t size)
Constructor. Paths are like "<base-dir>/.cache/<name>.123".
void store(const Gr::ImageBuffer &, const std::string &commit_path, const std::string &commit_path_other=std::string(), const std::string &same_as=std::string())
Stores an image in the cache.
void commit(bool other=false)
Commits all cached images to their non-cache location.
std::string base() const
Returns the base directory, as passed to the constructor.
A queue of recent images that can be flushed to the filesystem on demand.
A Path object represents a file system path.