static int SubmoduleCallback(git_submodule *sm, const char * /*name*/, void *payload) { auto spayload = (SubmodulePayload *)payload; CString path = CUnicodeUtils::GetUnicode(git_submodule_path(sm)); if (spayload->prefixList.empty()) { CTGitPath subPath(spayload->basePath); subPath.AppendPathString(path); spayload->list.push_back(subPath.GetGitPathString()); SubmodulePayload tpayload(spayload->list, subPath.GetGitPathString()); GetSubmodulePathList(tpayload); } else { for (size_t i = 0; i < spayload->prefixList.size(); ++i) { CString prefix = spayload->prefixList.at(i) + _T("/"); if (path.Left(prefix.GetLength()) == prefix) { CTGitPath subPath(spayload->basePath); subPath.AppendPathString(path); spayload->list.push_back(subPath.GetGitPathString()); SubmodulePayload tpayload(spayload->list, subPath.GetGitPathString()); GetSubmodulePathList(tpayload); } } } return 0; }
void MltRuntime::parse_struct(json_t* v, const JsonPath& curPath, hash_map<string, JsonPath>& uuid_paths, int erase) throw(Exception) { json_t* je = json_object_get(v, "uuid"); if ( je && json_is_string(je) && strlen(json_string_value(je)) ) { string uuid = json_string_value(je); if (!erase) { if ( uuid_paths.find(uuid) != uuid_paths.end()) { throw_error_v(ErrorRuntimeJsonUUIDDup, "uuid dup:%s", uuid.c_str()); } uuid_paths[uuid] = curPath; } else { uuid_paths.erase(string(uuid)); } } void* it = json_object_iter(v); while(it) { const char* k = json_object_iter_key(it); je = json_object_iter_value(it); it = json_object_iter_next(v, it); if ( json_is_object(je) && json_object_size(je) > 0 ) { JsonPath subPath(curPath); subPath.push_back(k); parse_struct(je, subPath, uuid_paths, erase); } else if (json_is_array(je) && json_array_size(je) > 0) { int sz = json_array_size(je); for ( int i=0; i<sz; i++ ) { json_t* ae = json_array_get(je, i); if ( json_is_object(ae) && json_object_size(ae) > 0 ) { JsonPath subPath(curPath); subPath.push_back(k, i); parse_struct(ae, subPath, uuid_paths, erase); } } } } }
ossimRefPtr<ossimXmlNode> ossimXmlNode::addNode(const ossimString& relPath, const ossimString& text) { // // Make a copy to manipulate: // ossimString relXpath (relPath); if (relXpath.empty()) return 0; // // First verify that this is not an absolute path: // if (relXpath[static_cast<std::string::size_type>(0)] == XPATH_DELIM[static_cast<std::string::size_type>(0)]) { ossimNotify(ossimNotifyLevel_WARN) << "WARNING: ossimXmlNode::findChildNodes\n" << "Only relative XPaths can be searched from a node. " << "Returning null list...\n"; return 0; } // // Read the desired tag from the relative xpath // ossimString desiredTag (relXpath); if (relXpath.contains(XPATH_DELIM)) { desiredTag = relXpath.before(XPATH_DELIM); } ossimString subPath (relXpath.after(XPATH_DELIM)); ossimRefPtr<ossimXmlNode> node = findFirstNode(desiredTag); if(!node.valid()) { if(subPath.empty()) { node = addChildNode(desiredTag, text); } else { node = addChildNode(desiredTag, ""); } } if(!subPath.empty()) { return node->addNode(subPath, text); } return node; }
QList<unsigned int> GLC_WorldTo3dxml::instancePath(const GLC_StructOccurence* pOccurence) { QList<unsigned int> path; if (!pOccurence->isOrphan()) { GLC_StructInstance* pInstance= pOccurence->structInstance(); Q_ASSERT(m_InstanceToIdHash.contains(pInstance)); path.prepend(m_InstanceToIdHash.value(pInstance)); QList<unsigned int> subPath(instancePath(pOccurence->parent())); subPath.append(path); path= subPath; } return path; }
void trimSurface() { AcBr::ErrorStatus returnValue = AcBr::eOk; Acad::ErrorStatus acadReturnValue = eOk; // Get the subentity path for a face AcDbFullSubentPath subPath(kNullSubent); acadReturnValue = selectEntity(AcDb::kFaceSubentType, subPath); if (acadReturnValue != eOk) { acutPrintf(ACRX_T("\n Error in getPath: %d"), acadReturnValue); return; } // Make a face entity to access the surface AcBrFace faceEntity; returnValue = faceEntity.set(subPath); if (returnValue != AcBr::eOk) { acutPrintf(ACRX_T("\n Error in AcBrFace::set:")); errorReport(returnValue); return; } // Query the style for trimmed surface dump Adesk::Boolean trimmed = Adesk::kTrue; ACHAR opt[128]; while (Adesk::kTrue) { acutPrintf(ACRX_T("\nSelect Style for Trimmed Surface Dump: ")); acedInitGet(NULL, ACRX_T("Nurb Trimmed")); if (acedGetKword(ACRX_T("Nurb/<Trimmed>: "), opt) == RTCAN) return; // Map the user input to a valid dump style if ((_tcscmp(opt, ACRX_T("Trimmed")) == 0) || (_tcscmp(opt, ACRX_T("")) == 0)) { trimmed = Adesk::kTrue; break; } else if ((_tcscmp(opt, ACRX_T("Nurb")) == 0)) { trimmed = Adesk::kFalse; break; } } (trimmed) ? faceToTrimmedSurface(faceEntity) : faceToNurbSurface(faceEntity); return; }
AcBr::ErrorStatus selectEntityByType(AcBrEntity*& pEnt, AcDb::SubentType& subType) { Acad::ErrorStatus acadReturnValue = Acad::eOk; AcBr::ErrorStatus returnValue = AcBr::eOk; // Query validation level AcBr::ValidationLevel vlevel = validationLevel(); // Query the subentity type subType = subtype(); // Query whether to select a database entity or create a new one Adesk::Boolean context = (subType != AcDb::kNullSubentType) ? Adesk::kFalse : localContext(); if (!context) { // Query the subentity by AutoCAD pick and get the subentity path AcDbFullSubentPath subPath(kNullSubent); acadReturnValue = selectEntity(subType, subPath); if (acadReturnValue != Acad::eOk) { acutPrintf(ACRX_T("\n Error in selectEntity: %d"), acadReturnValue); return (AcBr::ErrorStatus)acadReturnValue; } // Call the appropriate subentity constructor switch (subType) { case AcDb::kNullSubentType: pEnt = new AcBrBrep(); break; case AcDb::kFaceSubentType: pEnt = new AcBrFace(); break; case AcDb::kEdgeSubentType: pEnt = new AcBrEdge(); break; default: acutPrintf(ACRX_T("\n selectEntityByType: unsupported subentity type: %d\n"), subType); returnValue = (AcBr::ErrorStatus)Acad::eWrongSubentityType; return returnValue; } if (pEnt == NULL) { acutPrintf(ACRX_T("\n selectEntityByType: unable to allocate memory\n")); returnValue = (AcBr::ErrorStatus)Acad::eOutOfMemory; return returnValue; } returnValue = pEnt->set(subPath); if (returnValue != AcBr::eOk) { acutPrintf(ACRX_T("\n Error in AcBrEntity::set:")); errorReport(returnValue); return returnValue; } } else { // Create the entity as a local object AcDbEntity* pEntity; acadReturnValue = createEntity(pEntity); if (acadReturnValue != Acad::eOk) { acutPrintf(ACRX_T("\n Error in createEntity: %d"), acadReturnValue); return (AcBr::ErrorStatus)acadReturnValue; } if (pEntity == NULL) { acutPrintf(ACRX_T("\n selectEntityByType: unable to allocate memory\n")); returnValue = (AcBr::ErrorStatus)Acad::eOutOfMemory; return returnValue; } pEnt = new AcBrBrep(); if (pEnt == NULL) { acutPrintf(ACRX_T("\n selectEntityByType: unable to allocate memory\n")); returnValue = (AcBr::ErrorStatus)Acad::eOutOfMemory; return returnValue; } returnValue = ((AcBrBrep*)pEnt)->set((const AcDbEntity&)*pEntity); if (returnValue != AcBr::eOk) { acutPrintf(ACRX_T("\n Error in AcBrEntity::set:")); errorReport(returnValue); return returnValue; } } returnValue = pEnt->setValidationLevel(vlevel); if (returnValue != AcBr::eOk) { acutPrintf(ACRX_T("\n Error in AcBrEntity::setValidationLevel:")); errorReport(returnValue); return returnValue; } return returnValue; }
ParsedPath::operator PathName() const { if (!getCount()) return ""; return subPath(getCount()); }
// Recursive routine to get all subdirs added BOOL CAddListDlg::AddPath(CStringList *pList, LPCTSTR path) { BOOL success=TRUE; // Process any accumulated messages if (!MainFrame()->IsQuitting()) { MSG msg; while (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE)) { if (msg.message == WM_QUIT) // App was just terminated return FALSE; TranslateMessage(&msg); DispatchMessage(&msg); } } // Is path a directory or a file? WIN32_FIND_DATA fileInfo; HANDLE hFile=FindFirstFile(path, &fileInfo); if(hFile == INVALID_HANDLE_VALUE) { success= FALSE; goto ReportErrors; } FindClose(hFile); if( (fileInfo.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) != FILE_ATTRIBUTE_DIRECTORY) { // Its a file, so just add the one file pList->AddHead(path); m_AddFileCount++; // Every m_WarnLimit, check with user to see if we are out of // control. if(m_WarnLimit && (m_AddFileCount%m_WarnLimit) == 0 ) { if(VerifyOKToContinue() != IDYES) { success=FALSE; m_UserTerminated=TRUE; goto ReportErrors; } if (m_WarnLimit < 10) m_WarnLimit = 5000; } } else { // Its a directory, so enumerate its contents CString subPath(path); subPath += _T("\\*.*"); hFile=FindFirstFile(subPath, &fileInfo); if(hFile == INVALID_HANDLE_VALUE) { success= FALSE; goto ReportErrors; } CString fullName; while(1) { if(lstrcmp(fileInfo.cFileName, _T(".")) !=0 && lstrcmp(fileInfo.cFileName, _T("..")) !=0) { fullName=path; fullName += _T("\\"); fullName += fileInfo.cFileName; if( (fileInfo.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) != FILE_ATTRIBUTE_DIRECTORY) { // Add files directly pList->AddHead(fullName); m_AddFileCount++; if( (m_AddFileCount%m_WarnLimit) == 0 && VerifyOKToContinue() != IDYES ) { success=FALSE; m_UserTerminated=TRUE; break; } } else { // Make a recursive call to AddPath for directories if(!AddPath(pList, fullName)) { success=FALSE; break; } } } if( !FindNextFile(hFile, &fileInfo) ) break; } FindClose(hFile); } ReportErrors: if(!success && !m_UserTerminated) { DWORD errNo=GetLastError(); if(errNo != 0) // Avoid showing same message too many times { LPVOID lpMsgBuf; FormatMessage( FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM, NULL, errNo, MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), // Default language (LPTSTR) &lpMsgBuf, 0, NULL ); // Display the string. CString msg = (LPCTSTR)lpMsgBuf; if (errNo == 0x7B) { CString p = path; if (p.ReverseFind(_T(':')) != 1) msg += LoadStringResource(IDS_CANTADDLNKVIAFILEADD); } AfxMessageBox(msg + _T('\n') + path, MB_OK|MB_ICONERROR ); // Free the buffer. LocalFree( lpMsgBuf ); SetLastError(0); } } return success; }
std::vector<FileData> getFileDataFrom(const FS_NAMESPACE::path & inPath, const FS_NAMESPACE::path & outPath, const FS_NAMESPACE::path & parentDir, const bool recurse) { // get all files from directory std::vector<FileData> files; // check for infinite symlinks if (FS_NAMESPACE::is_symlink(inPath)) { // check if the symlink points somewhere in the path. this would recurse if (inPath.string().find(FS_NAMESPACE::canonical(inPath).string()) == 0) { std::cout << "Warning: Path " << inPath << " contains recursive symlink! Skipping." << std::endl; return files; } } // iterate through source directory searching for files const FS_NAMESPACE::directory_iterator dirEnd; for (FS_NAMESPACE::directory_iterator fileIt(inPath); fileIt != dirEnd; ++fileIt) { FS_NAMESPACE::path filePath = (*fileIt).path(); if (!FS_NAMESPACE::is_directory(filePath)) { if (beVerbose) { std::cout << "Found input file " << filePath << std::endl; } // add file to list FileData temp; temp.inPath = filePath; // replace dots in file name with '_' and add a .c/.cpp extension std::string newFileName = filePath.filename().generic_string(); std::replace(newFileName.begin(), newFileName.end(), '.', '_'); if (useC) { newFileName.append(".c"); } else { newFileName.append(".cpp"); } // remove parent directory of file from path for internal name. This could surely be done in a safer way FS_NAMESPACE::path subPath(filePath.generic_string().substr(parentDir.generic_string().size() + 1)); // add a ":/" before the name to mark internal resources (Yes. Hello Qt!) temp.internalName = ":/" + subPath.generic_string(); // add subdir below parent path to name to enable multiple files with the same name std::string subDirString(subPath.remove_filename().generic_string()); if (!subDirString.empty()) { // replace dir separators by underscores std::replace(subDirString.begin(), subDirString.end(), '/', '_'); // add in front of file name newFileName = subDirString + "_" + newFileName; } // build new output file name temp.outPath = outPath / newFileName; if (beVerbose) { std::cout << "Internal name will be \"" << temp.internalName << "\"" << std::endl; std::cout << "Output path is " << temp.outPath << std::endl; } // get file size try { temp.size = static_cast<uint64_t>(FS_NAMESPACE::file_size(filePath)); if (beVerbose) { std::cout << "Size is " << temp.size << " bytes." << std::endl; } } catch (...) { std::cout << "Error: Failed to get size of " << filePath << "!" << std::endl; temp.size = 0; } // add file to list files.push_back(temp); } } // does the user want subdirectories? if (recurse) { // iterate through source directory again searching for directories for (FS_NAMESPACE::directory_iterator dirIt(inPath); dirIt != dirEnd; ++dirIt) { FS_NAMESPACE::path dirPath = (*dirIt).path(); if (FS_NAMESPACE::is_directory(dirPath)) { if (beVerbose) { std::cout << "Found subdirectory " << dirPath << std::endl; } // subdirectory found. recurse. std::vector<FileData> subFiles = getFileDataFrom(dirPath, outPath, parentDir, recurse); // add returned result to file list files.insert(files.end(), subFiles.cbegin(), subFiles.cend()); } } } // return result return files; }
// ------------------------------------------------------------- void Actions::ParseDirectory( LPCTSTR rootPath, LPCTSTR extentionPath ) { // make sure that we do not have too many actions // this is a sign that something is broken // or that we are reading the root directory { myodd::threads::Lock guard(_mutexActions); if (_actions.size() > static_cast<size_t>(::myodd::config::Get(L"paths\\maxcommand", 2048))) { ASSERT(0); // you have reached the limit! // it is pointless to try and add more command. return; } } // make sure that the path that we have is valid. ASSERT( _tcslen( rootPath ) > 0 ); if( _tcslen( rootPath ) == 0 ) { return; } // the end path std::wstring directory = rootPath; // make sure it has a trailing back slash. myodd::files::AddTrailingBackSlash( directory ); // add the extension directory += extentionPath; // add a trailing back slash myodd::files::AddTrailingBackSlash( directory ); // // we could refine the search to // *.bat, *.exe, *.pl // but I am not sure we really need to restrict anything // it is up to the user to ensure that they have auto sPath = directory + L"*.*"; LPTSTR fullPath = NULL; if( !myodd::files::ExpandEnvironment( sPath.c_str(), fullPath ) ) { return; } _tfinddata_t fdata; const auto ffhandle = _tfindfirst( fullPath, &fdata ); if( ffhandle != -1 ) { do { if( _tcscmp(fdata.name, L"." ) == 0 || _tcscmp(fdata.name, L"..") == 0) { continue; } // .svn directories are hidden so we might as well ignore all hidden file. if( (fdata.attrib & _A_HIDDEN) == _A_HIDDEN ) { continue; } if( (fdata.attrib & _A_SUBDIR) == _A_SUBDIR ) { if( IsReservedDir( fdata.name ) ) { continue; } std::wstring subPath( extentionPath ); subPath += fdata.name; myodd::files::AddTrailingBackSlash( subPath ); ParseDirectory( rootPath, subPath.c_str() ); continue; } // ok add this command auto szFullPath( directory); szFullPath += fdata.name; std::wstring szName( fdata.name); szName = myodd::strings::lower(szName ); // if we don't want to show the extension then strip it. if( ::myodd::config::Get( L"commands\\show.extentions", 0 ) == false ) { myodd::files::StripExtension( szName ); } Add( new Action( _application ,szName, szFullPath)); }while( _tfindnext( ffhandle, &fdata ) == 0 ); _findclose( ffhandle ); } delete [] fullPath; }
void countSubents() { AcBr::ErrorStatus returnValue = AcBr::eOk; Acad::ErrorStatus acadReturnValue = eOk; // Get the subentity path for a brep AcDbFullSubentPath subPath(kNullSubent); acadReturnValue = selectEntity(AcDb::kNullSubentType, subPath); if (acadReturnValue != eOk) { acutPrintf(ACRX_T("\n Error in getPath: %d"), acadReturnValue); return; } // Make a brep entity to access the solid AcBrBrep brepEntity; returnValue = ((AcBrEntity*)&brepEntity)->set(subPath); if (returnValue != AcBr::eOk) { acutPrintf(ACRX_T("\n Error in AcBrBrep::set:")); errorReport(returnValue); return; } // count the unique complexes in the brep returnValue = countComplexes(brepEntity); if (returnValue != AcBr::eOk) { acutPrintf(ACRX_T("\n Error in countComplexes:")); errorReport(returnValue); return; } // count the unique shells in the brep returnValue = countShells(brepEntity); if (returnValue != AcBr::eOk) { acutPrintf(ACRX_T("\n Error in countShells:")); errorReport(returnValue); return; } // count the unique faces in the brep returnValue = countFaces(brepEntity); if (returnValue != AcBr::eOk) { acutPrintf(ACRX_T("\n Error in countFaces:")); errorReport(returnValue); return; } // count the unique edges in the brep returnValue = countEdges(brepEntity); if (returnValue != AcBr::eOk) { acutPrintf(ACRX_T("\n Error in countEdges:")); errorReport(returnValue); return; } // count the unique vertices in the brep returnValue = countVertices(brepEntity); if (returnValue != AcBr::eOk) { acutPrintf(ACRX_T("\n Error in countVertices:")); errorReport(returnValue); return; } return; }
void Builder::run() { VLM_LatestError = BUILDER_NO_ERROR; //InterfaceArchiver * archives =new InterfaceArchiver(); QString MCL_CurrentFilePath = ""; int count; QFile VXL_UpdateListFile(VCM_OutputFilePath); QFileInfo VXL_UpdateListFileInfo; QDir VXL_UpdateListDir; //On vérirife l'existence du dossier VXL_UpdateListFileInfo.setFile(VXL_UpdateListFile); VXL_UpdateListDir = VXL_UpdateListFileInfo.absoluteDir(); if(!VXL_UpdateListDir.exists()) { VXL_UpdateListDir.mkpath(VXL_UpdateListFileInfo.absolutePath()); } else { //On vérifie la présence du fichier if(VXL_UpdateListFile.exists()) { //On le supprime VXL_UpdateListFile.remove(); } } //On ouvre le fichier if (!VXL_UpdateListFile.open(QIODevice::WriteOnly | QIODevice::Text)) { emit NotifyErrorMsg("Unable to open UpdateList File"); VLM_LatestError = BUILDER_ERROR_CANT_OPEN_FILE; return; } //On créé le buffer pour insèrer du texte QTextStream VXL_OutTextStream(&VXL_UpdateListFile); count = OMM_ListFilesToTreate.size(); VXL_OutTextStream << "[files]" <<"\n" << "fcount=" << count << "\n"; for(int i=0; i<OMM_ListFilesToTreate.size();i++) { MCL_CurrentFilePath = OMM_ListFilesToTreate[i]->getPath() + "/" + OMM_ListFilesToTreate[i]->getFilename().section('/', -1); qDebug() << MCL_CurrentFilePath; //On calcul le hash du fichier OMM_ListFilesToTreate[i]->setSha1(CalcSha1(MCL_CurrentFilePath)); //Si demandé, on affiche le fichier en cours de traitement #ifdef ENABLE_DEBUG_SHOWLISTS #ifdef QT_DEBUG qDebug() << "File :" << i+1 << "/" <<OMM_ListFilesToTreate.size() << OMM_ListFilesToTreate[i]->getFilename() << "|" << OMM_ListFilesToTreate[i]->getpriority() << "|" << OMM_ListFilesToTreate[i]->getPath() << "|" << OMM_ListFilesToTreate[i]->getSha1() ; #endif //QT_DEBUG #endif //ENABLE_DEBUG_SHOWLISTS //On écris la ligne qui le concerne if(QString::compare(MCL_CurrentFilePath, VCM_ReferenceFilePath) == 0) {//Fichier de référence } else {//Fichier "normal" count++; VXL_OutTextStream << "F"<<i<<"=" << OMM_ListFilesToTreate[i]->getFilename() << "|" << OMM_ListFilesToTreate[i]->getSha1() << "|" << OMM_ListFilesToTreate[i]->getpriority() << "\n"; } /***********TODO****************/ QString fileToCopy(OMM_ListFilesToTreate[i]->getPath() + "/" + OMM_ListFilesToTreate[i]->getFilename().section('/', -1)); QString subPath(OMM_ListFilesToTreate[i]->getFilename().section('/', 0, -2)); VXL_UpdateListDir.mkpath(subPath); QFile::copy(fileToCopy, VCM_ReferenceFilePath+OMM_ListFilesToTreate[i]->getFilename()); // QFile::copy(OMM_ListFilesToTreate[i]->getFilename(),OMM_ListFilesToTreate[i]->getFilename()); // On Maj la ProgressBar emit NotifyProgress(i+1,OMM_ListFilesToTreate.size()); } return; }