18 ex <<
"Cannot change file but operation '" << why <<
"' was called";
19 ex.
addContext(
"LocalCacheFile::" + why +
"()");
25 : image_(base->
size()),
36 if (
char *
p = getenv(
"TMPDIR"))
40 pattern +=
"/cmssw-shadow-XXXXXX";
42 std::vector<char>
temp(pattern.c_str(), pattern.c_str()+pattern.size()+1);
43 int fd = mkstemp(&
temp[0]);
47 ex <<
"Cannot create temporary file '" << pattern <<
"': " 48 << strerror(errno) <<
" (error " << errno <<
")";
49 ex.
addContext(
"LocalCacheFile::LocalCacheFile");
53 file_ = std::make_unique<File>(fd);
75 void *
window = mmap(
nullptr, len, PROT_READ | PROT_WRITE, MAP_SHARED,
file_->fd(),
start);
76 if (window == MAP_FAILED)
79 ex <<
"Unable to map a window of local cache file: " 80 << strerror(errno) <<
" (error " << errno <<
")";
87 nread =
storage_->read(window, len, start);
92 std::ostringstream ost;
93 ost <<
"Unable to cache " << len <<
" byte file segment at " << start <<
": ";
104 ex <<
"Unable to cache " << len <<
" byte file segment at " << start
105 <<
": got only " << nread <<
" bytes back";
128 cache(here, here + n);
130 return file_->read(into, n);
137 return file_->read(into, n, pos);
146 end += into[
i].
size();
149 return file_->readv(into, n);
167 {
nowrite(
"write");
return 0; }
171 {
nowrite(
"write");
return 0; }
175 {
nowrite(
"writev");
return 0; }
179 {
nowrite(
"writev");
return 0; }
183 {
return file_->position(offset, whence); }
213 return file_->prefetch(what, n);
void cache(IOOffset start, IOOffset end)
edm::propagate_const< std::unique_ptr< Storage > > storage_
virtual IOOffset position(void) const
def window(xmin, xmax, ymin, ymax, x=0, y=0, width=100, height=100, xlogbase=None, ylogbase=None, minusInfinity=-1000, flipx=False, flipy=True)
base
Make Sure CMSSW is Setup ##.
virtual IOSize writev(const IOBuffer *from, IOSize n)
static const IOOffset CHUNK_SIZE
std::vector< char > present_
IOOffset offset(void) const
virtual IOSize write(const void *from, IOSize n)
virtual IOOffset size(void) const
LocalCacheFile(std::unique_ptr< Storage > base, const std::string &tmpdir="")
void addContext(std::string const &context)
virtual IOSize readv(IOBuffer *into, IOSize n)
virtual bool prefetch(const IOPosBuffer *what, IOSize n)
edm::propagate_const< std::unique_ptr< File > > file_
virtual void resize(IOOffset size)
static void nowrite(const std::string &why)