void construct(t_index& idx, std::string file, uint8_t num_bytes=0) { tMSS file_map; cache_config config; if (is_ram_file(file)) { config.dir = "@"; } construct(idx, file, config, num_bytes); }
//! Is the stream close? bool is_open() { if (nullptr == m_streambuf) return false; if (is_ram_file(m_file)) { return ((ram_filebuf*)m_streambuf)->is_open(); } else { return ((std::filebuf*)m_streambuf)->is_open(); } }
void add_check_tflx_toram() { if(WT_ISATTACHED(&trdtask)) return; if(is_ram_file(flix.fd)) /* it is in ram already, forget it */ return; init_waitask(&trdtask,trdtask_func,NULL,WT_KILLCURSOR); add_waitask(&trdtask); }
//! Close the stream. void close() { bool fail = false; if (nullptr == m_streambuf) { fail = true; } else { if (is_ram_file(m_file)) { fail = !((ram_filebuf*)m_streambuf)->close(); } else { fail = !((std::filebuf*)m_streambuf)->close(); } } if (fail) this->setstate(std::ios::failbit); }
static int trdtask_func(Waitask *wt) { if(pushed_mask > 0 /* wait till all is popped */ || pushed_alt > 0 || pushed_cel > 0 || pushed_mask > 0 || flix.fd == JNONE /* wait till file is open */ || cgroup_hidden(vb.screen) /* wait till menus are shown */ || zoom_hidden()) /* wait till rezoomed */ { return(0); } if(!is_ram_file(flix.fd)) /* Only if it is no in ram already */ to_trd_maxmem(); return(TRUE); /* done with it */ }
osfstream& seekp(pos_type pos) { ios_base::iostate err = std::ios_base::iostate(std::ios_base::goodbit); try { if (!this->fail()) { pos_type p = 0; if (is_ram_file(m_file)) { p = ((ram_filebuf*)m_streambuf)->pubseekpos(pos, std::ios_base::out); } else { p = ((std::filebuf*)m_streambuf)->pubseekpos(pos, std::ios_base::out); } if (p == pos_type(off_type(-1))) { err |= ios_base::failbit; this->setstate(err); } } } catch (...) { if (err) { this->setstate(err); } } return *this; }
//! Open the stream. buf_ptr_type open(const std::string& file, std::ios_base::openmode mode = std::ios_base::out) { delete m_streambuf; m_streambuf = nullptr; m_file = file; std::streambuf* success = nullptr; if (is_ram_file(file)) { m_streambuf = new ram_filebuf(); success = ((ram_filebuf*)m_streambuf)->open(m_file, mode | std::ios_base::out); } else { m_streambuf = new std::filebuf(); success = ((std::filebuf*)m_streambuf)->open(m_file, mode | std::ios_base::out); } if (success) { this->clear(); } else { this->setstate(std::ios_base::failbit); delete m_streambuf; m_streambuf = nullptr; } this->rdbuf(m_streambuf); return m_streambuf; }
std::streampos tellg() { ios_base::iostate err = std::ios_base::iostate(ios_base::goodbit); pos_type p = pos_type(off_type(-1)); try { if (!this->fail()) { if (is_ram_file(m_file)) { p = ((ram_filebuf*)m_streambuf)->pubseekoff(0, std::ios_base::cur); } else { p = ((std::filebuf*)m_streambuf)->pubseekoff(0, std::ios_base::cur); } if (p == pos_type(off_type(-1))) { err |= ios_base::failbit; } } } catch (...) { if (err) { this->setstate(err); } } return p; }
isfstream& seekg(off_type off, ios_base::seekdir way) { ios_base::iostate err = std::ios_base::iostate(ios_base::goodbit); try { if (!this->fail()) { pos_type p = 0; if (is_ram_file(m_file)) { p = ((ram_filebuf*)m_streambuf)->pubseekoff(off, way, std::ios_base::in); } else { p = ((std::filebuf*)m_streambuf)->pubseekoff(off, way, std::ios_base::in); } if (p == pos_type(off_type(-1))) { err |= ios_base::failbit; } } } catch (...) { if (err) { this->setstate(err); } } return *this; }