#ifndef __TEMPFILE_H__ #define __TEMPFILE_H__ #include #include #ifdef _WIN32 #include #endif class TempFile { protected: #ifdef _WIN32 char path[MAX_PATH]; char fname[MAX_PATH]; std::fstream file; #endif public: #ifdef _WIN32 TempFile(const char *prefix = "tmp"){ //GetTempPath(sizeof(path), path); // 一時ディレクトリ GetCurrentDirectory(sizeof(path), path); // カレントディレクトリ GetTempFileName(path, prefix, 0, fname); file.open(fname); } ~TempFile(){ file.close(); remove(fname); } #endif std::string get_fname(){ return std::string(fname); } std::string get_path(){ return std::string(path); } std::fstream &stream(){ return file; } }; #endif /* __TEMPFILE_H__ */