void log_to_file(const std::string &log_msg){ boost::mutex::scoped_lock lock(_mutex); if (_file_lock == NULL){ const std::string log_path = (get_temp_path() / "uhd.log").string(); _file_stream.open(log_path.c_str(), std::fstream::out | std::fstream::app); _file_lock = new ip::file_lock(log_path.c_str()); } _file_lock->lock(); _file_stream << log_msg << std::flush; _file_lock->unlock(); }
TempDir::TempDir(const string& appName) { for (int i=(std::rand()%0xffff); ; ++i) { m_path = join_path(get_temp_path(), appName + convert_to<string>(i)); if (!directory_exists(m_path)) { make_directory(m_path); break; } } }
file::file( const std::string &_pathfile, sorting_type defaults ) : is_temp_name( _pathfile.size() ? false : true ), pathfile( _pathfile.size() ? _pathfile : std::tmpnam(0) ), sorting(defaults) { if( is_temp_name ) { pathfile = get_temp_path() + pathfile; } // metadata here // ie, committed_by, date_created, last_open, last_access, vertex_info, bitrate, etc // valid prefixes: // b_ = bool // d_ = double // s_ = std::string // z_ = size_t }
TempFile::TempFile() { Buffer<wchar_t> buf(MAX_PATH); wstring temp_path = get_temp_path(); CHECK_SYS(GetTempFileNameW(temp_path.c_str(), L"", 0, buf.data())); path.assign(buf.data()); }