void copy(const char *src, const char *dst) { std::cout << "copying " << src << " to " << dst << std::endl; Mmap<char> mmap; CHECK_DIE(mmap.open(src)) << mmap.what(); std::ofstream ofs(dst, std::ios::binary|std::ios::out); CHECK_DIE(ofs) << "permission denied: " << dst; ofs.write(reinterpret_cast<char*>(mmap.begin()), mmap.size()); ofs.close(); }
void auditFunc(boost::system::system_error const &err) { if (debugAudit.enabled()) { LogDebug << "AuditTimer::auditFunc() thread" << boost::this_thread::get_id(); } else { LogSpam << "auditFunc() " << getpid(); } if (mm_) { int64_t nMap = 0, nUnmap = 0, nOpen = 0, nClose = 0; mm_->counters(&nMap, &nUnmap, &nOpen, &nClose); mmOpens.value(nOpen); mmCloses.value(nClose); mmMaps.value(nMap); mmUnmaps.value(nUnmap); } for (size_t i = 0, n = retentionCounters.size(); i != n; ++i) { RetentionCounters *rc = retentionCounters[i]; int64_t v = rc->ri_->stats.nHits.stat_; istat::atomic_add(&rc->ri_->stats.nHits.stat_, -v); rc->pHits_.value(v); v = rc->ri_->stats.nMisses.stat_; istat::atomic_add(&rc->ri_->stats.nMisses.stat_, -v); rc->pMisses_.value(v); } scheduleNext(); }
//--------------------------------- int main(){ ifstream in("abc.txt"); vector<string> abc; // abc.reserve(1100); Mmap nums; int n=0; for(string s; getline(in,s); ){ istringstream sin(s); int num=0; for(string t; sin>>t; num++); if(num){ nums.insert(Mmap::value_type(num, n++)); abc.push_back(s); } } for(Mmap::iterator it=nums.begin(); it!=nums.end(); ++it) cout<<abc[it->second]<<endl; getchar(); }//=================================
int64_t availableSpace(char const *path) { ++available_; return mm_->availableSpace(path); }
bool flush(void const *ptr, size_t size, bool immediate) { ++flush_; return mm_->flush(ptr, size, immediate); }
bool unmap(void const *ptr, size_t size) { ++unmap_; return mm_->unmap(ptr, size); }
void *map(int fd, int64_t offset, size_t size, bool writable) { ++map_; lastOffsetMapped_ = offset; return mm_->map(fd, offset, size, writable); }
int truncate(int fd, ssize_t size) { ++truncate_; return mm_->truncate(fd, size); }
ssize_t tell(int fd) { ++tell_; return mm_->tell(fd); }
ptrdiff_t seek(int fd, ptrdiff_t offset, int whence) { ++seek_; return mm_->seek(fd, offset, whence); }
ssize_t write(int fd, void *ptr, ssize_t amt) { ++write_; return mm_->write(fd, ptr, amt); }
ssize_t read(int fd, void *ptr, ssize_t amt) { ++read_; return mm_->read(fd, ptr, amt); }
int close(int fd) { ++close_; return mm_->close(fd); }
int open(char const *name, int flags) { ++open_; return mm_->open(name, flags); }