18 ex <<
"Cannot change file but operation '" << why <<
"' was called";
19 ex.
addContext(
"LocalCacheFile::" + why +
"()");
34 if (
char *
p = std::getenv(
"TMPDIR"))
38 pattern +=
"/cmssw-shadow-XXXXXX";
41 int fd = mkstemp(&
temp[0]);
44 ex <<
"Cannot create temporary file '" <<
pattern <<
"': " << strerror(errno) <<
" (error " << errno <<
")";
45 ex.
addContext(
"LocalCacheFile::LocalCacheFile");
49 file_ = std::make_unique<File>(
fd);
65 void *
window = mmap(
nullptr, len, PROT_READ | PROT_WRITE, MAP_SHARED,
file_->fd(),
start);
66 if (
window == MAP_FAILED) {
68 ex <<
"Unable to map a window of local cache file: " << strerror(errno) <<
" (error " << errno <<
")";
77 std::ostringstream ost;
78 ost <<
"Unable to cache " << len <<
" byte file segment at " <<
start <<
": ";
88 ex <<
"Unable to cache " << len <<
" byte file segment at " <<
start <<
": got only " << nread <<
" bytes back";
110 return file_->read(into,
n);
125 return file_->readv(into,
n);
178 return file_->prefetch(what,
n);
void flush(void) override
IOSize write(const void *from, IOSize n) override
edm::propagate_const< std::unique_ptr< Storage > > storage_
IOSize writev(const IOBuffer *from, IOSize n) override
void cache(IOOffset start, IOOffset end)
virtual IOOffset size() const
edm::propagate_const< std::unique_ptr< File > > file_
def window(xmin, xmax, ymin, ymax, x=0, y=0, width=100, height=100, xlogbase=None, ylogbase=None, minusInfinity=-1000, flipx=False, flipy=True)
bool prefetch(const IOPosBuffer *what, IOSize n) override
void close(void) override
IOSize readv(IOBuffer *into, IOSize n) override
void addContext(std::string const &context)
~LocalCacheFile(void) override
virtual IOOffset position() const
LocalCacheFile(std::unique_ptr< Storage > base, const std::string &tmpdir="")
static constexpr IOOffset CHUNK_SIZE
void resize(IOOffset size) override
std::vector< char > present_
static void nowrite(const std::string &why)