18 ex <<
"Cannot change file but operation '" << why <<
"' was called";
19 ex.
addContext(
"LocalCacheFile::" + why +
"()");
25 : image_(base->
size()),
27 storage_(std::
move(base)),
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(0, 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);
tuple start
Check for commandline option errors.
void cache(IOOffset start, IOOffset end)
edm::propagate_const< std::unique_ptr< Storage > > storage_
virtual IOOffset position(void) const
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)
volatile std::atomic< bool > shutdown_flag false
tuple size
Write out results.
static void nowrite(const std::string &why)