BOOL __stdcall ImportDXFFile(const TCHAR* lpszFileName, Painter* painter, Layers* layers, Blocks* blocks) { layers->clearLayers(); blocks->clear(); Draw_Dxf* creationClass = CreateDraw_Dxf(painter,layers,blocks); DL_Dxf* dxf = CreateDL_Dxf(); #ifdef UNICODE char str[MAX_PATH]; WideCharToMultiByte(CP_ACP,0,(TCHAR*)lpszFileName,-1,str,MAX_PATH,NULL,NULL); std::string strFileName(str); #else std::string strFileName(lpszFileName); #endif if (!dxf->in(strFileName.c_str(), creationClass)) { // if file open failed DestroyDL_Dxf(dxf); DestroyDraw_Dxf(creationClass); return false; } blocks->regen(); layers->regen(); DestroyDL_Dxf(dxf); DestroyDraw_Dxf(creationClass); return true; }
_MEMBER_FUNCTION_IMPL(db, constructor) { const char * filename; script_getstring(pVM, -1, &filename); if(filename) { CSQLite * pSQLite = new CSQLite(); String strFileName(filename); SharedUtility::RemoveIllegalCharacters(strFileName); String strPath(SharedUtility::GetAbsolutePath("files/%s", strFileName.Get())); pSQLite->open(strPath); if(script_setinstance(pVM, pSQLite, &_CLASS_DECL(db)) == 0) { return 1; } else { CLogFile::Print("Failed to set the database instance."); SAFE_DELETE(pSQLite); } } script_pushnull(pVM); return 1; }
bool FrmReports::parseXMLFile(const QString itemName, QString& strName, QString& strAuthor, QString& strPixmap, QString& strDescription) { QString strFileName(qApp->translate("dir", strReportsDir) + tr("\\") + itemName + tr(".bdrt")); QFile file(strFileName); if (!file.exists()) return false; if (!file.open(QFile::ReadOnly | QFile::Text)) return false; //Just try to parse the xml QXmlSimpleReader xmlReader; QXmlInputSource *source = new QXmlInputSource(&file); if (!xmlReader.parse(source)) { file.close(); //exit, but close the file first! return false; } delete source; file.close(); //Initialize the reader if (!file.open(QFile::ReadOnly | QFile::Text)) return false; QXmlStreamReader xml(&file); if (!readProperties(xml, strName, strAuthor, strPixmap, strDescription)) return false; file.close(); return true; }
MStatus AlembicProfileBeginCommand::doIt(const MArgList& args) { MStatus status = MS::kSuccess; #ifdef ESS_PROFILING MArgParser argData(syntax(), args, &status); if(!argData.isFlagSet("fileNameArg")) { // TODO: display dialog MGlobal::displayError("[ExocortexAlembic] No fileName specified."); return status; } // get the filename arg MString fileName = argData.flagArgumentString("fileNameArg",0); std::string strFileName( fileName.asChar() ); if( nameToProfiler.find( strFileName ) == nameToProfiler.end() ) { boost::shared_ptr<Profiler> profiler( new Profiler( strFileName.c_str() ) ); nameToProfiler.insert( std::pair<std::string, boost::shared_ptr<Profiler>>( strFileName, profiler ) ); } else { nameToProfiler[ strFileName]->resume(); } #endif return status; }
void CGlobal::LoadBitmaps() { DeleteBitmaps(); CString strFileName(_T("")); CString sModulePath = GetModulePath() + _T("\\"); for(UINT i=0; i<IDX_BMP_MAX; i++) { strFileName = GetBitmapFileName(i); if( strFileName.IsEmpty() ) continue; strFileName = sModulePath + strFileName; m_infoBitmap[i].hBitmap = (HBITMAP)::LoadImage(::AfxGetInstanceHandle(), (LPCTSTR)strFileName, IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE|LR_CREATEDIBSECTION|LR_DEFAULTSIZE); ::GetObject(m_infoBitmap[i].hBitmap, sizeof(BITMAP), &m_infoBitmap[i].bitmap); } }
MStatus AlembicProfileEndCommand::doIt(const MArgList& args) { MStatus status = MS::kSuccess; #ifdef ESS_PROFILING MArgParser argData(syntax(), args, &status); if(!argData.isFlagSet("fileNameArg")) { // TODO: display dialog MGlobal::displayError("[ExocortexAlembic] No fileName specified."); return status; } // get the filename arg MString fileName = argData.flagArgumentString("fileNameArg",0); std::string strFileName( fileName.asChar() ); if( nameToProfiler.find( strFileName ) != nameToProfiler.end() ) { nameToProfiler[ strFileName ]->stop(); } #endif return status; }
_MEMBER_FUNCTION_IMPL(xml, constructor) { const char * filename; script_getstring(pVM, -1, &filename); if(filename) { CXML * pXML = new CXML(); String strFileName(filename); SharedUtility::RemoveIllegalCharacters(strFileName); String strPath(SharedUtility::GetAbsolutePath("files/%s", strFileName.Get())); pXML->load(strPath); if(!pXML || script_setinstance(pVM, pXML, &_CLASS_DECL(xml)) != 0 ) { CLogFile::Print("Failed to load the xml."); SAFE_DELETE(pXML); script_pushnull(pVM); return 1; } //_SET_RELEASE_HOOK(xml); //script_pushbool(pVM, true); return 1; } script_pushnull(pVM); return 1; }
/** @brief Serialization Test */ TEST(Serialization, SerializableMembers) { // filename std::string strFileName("Bus_Stop.text"); // create class instance const Bus_Stop bs1(GPS_Position(35, 59, 24.567f), GPS_Position(12, 53, 24.657f)); // save data to archive { // create and open a character archive for output std::ofstream ofs(strFileName); boost::archive::text_oarchive oa(ofs); // write class instance to archive oa << bs1; // archive and stream closed when destructors are called } // load data from archive Bus_Stop bs2; { // create and open a character archive for input std::ifstream ifs(strFileName); boost::archive::text_iarchive ia(ifs); // read class state from archive ia >> bs2; // archive and stream closed when destructors are called } EXPECT_EQ(bs1, bs2); }
//╪стьм╪ф╛ bool CPngImageEx::LoadImage(CWnd* pWnd, LPCTSTR pszFileName) { //WIN 7 ж╢пп if ( CD2DEngine::GetD2DEngine() ) { m_pWnd = pWnd; CD2DEngine::GetD2DEngine()->LaodImage(pWnd, pszFileName, m_strImageName); return true; } //╪стьеп╤о ASSERT(m_pImage==NULL); if (m_pImage!=NULL) return false; //╪стьнд╪Ч CT2CW strFileName(pszFileName); m_pImage=Image::FromFile((LPCWSTR)strFileName); //╢МнСеп╤о if ((m_pImage==NULL)||(m_pImage->GetLastStatus()!=Ok)) { DestroyImage(); return false; } return true; }
bool Win32DllLoader::Load() { if (m_dllHandle != NULL) return true; std::string strFileName(GetFileName()); std::string strDll; strDll = CSpecialProtocol::TranslatePath(strFileName); m_dllHandle = LoadLibraryExA(strDll.c_str(), NULL, LOAD_WITH_ALTERED_SEARCH_PATH); if (!m_dllHandle) { DWORD dw = GetLastError(); char* lpMsgBuf = NULL; DWORD strLen = FormatMessageA(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS, NULL, dw, MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US), (LPSTR)&lpMsgBuf, 0, NULL); if (strLen == 0) strLen = FormatMessageA(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS, NULL, dw, MAKELANGID(LANG_NEUTRAL, SUBLANG_NEUTRAL), (LPSTR)&lpMsgBuf, 0, NULL); if (strLen != 0) { LOGERR("Failed to load \"%s\" with error %lu: \"%s\"", strFileName.c_str(), dw, lpMsgBuf); } else LOGERR("Failed to load \"%s\" with error %lu", strFileName.c_str(), dw); LocalFree(lpMsgBuf); return false; } return true; }
QIcon CFlowChartSymbolPikcer::IconForSymbol( const QString &_fn ) { QString strFileName( ":/images/" ); strFileName += _fn.toLower(); strFileName += ".png"; strFileName.replace( " ", "-" ); return QIcon( strFileName ); }
bool DevAssetManager::Check_Source_Asset_File_Name_Is_Ok( const char* fileName ) const { CHK_VRET_FALSE_IF_NIL(fileName); String strFileName( fileName ); String strFilePath; strFileName.ExtractFilePath( strFilePath ); CHK_VRET_FALSE_IF_NOT( strFilePath.IsEmpty() ); return true; }
bool DrawingDocument::OnCreate(const wxString& path, long flags) { #ifndef WIN32 wxFileName strFileName(path); wxString strName = strFileName.GetFullName(); wxString strPathName = strFileName.GetFullPath(); SetTitle(strName); SetFilename(strPathName); #endif return wxDocument::OnCreate(path, flags); }
const char * CHashModuleNatives::md5File(const char * szFileName) { char * result = new char[33]; MD5 md5bytes; CMD5Hasher hasher; String strFileName(szFileName); SharedUtility::RemoveIllegalCharacters(strFileName); String strFilePath(SharedUtility::GetAbsolutePath("files/%s", strFileName.Get())); hasher.Calculate(strFilePath.Get(), md5bytes); hasher.ConvertToHex(md5bytes, result); return result; }
void CRegisterExport::ShellExportRegister(LPCTSTR lpExportStr,LPCTSTR lpExportFile) { CString strItem(lpExportStr); CString strFileName(lpExportFile); CString strFilePath; CString strParameters; int nIndex = 0; strParameters = _T("/e \"") + strFileName + _T("\" \"") + strItem + _T("\""); ShellExecute(0, _T("open"), _T("regedit.exe"), strParameters, NULL , SW_SHOWNORMAL); }
void CMedalCfgMgr::LoadConfigFromFile() { std::string strFileName( g_sPath ); strFileName.append( MEDAL_FILE_NAME ); CFileStream file; file.open( strFileName.c_str(), "rb" ); LoadMedalConfigFromFile( file ); LoadProgressConfigFromFile( file ); file.close(); }
bool CGdiPlusImage::Save(LPCTSTR pszFileName,LPCTSTR format) { //╪стьнд╪Ч CT2CW strFileName(pszFileName); //м╪оЯ╠ё╢Ф CLSID Clsid; GetEncoderClsid(format, &Clsid); if( m_pImage->Save((LPCWSTR)strFileName, &Clsid) == Ok ) return true; return false; }
bool CGdiPlusImage::Save(LPCTSTR pszFileName,LPCTSTR format) { //¼ÓÔØÎļþ CT2CW strFileName(pszFileName); //ͼÏñ±£´æ CLSID Clsid; GetEncoderClsid(format, &Clsid); if( m_pImage->Save((LPCWSTR)strFileName, &Clsid) == Ok ) return true; return false; }
BOOL CLogFactory::CreateLogName(BSTR AppName, BSTR Configue, BSTR Section, LONG FileType, CString &strLogName) { CString strError; CString strAppPath(AppName); CString strFileName(Configue); CString strSection(Section); if (!IsFileExisted(strAppPath)) { strError.Format(_T("AppName:%s is not existed. CLogFactory::CreateLogName return FALSE."), strAppPath); LOGGER_WRITE(strError.GetBuffer()); LogEvent(strError); return FALSE; } strError.Format(_T("AppName:%s"), strAppPath); LOGGER_WRITE(strError.GetBuffer()); int iIndex = strAppPath.ReverseFind(_T('\\')); ATLASSERT(-1 != iIndex); strAppPath = strAppPath.Left(iIndex + 1); CParameter Parameter; CConfigReader Reader; Reader.Read(strAppPath, strFileName, strSection, FileType, Parameter); CHAR Buffer[MAX_PATH] = { 0 }; #pragma warning(push) #pragma warning(disable: 4996) strcat(Buffer, Parameter.m_cFixFolder); strcat(Buffer, Parameter.m_cCycleFolder); strcat(Buffer, Parameter.m_cCycleName); strcat(Buffer, Parameter.m_cCreateTime); strcat(Buffer, Parameter.m_cSaveTime); strcat(Buffer, Parameter.m_cExeName); #pragma warning(pop) strLogName = CString(Buffer); strLogName.Remove(_T('\\')); strLogName.Remove(_T(':')); strLogName.Remove(_T('.')); strLogName.Remove(_T(' ')); LOGGER_WRITE2(_T("LogName:") << strLogName.GetBuffer() << _T(" FileType:") << FileType); return TRUE; }
wstring GetSetting( const wchar_t* file, wchar_t* strName, wchar_t* strDefault, wchar_t* dst_path ) { int dwRet; wstring strRet; wstring strFileName(dst_path); wchar_t buf[1024]; wstring ini_file(file); strFileName += ini_file; dwRet = GetPrivateProfileStringW(L"Setting", strName, strDefault, buf, sizeof(buf), strFileName.c_str()); strRet = buf; return strRet; }
bool CAnonyTest::RegistScript(){ string strFileName("anony.bin"); int nFee = basetest.GetRandomFee(); int nCurHight; basetest.GetBlockHeight(nCurHight); string regAddr=""; if(!SelectOneAccount(regAddr)) return false; //reg anony app Value regscript = basetest.RegisterAppTx(regAddr, strFileName, nCurHight, nFee+20*COIN); if(basetest.GetHashFromCreatedTx(regscript, strTxHash)){ return true; } return false; }
SQInteger CHashNatives::md5File(SQVM * pVM) { const char * szFileName; char result[33]; MD5 md5bytes; CMD5Hasher hasher; sq_getstring(pVM, -1, &szFileName); String strFileName(szFileName); SharedUtility::RemoveIllegalCharacters(strFileName); String strFilePath(SharedUtility::GetAbsolutePath("files/%s", strFileName.Get())); hasher.Calculate(strFilePath.Get(), md5bytes); hasher.ConvertToHex(md5bytes, result); sq_pushstring(pVM, result, 32); return 1; }
void CBasicLog::EndTrial() { if(!m_bStarted) return; std::string strFileName(GetStringParameter(SP_USER_LOC)); strFileName.append("dasher_basic.log"); std::ofstream oFile; oFile.open(strFileName.c_str(), ios::out | ios::app); oFile << "\"" << m_strStartDate << "\":\"" << GetDateStamp() << "\":" << m_iSymbolCount << ":" << m_dBits << ":" << m_iKeyCount << ":" << m_iInitialRate / 100.0 << ":" << GetLongParameter(LP_MAX_BITRATE) / 100.0 << ":\"" << GetStringParameter(SP_INPUT_FILTER) << "\":\"" << GetStringParameter(SP_ALPHABET_ID) << "\"" << std::endl; oFile.close(); m_bStarted = false; }
void CBatchTextDlg::OnBnStartClicked() { if (m_VarTbl.empty()) { return; } //处理文件内容模式 CString str; m_ctrlPattern.GetWindowText(str); CStringW strContent(str); m_ContPat.clear(); ParsePattern(strContent, m_ContPat); //处理文件名模式 m_ctrlFileName.GetWindowText(str); CStringW strFileName(str); m_FilePat.clear(); ParsePattern(strFileName, m_FilePat); //处理目标文件夹 CString strFolder; m_ctrlFolder.GetWindowText(strFolder); if (FALSE == PathFileExists(strFolder)) { CreateDirectory(strFolder, NULL); } if (strFolder[strFolder.GetLength() - 1] != _T('\\')) { strFolder.AppendChar(_T('\\')); } if (m_FilePat.size() == 1) { CString strPathName = strFolder + m_FilePat.front(); DeleteFile(strPathName); } //开始生成 for (STRTABLE::iterator i = m_VarTbl.begin(); i != m_VarTbl.end(); ++i) { GenTextFromPat(m_ContPat, *i, strContent); GenTextFromPat(m_FilePat, *i, strFileName); CString strPathName = strFolder + CString(strFileName); SaveTextFile(strPathName, strContent); } }
CString CGeneralSettingsDlg::BrowseAndGetSingleFile(CString strInitialPath,CString strFilter) { CString strFileName(TEXT("")); CFileDialog filedlg(TRUE,NULL,NULL, OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT,strFilter); TCHAR pBuffer[MAX_PATH]; memset(pBuffer,0,sizeof(TCHAR)*(MAX_PATH)); swprintf(pBuffer,nof(pBuffer),(LPCTSTR)strInitialPath); filedlg.m_ofn.lpstrFile = pBuffer; filedlg.m_ofn.nMaxFile = MAX_PATH; if( IDOK == filedlg.DoModal() ) { POSITION pos = filedlg.GetStartPosition(); while (pos != NULL) { strFileName = filedlg.GetNextPathName(pos); } } return strFileName; }
cocos2d::CCNode* CCSSceneReader::createNodeWithSceneFile(const char* pszFileName) { unsigned long size = 0; const char* pData = 0; cocos2d::CCNode *pNode = NULL; do { CC_BREAK_IF(pszFileName == NULL); std::string strFileName(pszFileName); pData = (char*)(cocos2d::CCFileUtils::sharedFileUtils()->getFileData(pszFileName, "r", &size)); CC_BREAK_IF(pData == NULL || strcmp(pData, "") == 0); cs::CSJsonDictionary *jsonDict = new cs::CSJsonDictionary(); jsonDict->initWithDescription(pData); pNode = createObject(jsonDict,NULL); CC_SAFE_DELETE(jsonDict); } while (0); return pNode; }
//¼ÓÔØͼƬ bool CGdiPlusImage::LoadImage(LPCTSTR pszFileName) { // ¼ÓÔØÅÐ¶Ï ASSERT(m_pImage == NULL); if (m_pImage != NULL) return false; // ¼ÓÔØÎļþ CT2CW strFileName(pszFileName); m_pImage = Image::FromFile((LPCWSTR)strFileName); // ´íÎóÅÐ¶Ï if ((m_pImage==NULL)||(m_pImage->GetLastStatus()!=Ok)) { DestroyImage(); return false; } return true; }
//╪стьм╪ф╛ bool CGdiPlusImage::LoadImage(LPCTSTR pszFileName) { //╪стьеп╤о ASSERT(m_pImage==NULL); if (m_pImage!=NULL) return false; //╪стьнд╪Ч CT2CW strFileName(pszFileName); m_pImage=Image::FromFile((LPCWSTR)strFileName); //╢МнСеп╤о if ((m_pImage==NULL)||(m_pImage->GetLastStatus()!=Ok)) { DestroyImage(); return false; } return true; }
Model* ModelFactory::createObjModelFromTemp(const char* filename) { if(filename == NULL) { LOG_ERROR("filename is NULL\n"); return nullptr; } Model *pModel = new Model; bool success = false; string strFileName(filename); ObjLoader objLoader; success = objLoader.loadFromTemp(pModel, strFileName); if(success) return pModel; delete pModel; return nullptr; }
//Remove local client folder void CFileServer::RemoveDestFolder() { try { CDestFolderHelper folderHelper; folderHelper.SetDestFolder(m_strReceivePath); if (folderHelper.IsDestFolderExist()) { if (m_IsDestFolderPreviouslyExisted == false) { int nCount; BasicFileInfoList* pList = folderHelper.GetFileListInDestFolder(&nCount); if (pList == NULL) { ::RemoveDirectory(m_strReceivePath); } else { while (pList != NULL) { BasicFileInfoList* pNext = pList->pNext; CString strFullFileName(m_strReceivePath); CString strFileName(pList->fileInfo.FileName); strFullFileName += "\\" + strFileName; DeleteFile(strFullFileName); delete pList; pList = pNext; } ::RemoveDirectory(m_strReceivePath); } } } } catch(...) { if (gl_pLogger) gl_pLogger->log_info("CFileServer::RemoveDestFolder() unkown exception."); } }