00001 // $Id: util.h 363 2010-02-22 15:02:45Z mfederico $ 00002 00003 #ifndef IRSTLM_UTIL_H 00004 #define IRSTLM_UTIL_H 00005 00006 #include <string> 00007 #include <fstream> 00008 #include "gzfilebuf.h" 00009 00010 00011 std::string gettempfolder(); 00012 void createtempfile(std::ofstream &fileStream, std::string &filePath, std::ios_base::openmode flags); 00013 void removefile(const std::string &filePath); 00014 00015 class inputfilestream : public std::istream 00016 { 00017 protected: 00018 std::streambuf *m_streambuf; 00019 bool _good; 00020 public: 00021 00022 inputfilestream(const std::string &filePath); 00023 ~inputfilestream(); 00024 bool good(){return _good;} 00025 void close(); 00026 }; 00027 00028 void *MMap(int fd, int access, off_t offset, size_t len, off_t *gap); 00029 int Munmap(void *p,size_t len,int sync); 00030 00031 00032 // A couple of utilities to measure access time 00033 void ResetUserTime(); 00034 void PrintUserTime(const std::string &message); 00035 double GetUserTime(); 00036 00037 00038 #endif 00039
1.5.9