void plPythonMgr::LoadPythonFiles() { plFileName clientPath = plMaxConfig::GetClientPath(false, true); if (clientPath.IsValid()) { plFileName oldCwd = plFileSystem::GetCWD(); plFileSystem::SetCWD(clientPath); // Get the path to the Python subdirectory of the client plFileName pythonPath = plFileName::Join(clientPath, "Python"); PythonInterface::initPython(); // Iterate through all the Python files in the folder std::vector<plFileName> pys = plFileSystem::ListDir(pythonPath, "*.py"); for (auto iter = pys.begin(); iter != pys.end(); ++iter) { // Get the filename without the ".py" (module name) ST::string fileName = iter->GetFileNameNoExt(); IQueryPythonFile(fileName.c_str()); } PythonInterface::finiPython(); plFileSystem::SetCWD(oldCwd); } }
// static plString plNetLinkingMgr::GetProperAgeName( const plString & ageName ) { plNetClientMgr * nc = plNetClientMgr::GetInstance(); std::vector<plFileName> files = plFileSystem::ListDir("dat", "*.age"); for (auto iter = files.begin(); iter != files.end(); ++iter) { plString work = iter->GetFileNameNoExt(); if (ageName.CompareI(work) == 0) return work; } return ageName; }
bool ExtractExeDllIcon(LPCTSTR strExeFile,LPCTSTR strSaveDir,bool bExtractLarge = false ,UINT iIndexICon = 0) { HICON hIconArry[1]={0}; UINT iSuccessCount = 0; if (bExtractLarge) iSuccessCount = ExtractIconEx(strExeFile,iIndexICon,hIconArry,NULL,1); else iSuccessCount = ExtractIconEx(strExeFile,iIndexICon,NULL,hIconArry,1); if (iSuccessCount!=1) { ZTools::WriteZToolsFormatLog("从文件【%s】中获取索引为【%d】的图标失败!",strExeFile,iIndexICon); return false; } string strName = GetFileNameNoExt(strExeFile); string strPngFile = string(strSaveDir) + "\\" + strName + ".png"; string strIconFile = string(strSaveDir) + "\\" + strName + ".ico"; BOOL bok1 = SavePngFile(hIconArry[0],strPngFile.c_str()); if (!bok1) { ZTools::WriteZToolsFormatLog("保存png文件【%s】失败!",strPngFile.c_str()); } BOOL bok2 = SaveIcon(hIconArry[0],strIconFile.c_str(),32); if (!bok2) { ZTools::WriteZToolsFormatLog("保存icon文件【%s】失败!",strIconFile.c_str()); } DestroyIcon(hIconArry[0]); if (bok1 && bok2) return true; return false; }
void JobDeployment::Execute( PackageProfile *profile ) { // make sure the section we are interested in, exists const XMLNode *chunk = profile->GetChunk( "Deployment" ); if ( chunk == NULL ) { std::cout << "[Error] 'Deployment' section is missing in project profile!" << std::endl; return; } // needed vars dtUtil::FileUtils &fileUtils = dtUtil::FileUtils::GetInstance(); // cache working directory const std::string &cwd = fileUtils.CurrentDirectory(); // output std::cout << "Deploying specified files." << std::endl; // check if output directory exists, if not then create it std::string outputDir = profile->GetOutputDirectory(); if ( !fileUtils.DirExists( outputDir ) ) { std::cout << "[Warning] Output directory does not exist, creating it now." << std::endl; MakeDirectoryEX( outputDir ); } // get all deployment input directory elements std::vector<const XMLNode*> inputElements; profile->GetDeploymentInputDirectoryElements( inputElements ); //loop through each input element and copy files from it to output directory for ( unsigned int i=0; i<inputElements.size(); i++) { //retrieve input directory string, resolving all environment variables const XMLNode *inputElement = inputElements[i]; std::string inputDir = ResolveEnvironmentVariables(profile->GetElementAttribute(inputElement, "location")); //change to directory we are copying files from if ( inputDir.length() == 0 || !fileUtils.DirExists( inputDir ) ) { std::cout << "[Error] Input directory '" << inputDir << "' does not exist." << std::endl; continue; } fileUtils.ChangeDirectory( inputDir ); // get all the files we need to deploy std::vector<std::string> fileNames; std::vector<Options> fileOptions; profile->GetDeploymentContents(inputElement, fileNames, fileOptions); // traverse list of files for ( unsigned int i=0; i<fileNames.size(); i++ ) { // gather file information std::string subpath = GetFilePath( fileNames[i] ); std::string file = GetFileName( fileNames[i] ); std::string fileName = GetFileNameNoExt( fileNames[i] ); std::string fileExt = GetFileExtension( fileNames[i] ); std::string srcDir = inputDir; std::string destDir = outputDir; // file is located in a relative subdirectory if(!subpath.empty()) { srcDir = RelativeToAbsolutePath( subpath, inputDir ); destDir = RelativeToAbsolutePath( subpath, outputDir ); // make sure this relative input directory actually exists if ( !fileUtils.DirExists( srcDir ) ) { std::cout << "[Warning] Directory '" << srcDir << "' does not exist." << std::endl; continue; } // create new destination directory if necessary MakeDirectoryEX( destDir ); } // copy everything! if ( file == "*.*" ) { std::string whatToIgnore = fileOptions[i].Get( std::string("ignore") ); copyAllFiles( srcDir, destDir, whatToIgnore ); } // copy all files of a certain extension else if ( fileName == "*" ) { dtUtil::DirectoryContents files = fileUtils.DirGetFiles( srcDir ); for( dtUtil::DirectoryContents::const_iterator itr = files.begin(); itr!=files.end(); ++itr ) { if ( GetFileExtension( itr->c_str() ) == fileExt ) { try { std::string absFile = RelativeToAbsolutePath( itr->c_str(), srcDir ); fileUtils.FileCopy( absFile, destDir, true ); } catch ( dtUtil::Exception &e ) { e.Print(); } } } } // copy a single file else { try { std::string absFile = RelativeToAbsolutePath( file, srcDir ); fileUtils.FileCopy( absFile, destDir, true ); } catch ( dtUtil::Exception &e ) { e.Print(); } } // sign any JAR files if ( fileExt == "jar" || fileExt == "JAR" ) { if ( fileOptions[i].Get( "sign" ) == "true" ) { std::string absFile = RelativeToAbsolutePath( file, destDir ); std::string cmdString; // used for signing JAR files std::string keystore = profile->GetKeystoreFile(); std::string key = profile->GetKeystoreKey(); std::string password = profile->GetKeystorePassword(); if ( !IsAbsolutePath( keystore ) ) { keystore = RelativeToAbsolutePath( keystore, cwd ); } // sign the JAR file // example: jarsigner -J"-Xmx256m" -keystore C:/SomeDirectory/netc.keystore bleh.jar myKey std::cout << "Signing " << fileNames[i] << std::endl; cmdString = "jarsigner -storepass "; cmdString += password; cmdString += " -J\"-Xmx256m\" -keystore "; cmdString += "\"" + keystore + "\""; cmdString += " "; cmdString += "\"" + absFile + "\""; cmdString += " " + key; system( cmdString.c_str() ); } } } } // restore working directory fileUtils.ChangeDirectory( cwd ); // confirmation std::cout << "Deployment files copied." << std::endl; }