NzFile::NzFile(const NzString& filePath) : m_endianness(nzEndianness_Unknown), m_impl(nullptr), m_openMode(0) { SetFile(filePath); }
BOOL ringFile::CreateTemp(LPCTSTR prefix) { char path[MAX_PATH]; char name[MAX_PATH]; char pfix[4]; // 合成前缀串 if(prefix) { memcpy((void*)pfix,(const void *)prefix, 3); pfix[3] = '\0'; } else wsprintf(pfix,"RFT\0"); // 获得临时文件全路径 GetTempPath(MAX_PATH,path); GetTempFileName((LPCSTR)path,(LPCSTR)pfix,0,(LPSTR)name); if (strlen((char*)name) == 0) return FALSE; // 进行预关联 SetFile((LPCTSTR)name); // 进行实关联 return Create(RF_NEW,FILE_ATTRIBUTE_TEMPORARY); }
CHTTPImageHandler::CHTTPImageHandler(const HTTPRequest &request) : CHTTPFileHandler(request) { std::string file; int responseStatus = MHD_HTTP_BAD_REQUEST; // resolve the URL into a file path and a HTTP response status if (m_request.pathUrl.size() > 7) { file = m_request.pathUrl.substr(7); XFILE::CImageFile imageFile; const CURL pathToUrl(file); if (imageFile.Exists(pathToUrl)) { responseStatus = MHD_HTTP_OK; struct __stat64 statBuffer; if (imageFile.Stat(pathToUrl, &statBuffer) == 0) { SetLastModifiedDate(&statBuffer); SetCanBeCached(true); } } else responseStatus = MHD_HTTP_NOT_FOUND; } // set the file and the HTTP response status SetFile(file, responseStatus); }
void cElCompileFN::MakeFileH(bool SpecFCUV) { SetFile("h",0); (*this) << "class " << mNameClass << ": public cElCompiledFonc\n"; (*this) << "{\n"; (*this) << " public :\n\n"; (*this) << " " << mNameClass << "();\n"; (*this) << " void ComputeVal();\n"; (*this) << " void ComputeValDeriv();\n"; (*this) << " void ComputeValDerivHessian();\n"; (*this) << " double * AdrVarLocFromString(const std::string &);\n"; for (cECFN_SetString::const_iterator it = mNamesLoc->begin(); it!=mNamesLoc->end() ; it++) { (*this) << " void Set"<< it->Name() << "(double);\n"; } (*this) << "\n\n"; (*this) << " static cAutoAddEntry mTheAuto;\n"; (*this) << " static cElCompiledFonc * Alloc();\n"; (*this) << " private :\n\n"; { for (cECFN_SetString::const_iterator it = mNamesLoc->begin(); it!=mNamesLoc->end() ; it++) { (*this) << " double "<<NameVarLoc(it->Name()) <<";\n"; } } (*this) << "};\n"; CloseFile(); }
bool TDocument::AllowClose() { if (IsModified()) { bool save; if (!TCommonDialogs::SaveChanges(fTitle, GetMainWindow(), save)) return false; if (save) { // save the file if (fFile.IsSpecified()) Save(); else { TFile* file = TCommonDialogs::SaveFile(NULL, GetMainWindow()); if (file) { SetFile(file); Save(); delete file; } else return false; } } } return true; }
void ImageResource::UnserializeFrom(const SerializerElement & element) { alwaysLoaded = element.GetBoolAttribute("alwaysLoaded"); smooth = element.GetBoolAttribute("smoothed"); SetUserAdded( element.GetBoolAttribute("userAdded") ); SetFile(element.GetStringAttribute("file")); }
std::unique_ptr<Workspace> JsonImporter::ImportWorkspace(FileManager& fileManager, const filesystem::path& workspaceFile) { auto json = internal::ParseJsonFile(fileManager.GetFileSystem(), workspaceFile); if (internal::IsValidWorkspace(json)) { auto workspace = std::make_unique<Workspace>(); workspace->SetName(json["workspace"]); workspace->SetFile(workspaceFile); auto& projects = json["projects"]; if (projects.is_array()) { auto workspacePath = workspaceFile.parent_path(); for (auto& project : projects) { workspace->AddProject(ImportProject(fileManager, workspacePath / project)); } } return workspace; } return nullptr; }
// be careful.. it can go through recursion. // do not use AssignVar, SetVar.. and so on. // which makes to run this function again. // these functions gets argment with the CVar type... // and calls this function again. CVar::CVar(CVar &var) { value = 0; file = NULL; string = NULL; var_name = NULL; cbr = var.cbr; var_type = var.var_type; SetName(var.var_name); next = var.next; prev = var.prev; switch(var_type) { case INT : case CHAR : SetValue(var.value); break; case STRING : SetString(var.string); break; case File : SetFile(var.file); break; default : sntx_err(INTERNAL_ERROR); } }
std::unique_ptr<Project> JsonImporter::ImportProject(FileManager& fileManager, const filesystem::path& projectFile) { auto json = internal::ParseJsonFile(fileManager.GetFileSystem(), projectFile); if (internal::IsValidProject(json)) { auto project = std::make_unique<Project>(); project->SetName(json["project"]); project->SetFile(projectFile); for (auto& config : json["configs"]) { project->AddConfiguration(internal::ImportConfig(config)); } for (auto& filePath : json["files"]) { project->AddFile(fileManager.GetOrCreateFile(filePath)); } return project; } return nullptr; }
Log::Log(int mode, int level, char *filename, bool append) { m_lastLogTime = 0; m_filename = NULL; m_append = false; hlogfile = NULL; m_todebug = false; m_toconsole = false; m_tofile = false; SetFile(filename, append); SetMode(mode); SetLevel(level); // If the compiler returns full path names in __FILE__, // remember the path prefix, to remove it from the log messages. char *path = __FILE__; char *ptr = strrchr(path, '\\'); if (ptr != NULL) { m_prefix_len = ptr + 1 - path; m_prefix = (char *)malloc(m_prefix_len + 1); memcpy(m_prefix, path, m_prefix_len); m_prefix[m_prefix_len] = '\0'; } }
status_t ArpConfigureFile::SetFile(const char* name) { ArpD(cdb << ADH << "ArpConfigureFile: setting file from path = " << name << endl); BEntry entry(&mFile); if( entry.InitCheck() != B_OK ) return entry.InitCheck(); BPath path; status_t err = entry.GetPath(&path); if( err != B_OK ) return err; ArpD(cdb << ADH << "ArpConfigureFile: orig path = " << path << endl); err = path.InitCheck(); if( err == B_OK ) err = path.GetParent(&path); if( err == B_OK ) err = path.Append(name); ArpD(cdb << ADH << "ArpConfigureFile: renamed path = " << path.Path() << endl); if( err != B_OK ) return err; entry.SetTo(path.Path()); err = entry.InitCheck(); if( err != B_OK ) return err; entry_ref ref; err = entry.GetRef(&ref); if( err != B_OK ) return err; return SetFile(ref); }
RheiaHtmlLogger::RheiaHtmlLogger() : m_window(NULL) { wxString path = RheiaStandardPaths::DataDirectoryUser( ) + wxT("/htmllog.html"); RheiaConfigurationManager* cfg = RheiaManager::Get()->GetConfigurationManager( wxT("RheiaHtmlLogger") ); path = cfg->Read( wxT("/default_file") , path ); SetFile(path); }
NzFile::NzFile(const NzString& filePath, unsigned long openMode) : m_endianness(nzEndianness_Unknown), m_impl(nullptr), m_openMode(0) { SetFile(filePath); Open(openMode); }
CFileLock::CFileLock(const char* p_szFile) { m_nFd = -1; m_szFile = NULL; if (p_szFile) { SetFile(p_szFile); } }
U8NandArchive::U8NandArchive( const char* nandPath ) : U8Archive( NULL, 0 ), fd( -1 ), dataOffset( 0 ) { if( nandPath ) { SetFile( nandPath ); } }
CHTTPWebinterfaceHandler::CHTTPWebinterfaceHandler(const HTTPRequest &request) : CHTTPFileHandler(request) { // resolve the URL into a file path and a HTTP response status std::string file; int responseStatus = ResolveUrl(request.pathUrl, file); // set the file and the HTTP response status SetFile(file, responseStatus); }
extern segment_id BESetSeg( segment_id seg ) { //================================================== segment_id old; Action( "BESetSeg( %d )", seg ); old = SetFile( seg ); Action( " -> %d%n", old ); return( old ); }
U8FileArchive::U8FileArchive( const char* filePath ) : U8Archive( NULL, 0 ), fd( NULL ), dataOffset( 0 ) { if( filePath ) { SetFile( filePath ); } }
status_t ArpConfigureFile::SetFile(const BPath& file) { BEntry entry(file.Path()); status_t err = entry.InitCheck(); if( err != B_OK ) return err; entry_ref ref; err = entry.GetRef(&ref); if( err != B_OK ) return err; return SetFile(ref); }
ColdLog::ColdLog(int mode, int level, LPTSTR filename, bool append) { hlogfile = NULL; m_todebug = false; m_toconsole = false; m_tofile = false; SetMode(mode); if (mode & ToFile) { SetFile(filename, append); } }
Include::Include(af::TElement& B) { Root = B.GetRoot(); if(B.GetName() == "New") { QString s; SetObjectName("Include_" + s.sprintf("%d", Root.Tag())); SetIncludeType(0); SetFile(""); } }
void PageOutput::OnBrowse() { QString filters; for(int i = 0; i < CONTAINER_OTHER; ++i) { if(i != 0) filters += ";;"; filters += m_containers[i].filter; } for(unsigned int i = 0; i < m_containers_av.size(); ++i) { if(!m_containers_av[i].filter.isEmpty()) filters += ";;" + m_containers_av[i].filter; } enum_container container = GetContainer(); unsigned int container_av = GetContainerAV(); QString selected_filter = (container == CONTAINER_OTHER)? m_containers_av[container_av].filter : m_containers[container].filter; QString selected_file = QFileDialog::getSaveFileName(this, tr("Save recording as"), GetFile(), filters, &selected_filter, QFileDialog::DontConfirmOverwrite); if(selected_file.isNull()) return; m_lineedit_file->clear(); QFileInfo fi(selected_file); if(fi.suffix().isEmpty()) { QStringList suffixes = (container == CONTAINER_OTHER)? m_containers_av[container_av].suffixes : m_containers[container].suffixes; if(!suffixes.isEmpty()) selected_file += "." + suffixes[0]; } else { bool found = false; for(int i = 0; i < CONTAINER_OTHER; ++i) { if(m_containers[i].suffixes.contains(fi.suffix(), Qt::CaseInsensitive)) { SetContainer((enum_container) i); found = true; break; } } if(!found) { for(unsigned int i = 0; i < m_containers_av.size(); ++i) { if(m_containers_av[i].suffixes.contains(fi.suffix(), Qt::CaseInsensitive)) { SetContainer(CONTAINER_OTHER); SetContainerAV(i); break; } } } } SetFile(selected_file); OnUpdateContainerFields(); }
void CHttpClient::Reset() { // Are we connected? if (IsConnected()) { // Disconnect Disconnect(); } // Set the status to none m_status = HTTP_STATUS_NONE; SetFile(); }
/** * @brief Constructor * @param [in] szLogName Logfile name (including path). * @param [in] bDeleteExisting Do we delete existing log file with same name? */ CLogFile::CLogFile(LPCTSTR szLogName /*= NULL*/, BOOL bDeleteExisting /*=FALSE*/) : m_nMaxSize(MEGA) , m_bEnabled(FALSE) , m_nDefaultLevel(LMSG) , m_nMaskLevel(LALL) { String path; if (szLogName != NULL) path = szLogName; SetFile(path, bDeleteExisting); m_hLogMutex = CreateMutex(NULL, FALSE, MutexName); }
void CVar::AssignVar(class CVar var) { switch(var_type) { case INT : case CHAR : SetValue(var.value); break; case STRING : SetString(var.string); break; case File : SetFile(var.file); default : sntx_err(INTERNAL_ERROR); } }
void PageOutput::LoadProfileSettings(QSettings* settings) { // choose default container and codecs enum_container default_container = (enum_container) 0; for(unsigned int i = 0; i < VIDEO_CODEC_COUNT; ++i) { if(AVFormatIsInstalled(m_containers[i].avname)) { default_container = (enum_container) i; break; } } enum_video_codec default_video_codec = (enum_video_codec) 0; for(unsigned int i = 0; i < VIDEO_CODEC_COUNT; ++i) { if(AVCodecIsInstalled(m_video_codecs[i].avname) && m_containers[default_container].supported_video_codecs.count((enum_video_codec) i)) { default_video_codec = (enum_video_codec) i; break; } } enum_audio_codec default_audio_codec = (enum_audio_codec) 0; for(unsigned int i = 0; i < AUDIO_CODEC_COUNT; ++i) { if(AVCodecIsInstalled(m_audio_codecs[i].avname) && m_containers[default_container].supported_audio_codecs.count((enum_audio_codec) i)) { default_audio_codec = (enum_audio_codec) i; break; } } // load settings SetFile(settings->value("output/file", "").toString()); SetSeparateFiles(settings->value("output/separate_files", false).toBool()); SetContainer(StringToEnum(settings->value("output/container", QString()).toString(), default_container)); SetContainerAV(FindContainerAV(settings->value("output/container_av", QString()).toString())); SetVideoCodec(StringToEnum(settings->value("output/video_codec", QString()).toString(), default_video_codec)); SetVideoCodecAV(FindVideoCodecAV(settings->value("output/video_codec_av", QString()).toString())); SetVideoKBitRate(settings->value("output/video_kbit_rate", 5000).toUInt()); SetH264CRF(settings->value("output/video_h264_crf", 23).toUInt()); SetH264Preset((enum_h264_preset) settings->value("output/video_h264_preset", H264_PRESET_SUPERFAST).toUInt()); SetVP8CPUUsed(settings->value("output/video_vp8_cpu_used", 5).toUInt()); SetVideoOptions(settings->value("output/video_options", "").toString()); SetVideoAllowFrameSkipping(settings->value("output/video_allow_frame_skipping", true).toBool()); SetAudioCodec(StringToEnum(settings->value("output/audio_codec", QString()).toString(), default_audio_codec)); SetAudioCodecAV(FindAudioCodecAV(settings->value("output/audio_codec_av", QString()).toString())); SetAudioKBitRate(settings->value("output/audio_kbit_rate", 128).toUInt()); SetAudioOptions(settings->value("output/audio_options", "").toString()); // update things OnUpdateContainerFields(); OnUpdateVideoCodecFields(); OnUpdateAudioCodecFields(); }
Log::Log(int mode, int level, LPCTSTR filename, bool append) { m_lastLogTime = 0; hlogfile = INVALID_HANDLE_VALUE; m_todebug = false; m_toconsole = false; m_tofile = false; InitializeCriticalSection( &m_criLock ); SetLevel( level ); SetMode(mode); if( mode&ToFile && filename ) SetFile(filename, append); }
/// Destroys the pipe instance, freeing any resources. CNamedPipe::~CNamedPipe () { #ifndef _WIN32 if (IsServer ()) { int file = GetFile (); if (file) { close (file); SetFile (0); if (unlink (m_pszName)) { LOGWARN (TEXT ("Couldn't delete pipe ") << m_pszName << TEXT (", error ") << GetLastError ()); } else { LOGDEBUG (TEXT ("Deleted pipe ") << m_pszName); } } } #endif delete m_pszName; }
void TDocument::SaveAs(bool makeCopy) { TFile* file = TCommonDialogs::SaveFile(NULL, GetMainWindow()); if (file) { if (! makeCopy) SetFile(file); WriteToFile(file); UpdateFileModification(); if (! makeCopy) SetModified(false); delete file; } }
void Log::ReallyPrint(LPCTSTR format, va_list ap) { SYSTEMTIME current; GetLocalTime(¤t); if (memcmp(&m_lastLogT, ¤t, sizeof(SYSTEMTIME)) != 0) { m_lastLogT = current; TCHAR time_str[50] = {0}; TCHAR date_str[50] = {0}; int nRet = GetDateFormat(LOCALE_USER_DEFAULT, NULL, ¤t, TEXT("dd"), date_str, sizeof(date_str)); nRet = GetTimeFormat(LOCALE_USER_DEFAULT,NULL, ¤t,TEXT("hh:mm:ss"),time_str,sizeof(time_str)); TCHAR time_buf[50]; wsprintf(time_buf, TEXT("<%s %s>:"),date_str, time_str); ReallyPrintLine(time_buf); } // Prepare the complete log message TCHAR line[LINE_BUFFER_SIZE]; memset(line, 0, sizeof(line)); int len = 0; #ifdef _UNICODE _vsnwprintf(line, sizeof(line) - 2 * sizeof(TCHAR), format, ap); len = wcslen(line); #else _vsnprintf(line, sizeof(line) - 2 * sizeof(TCHAR), format, ap); len = strlen(line); #endif // _UNICODE line[LINE_BUFFER_SIZE-2] = (TCHAR)'\0'; #if (!defined(_UNICODE) && !defined(_MBCS)) if (len > 0 && len <= sizeof(line) - 2 * sizeof(TCHAR) && line[len-1] == (TCHAR)'\n') { // Replace trailing '\n' with MS-DOS style end-of-line. line[len-1] = (TCHAR)'\r'; line[len] = (TCHAR)'\n'; line[len+1] = (TCHAR)'\0'; } #endif ReallyPrintLine(line); ReallyPrintLine(TEXT("\r\n")); //if overfollow create new log if (m_tofile) { nTotalLogWrited += len; //max log size = 10m if (nTotalLogWrited > 1024*1024*10) { CloseFile(); CString strNewFile = m_strOrgFileName; SetFile(strNewFile, false); } } }