这篇教程C++ splitPath函数代码示例写得很实用,希望能帮到您。
本文整理汇总了C++中splitPath函数的典型用法代码示例。如果您正苦于以下问题:C++ splitPath函数的具体用法?C++ splitPath怎么用?C++ splitPath使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。 在下文中一共展示了splitPath函数的27个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。 示例1: splitPathbool ResourceManagerImpl::searchUpwards( std::string const &base, std::string const &subpath, std::string &dest ){ bool exists = false; // TODO debug g_message("............"); std::vector<std::string> parts = splitPath(subpath); std::vector<std::string> baseParts = splitPath(base); while ( !exists && !baseParts.empty() ) { std::vector<std::string> current; current.insert(current.begin(), parts.begin(), parts.end()); // TODO debug g_message(" ---{%s}", Glib::build_filename( baseParts ).c_str()); while ( !exists && !current.empty() ) { std::vector<std::string> combined; combined.insert( combined.end(), baseParts.begin(), baseParts.end() ); combined.insert( combined.end(), current.begin(), current.end() ); std::string filepath = Glib::build_filename( combined ); exists = Glib::file_test(filepath, Glib::FILE_TEST_EXISTS); // TODO debug g_message(" ...[%s] %s", filepath.c_str(), (exists ? "XXX" : "")); if ( exists ) { dest = filepath; } current.erase( current.begin() ); } baseParts.pop_back(); } return exists;}
开发者ID:panjh,项目名称:inkscape,代码行数:29,
示例2: bigWigCorrelateListvoid bigWigCorrelateList(char *listFile)/* Correlate all files in list to each other */{char **fileNames = NULL;int fileCount = 0;char *buf = NULL;readAllWords(listFile, &fileNames, &fileCount, &buf);int i;for (i=0; i<fileCount; ++i) { char *aPath = fileNames[i]; char aName[FILENAME_LEN]; if (rootNames) splitPath(aPath, NULL, aName, NULL); else safef(aName, sizeof(aName), "%s", aPath); int j; for (j=i+1; j<fileCount; ++j) { char *bPath = fileNames[j]; char bName[FILENAME_LEN]; if (rootNames) splitPath(bPath, NULL, bName, NULL); else safef(bName, sizeof(bName), "%s", bPath); struct correlate *c = bigWigCorrelate(aPath, bPath); printf("%s/t%s/t%g/n", aName, bName, correlateResult(c)); correlateFree(&c); } }}
开发者ID:ucsc-mus-strain-cactus,项目名称:kent,代码行数:31,
示例3: convertPathToRelativestatic std::string convertPathToRelative( std::string const &path, std::string const &docbase ){ std::string result = path; if ( !path.empty() && Glib::path_is_absolute(path) ) { // Whack the parts into pieces std::vector<std::string> parts = splitPath(path); std::vector<std::string> baseParts = splitPath(docbase); // TODO debug g_message("+++++++++++++++++++++++++"); for ( std::vector<std::string>::iterator it = parts.begin(); it != parts.end(); ++it ) { // TODO debug g_message(" [%s]", it->c_str()); } // TODO debug g_message(" - - - - - - - - - - - - - - - "); for ( std::vector<std::string>::iterator it = baseParts.begin(); it != baseParts.end(); ++it ) { // TODO debug g_message(" [%s]", it->c_str()); } // TODO debug g_message("+++++++++++++++++++++++++"); if ( !parts.empty() && !baseParts.empty() && (parts[0] == baseParts[0]) ) { // Both paths have the same root. We can proceed. while ( !parts.empty() && !baseParts.empty() && (parts[0] == baseParts[0]) ) { parts.erase( parts.begin() ); baseParts.erase( baseParts.begin() ); } // TODO debug g_message("+++++++++++++++++++++++++"); for ( std::vector<std::string>::iterator it = parts.begin(); it != parts.end(); ++it ) { // TODO debug g_message(" [%s]", it->c_str()); } // TODO debug g_message(" - - - - - - - - - - - - - - - "); for ( std::vector<std::string>::iterator it = baseParts.begin(); it != baseParts.end(); ++it ) { // TODO debug g_message(" [%s]", it->c_str()); } // TODO debug g_message("+++++++++++++++++++++++++"); if ( !parts.empty() ) { result.clear(); for ( size_t i = 0; i < baseParts.size(); ++i ) { parts.insert(parts.begin(), ".."); } result = Glib::build_filename( parts ); // TODO debug g_message("----> [%s]", result.c_str()); } } } return result;}
开发者ID:panjh,项目名称:inkscape,代码行数:51,
示例4: loadPslTablevoid loadPslTable(char *database, struct sqlConnection *conn, char *pslFile)/* load one psl table */{char table[128];char *tabFile;boolean indirectLoad = FALSE;verbose(1, "Processing %s/n", pslFile);/* determine table name to use */if (clTableName != NULL) safef(table, sizeof(table), "%s", clTableName);else { if (endsWith(pslFile, ".gz")) { char *stripGz; stripGz = cloneString(pslFile); chopSuffix(stripGz); splitPath(stripGz, NULL, table, NULL); freeMem(stripGz); } else splitPath(pslFile, NULL, table, NULL); }setupTable(database, conn, table);/* if a bin column is being added or if the input file is * compressed, we must copy to an intermediate tab file */indirectLoad = ((pslCreateOpts & PSL_WITH_BIN) != 0) || endsWith(pslFile, ".gz") || !noSort;if (indirectLoad) { tabFile = "psl.tab"; if (pslCreateOpts & PSL_XA_FORMAT) copyPslXaToTab(pslFile, tabFile); else copyPslToTab(pslFile, tabFile); }else tabFile = pslFile;sqlLoadTabFile(conn, tabFile, table, pslLoadOpts);if (!noHistory) hgHistoryComment(conn, "Add psl alignments to %s table", table);if (indirectLoad && !keep) unlink(tabFile);}
开发者ID:Nicholas-NVS,项目名称:kentUtils,代码行数:51,
示例5: makeCvoid makeC(struct dtdElement *elList, char *fileName, char *incName)/* Produce C code file. */{FILE *f = mustOpen(fileName, "w");struct dtdElement *el;char incFile[128], incExt[64];splitPath(incName, NULL, incFile, incExt);fprintf(f, "/* %s.c %s *//n", prefix, fileComment);fprintf(f, "/n");fprintf(f, "#include /"common.h/"/n");fprintf(f, "#include /"xap.h/"/n");fprintf(f, "#include /"%s%s/"/n", incFile, incExt);fprintf(f, "/n");fprintf(f, "/n");for (el = elList; el != NULL; el = el->next) { freeFunctionPrototype(el, f, ""); freeFunctionBody(el, f); freeListFunctionPrototype(el, f, ""); freeListFunctionBody(el, f); saveFunctionPrototype(el, f, ""); saveFunctionBody(el, f); loadFunctionPrototype(el, f, ""); loadFunctionBody(el, f); loadNextFunctionPrototype(el, f, ""); loadNextFunctionBody(el, f); }makeStartHandler(elList, f);makeEndHandler(elList, f);if (makeMain) makeTestDriver(elList, f);}
开发者ID:CEpBrowser,项目名称:CEpBrowser--from-UCSC-CGI-BIN,代码行数:35,
示例6: getFileName static std::string getFileName(const std::string &path) { std::string directory; std::string file; splitPath(path, directory, file); return file; }
开发者ID:mgottschlag,项目名称:CoreRender,代码行数:7,
示例7: getDirectory static std::string getDirectory(const std::string &path) { std::string directory; std::string file; splitPath(path, directory, file); return directory; }
开发者ID:mgottschlag,项目名称:CoreRender,代码行数:7,
示例8: splitByNamePrefixvoid splitByNamePrefix(char *inName, char *outRoot, int preFixCount)/* Split into chunks using prefix of sequence names. */{struct dnaSeq seq;struct lineFile *lf = lineFileOpen(inName, TRUE);FILE *f = NULL;char outDir[256], outFile[128], ext[64], outPath[512], preFix[512];ZeroVar(&seq);splitPath(outRoot, outDir, outFile, ext);assert(preFixCount < sizeof(preFix));while (faMixedSpeedReadNext(lf, &seq.dna, &seq.size, &seq.name)) { carefulClose(&f); strncpy(preFix, seq.name, preFixCount); preFix[preFixCount] = '/0'; sprintf(outPath, "%s%s.fa", outDir, preFix); verbose(2, "writing %s/n", outPath); f = mustOpen(outPath, "a"); faWriteNext(f, seq.name, seq.dna, seq.size); }carefulClose(&f);lineFileClose(&lf);}
开发者ID:CEpBrowser,项目名称:CEpBrowser--from-UCSC-CGI-BIN,代码行数:25,
示例9: Q_ASSERTvoid DrawingAnchor::loadXmlObjectPicture(QXmlStreamReader &reader){ Q_ASSERT(reader.name() == QLatin1String("pic")); while (!reader.atEnd()) { reader.readNextStartElement(); if (reader.tokenType() == QXmlStreamReader::StartElement) { if (reader.name() == QLatin1String("blip")) { QString rId = reader.attributes().value(QLatin1String("r:embed")).toString(); QString name = m_drawing->relationships()->getRelationshipById(rId).target; QString path = QDir::cleanPath(splitPath(m_drawing->filePath())[0] + QLatin1String("/") + name); bool exist = false; QList<QSharedPointer<MediaFile> > mfs = m_drawing->workbook->mediaFiles(); for (int i=0; i<mfs.size(); ++i) { if (mfs[i]->fileName() == path) { //already exist exist = true; m_pictureFile = mfs[i]; } } if (!exist) { m_pictureFile = QSharedPointer<MediaFile> (new MediaFile(path)); m_drawing->workbook->addMediaFile(m_pictureFile, true); } } } else if (reader.tokenType() == QXmlStreamReader::EndElement && reader.name() == QLatin1String("pic")) { break; } } return;}
开发者ID:olegyurchenko,项目名称:QtXlsxWriter,代码行数:34,
示例10: splitPath//---------------------------------------------------------------------// remove a file of the dir content - if presentfxp_name * Server::removeFile(bstring const & remotePath) { bstring path, file; file = splitPath(path, remotePath); DirCache::iterator i = dirCache.find(path); if (i == dirCache.end()) return 0; my_fxp_names * dir = i->second; int count = dir->nnames; for (int i = 0; i < count; ++i) { fxp_name * fn = dir->names[i]; if (file == fn->filename) { // not last -> replace current with last if (i + 1 < count) { dir->names[i] = dir->names[count - 1]; } // and one less now --dir->nnames; return fn; // done } } return 0;}
开发者ID:BackupTheBerlios,项目名称:sftp4tc-svn,代码行数:28,
示例11: writeRelevantSplitsvoid writeRelevantSplits(char *ctgDir, struct hash *splitCloneHash)/* Write out splits if there are any. */{ char fileName[512], dir[256], name[128], ext[64]; char *cnBuf, **cloneNames, *clonePath; int i, cloneCount; FILE *f; struct clone *clone; struct frag *frag; sprintf(fileName, "%s/geno.lst", ctgDir); readAllWords(fileName, &cloneNames, &cloneCount, &cnBuf); sprintf(fileName, "%s/splitFin", ctgDir); f = mustOpen(fileName, "w"); for (i=0; i<cloneCount; ++i) { clonePath = cloneNames[i]; splitPath(clonePath, dir, name, ext); if ((clone = hashFindVal(splitCloneHash, name)) != NULL) { printf(" Split %s in %s/n", name, ctgDir); for (frag = clone->fragList; frag != NULL; frag = frag->next) { fprintf(f, "%s/t%s/t%d/t%d/n", frag->name, clone->name, frag->start, frag->end); } } } fclose(f); freeMem(cloneNames); freeMem(cnBuf);}
开发者ID:CEpBrowser,项目名称:CEpBrowser--from-UCSC-CGI-BIN,代码行数:32,
示例12: writeRelevantChainsvoid writeRelevantChains(char *ctgDir, struct hash *cloneHash)/* Read in geno.lst and write chains on relevant clones to * fragChains. */{char inName[512];char outName[512];char *wordBuf, **faNames;int faCount;int i;char dir[256], cloneName[128], ext[64];FILE *f;struct clone *clone;sprintf(inName, "%s/geno.lst", ctgDir);sprintf(outName, "%s/fragChains", ctgDir);readAllWords(inName, &faNames, &faCount, &wordBuf);f = mustOpen(outName, "w");for (i=0; i<faCount; ++i) { splitPath(faNames[i], dir, cloneName, ext); if (!startsWith("NT_", cloneName)) { clone = hashMustFindVal(cloneHash, cloneName); writeChains(clone, f); } }freeMem(wordBuf);fclose(f);}
开发者ID:CEpBrowser,项目名称:CEpBrowser--from-UCSC-CGI-BIN,代码行数:29,
示例13: readAllWordsstruct slName *getFileList(char *listFile, char *bulkDir)/* Get list of files to work on from listFile. */{char **faFiles;char *faBuf;int faCount;int i;char path[512], dir[256], name[128], extension[64];struct slName *list = NULL, *el;readAllWords(listFile, &faFiles, &faCount, &faBuf);for (i = 0; i<faCount; ++i) { splitPath(faFiles[i], dir, name, extension); sprintf(path, "%s/%s.%s", bulkDir, name, "psl"); if (fileExists(path)) { el = newSlName(path); slAddHead(&list, el); } }slReverse(&list);return list;}
开发者ID:CEpBrowser,项目名称:CEpBrowser--from-UCSC-CGI-BIN,代码行数:26,
示例14: splitPath void ModelLoader::loadModel(std::string path, ModelData* modelData) { std::string basename, directory; splitPath(path, &basename, &directory); std::vector<tinyobj::shape_t> shapes; std::vector<tinyobj::material_t> materials; std::string err = tinyobj::LoadObj(shapes, materials, path.c_str(), directory.c_str()); modelData->vertices.clear(); modelData->indices.clear(); modelData->material.reset(); modelData->diffuseTex.reset(); modelData->alphaTex.reset(); if (materials.size() > 0) { modelData->material.reset(createMaterialFromMtl(*materials.begin())); if (!materials.begin()->diffuse_texname.empty()) modelData->diffuseTex.reset(loadImage(directory, materials.begin()->diffuse_texname)); else modelData->diffuseTex.reset(); if (!materials.begin()->alpha_texname.empty()) modelData->alphaTex.reset(loadImage(directory, materials.begin()->alpha_texname)); else modelData->alphaTex.reset(); } if (!err.empty()) throw Exception(err); loadShapes(shapes, &modelData->vertices, &modelData->indices); }
开发者ID:trolleyyy,项目名称:GK3D,代码行数:29,
示例15: recurseThroughIncludesstatic void recurseThroughIncludes(char *fileName, struct lm *lm, struct hash *circularHash, struct raLevel *level, struct raFile **pFileList)/* Recurse through include files. */{struct raFile *raFile = raFileRead(fileName, level, lm);slAddHead(pFileList, raFile);struct raRecord *r;for (r = raFile->recordList; r != NULL; r = r->next) { struct raTag *tag = r->tagList; if (sameString(tag->name, "include")) { for (; tag != NULL; tag = tag->next) { if (!sameString(tag->name, "include")) recordAbort(r, "Non-include tag %s in an include stanza", tag->name); char *relPath = tag->val; char dir[PATH_LEN]; splitPath(fileName, dir, NULL, NULL); char includeName[PATH_LEN]; safef(includeName, sizeof(includeName), "%s%s", dir, relPath); if (hashLookup(circularHash, includeName)) recordAbort(r, "Including file %s in an infinite loop", includeName); recurseThroughIncludes(includeName, lm, circularHash, level, pFileList); } } }}
开发者ID:CEpBrowser,项目名称:CEpBrowser--from-UCSC-CGI-BIN,代码行数:28,
示例16: getDirnamestring getDirname(const string &path){ string dir; string file; splitPath(path, dir, file); return dir;}
开发者ID:mikmakmuk,项目名称:syncevolution_n9,代码行数:7,
示例17: ccdsGetTblFileNamesvoid ccdsGetTblFileNames(char *tblFile, char *table, char *tabFile)/* Get table and tab file name from a single input name. If specified names * looks like a file name, use it as-is, otherwise generate a file name. * Output buffers should be PATH_LEN bytes long. Either output argument maybe * be NULL. */{if ((strchr(tblFile, '/') != NULL) || (strchr(tblFile, '.') != NULL)) { if (tabFile != NULL) safef(tabFile, PATH_LEN, "%s", tblFile); if (table != NULL) splitPath(tblFile, NULL, table, NULL); }else { if (tabFile != NULL) { char *tmpDir = getenv("TMPDIR"); if (tmpDir != NULL) safef(tabFile, PATH_LEN, "%s/%s.tab", tmpDir, tblFile); else safef(tabFile, PATH_LEN, "%s.tab", tblFile); } if (table != NULL) safef(table, PATH_LEN, "%s", tblFile); }}
开发者ID:ucsc-mus-strain-cactus,项目名称:kent,代码行数:27,
示例18: gfiGetSeqNamevoid gfiGetSeqName(char *spec, char *name, char *file)/* Extract sequence name and optionally file name from spec, * which includes nib and 2bit files. (The file may be NULL * if you don't care.) */{if (nibIsFile(spec)) { splitPath(spec, NULL, name, NULL); if (file != NULL) strcpy(file, spec); }else { char *s = strchr(spec, ':'); if (s == NULL) errAbort("Expecting colon in %s", spec); strcpy(name, s+1); if (file != NULL) { int fileNameSize = s - spec; memcpy(file, spec, fileNameSize); file[fileNameSize] = 0; } }}
开发者ID:JinfengChen,项目名称:pblat,代码行数:25,
示例19: mkOutPathvoid mkOutPath(char *outPath, char* outRoot, int digits, int fileCount)/* generate output file name */{char dir[PATH_LEN], fname[PATH_LEN];splitPath(outRoot, dir, fname, NULL);strcpy(outPath, dir);if (outDirDepth > 0) { /* add directory levels, using training digits for names */ char fcntStr[64], dirBuf[3]; int i, iDir; safef(fcntStr, sizeof(fcntStr), "%0*d", outDirDepth, fileCount); iDir = strlen(fcntStr)-outDirDepth; strcpy(dirBuf, "X/"); for (i = 0; i < outDirDepth; i++, iDir++) { dirBuf[0] = fcntStr[iDir]; strcat(outPath, dirBuf); makeDir(outPath); } }if (digits) sprintf(outPath+strlen(outPath), "%s%0*d.fa", fname, digits, fileCount);}
开发者ID:CEpBrowser,项目名称:CEpBrowser--from-UCSC-CGI-BIN,代码行数:26,
示例20: getBasenamestring getBasename(const string &path){ string dir; string file; splitPath(path, dir, file); return file;}
开发者ID:mikmakmuk,项目名称:syncevolution_n9,代码行数:7,
示例21: strncpychar *chromFileName(char *track, char *chrom, char fileName[512])/* Return chromosome specific version of file if it exists. */{if (fileExists(track)) { strncpy(fileName, track, 512); }else { char dir[256], root[128], ext[65]; int len; splitPath(track, dir, root, ext); /* Chop trailing / off of dir. */ len = strlen(dir); if (len > 0 && dir[len-1] == '/') dir[len-1] = 0; safef(fileName, 512, "%s/%s%s%s", dir, chrom, root, ext); if (!fileExists(fileName)) { warn("Couldn't find %s or %s", track, fileName); strncpy(fileName, track, 512); } }return fileName;}
开发者ID:davidhoover,项目名称:kent,代码行数:25,
示例22: ZFUNCTRACE_DEVELOPvoid ZProfile::openRoot (ZBoolean aCreate){ ZFUNCTRACE_DEVELOP ("ZProfile::openRoot(ZBoolean aCreate)"); if (iRootHandle == 0 || (aCreate && iRootReadOnly)) { closeRoot (); HKEY parentKey (0); ZString path; while (!parentKey) { path = iRoot; ZString token (splitPath (path)); for (unsigned i = 0; i < sizeof (sysHandles) / sizeof (SystemHandle); i++) if (token == sysHandles[i].iName) { parentKey = sysHandles[i].iHandle; break; } // if if (!parentKey) iRoot = ZString (sysHandles[0].iName) + (char) ZC_PATHSEPARATOR + iRoot; } // while if (path.length ()) iRootHandle = openHandle (parentKey, path, aCreate); else iRootHandle = parentKey; iRootReadOnly = !aCreate; } // if} // openRoot
开发者ID:greeduomacro,项目名称:Iris1,代码行数:31,
示例23: oneContigvoid oneContig(char *dir, char *chrom, char *contig)/* Write out clone ends information to one contig. */{char *wordsBuf, **faFiles, *faFile;int i, faCount;char path[512], sDir[256], sFile[128], sExt[64];FILE *f;struct clone *clone;sprintf(path, "%s/geno.lst", dir);readAllWords(path, &faFiles, &faCount, &wordsBuf);sprintf(path, "%s/cloneEnds", dir);f = mustOpen(path, "w");fprintf(f, "#accession/tversion/tphase/tGS ends/tSP ends/taFrag/taSide/tzFrag/tzSide/n");for (i=0; i<faCount; ++i) { faFile = faFiles[i]; splitPath(faFile, sDir, sFile, sExt); if ((clone = hashFindVal(cloneHash, sFile)) != NULL) { printCloneEndInfo(clone, f); } }freez(&wordsBuf);fclose(f);}
开发者ID:CEpBrowser,项目名称:CEpBrowser--from-UCSC-CGI-BIN,代码行数:27,
示例24: filterByQualint filterByQual(char *faFileName, FILE *f, int minQual, int minQualRun, struct hash *uniqHash)/* Write out parts of sequence that meet quality standards to fa file in out. * Returns untrimmed size. */{char qaFileName[512], dir[256], name[128], ext[64];struct qaSeq *qa;int start, size;int initialSize;splitPath(faFileName, dir, name, ext);sprintf(qaFileName, "%s%s.qual", dir, name);qa = qaMustReadBoth(qaFileName, faFileName);if (hashLookup(uniqHash, qa->name)) warn("%s duplicated, ignoring all but first occurence", qa->name);else { hashAdd(uniqHash, qa->name, NULL); if (trimQa(qa, minQual, minQualRun, &start, &size)) { faWriteNext(f, qa->name, qa->dna + start, size); } }initialSize = qa->size;qaSeqFree(&qa);return initialSize;}
开发者ID:ucsc-mus-strain-cactus,项目名称:kent,代码行数:26,
示例25: splitPathCommon::InSaveFile *Ps2SaveFileManager::openForLoading(const char *filename) { _screen->wantAnim(true); char dir[256], name[256]; splitPath(filename, dir, name); if (mcReadyForDir(dir)) { bool fileExists = false; for (int i = 0; i < _mcEntries; i++) if (strcmp(name, (char*)_mcDirList[i].name) == 0) fileExists = true; if (fileExists) { char fullName[256]; sprintf(fullName, "/ScummVM-%s/%s", dir, name); UclInSaveFile *file = new UclInSaveFile(fullName, _screen, _mc); if (file) { if (!file->ioFailed()) return file; else delete file; } } else printf("file %s (%s) doesn't exist/n", filename, name); } _screen->wantAnim(false); return NULL;}
开发者ID:iPodLinux-Community,项目名称:iScummVM,代码行数:26,
示例26: split QList<QImage> split(const QImage& img) { QVector<bool> emptyLines(img.height(), true); for (int y = 0; y < img.height(); ++y) { const uchar* it = img.constScanLine(y); const uchar* end = it + img.width(); while (it < end) { if (*it++ > 10) { emptyLines[y] = false; break; } } } QList<QImage> lines; for (int y = 0; y < img.height();) { if (emptyLines[y]) { ++y; continue; } QRect r(0, y, img.width(), 1); int height = 0; for (; y < img.height() && !emptyLines[y]; ++y) ++height; r.setHeight(height); if (height > 60 && height < 80) { lines += splitPath(img.copy(r)); } else { lines << img.copy(r); } } return lines; }
开发者ID:tonttu,项目名称:subocr,代码行数:35,
示例27: envint env(int argc, char **argv) { char epath[PATH_MAX + 1]; char *oldpath = getenv("PATH"); assert(oldpath); if (!getExecutablePath(epath, sizeof(epath))) exit(EXIT_FAILURE); if (argc <= 1) { const std::string &pname = getParentProcessName(); if (pname == "csh" || pname == "tcsh") { std::cerr << std::endl << "you are invoking this program from a C shell, " << std::endl << "please use " << std::endl << std::endl << "setenv PATH `" << epath << "/osxcross-env -v=PATH`" << std::endl << std::endl << "instead." << std::endl << std::endl; } } std::vector<std::string> path; std::map<std::string, std::string> vars; splitPath(oldpath, path); if (!hasPath(path, epath)) path.push_back(epath); vars["PATH"] = joinPath(path); auto printVariable = [&](const std::string & var)->bool { auto it = vars.find(var); if (it == vars.end()) { std::cerr << "unknown variable '" << var << "'" << std::endl; return false; } std::cout << it->second << std::endl; return true; }; if (argc <= 1) { std::cout << std::endl; for (auto &v : vars) { std::cout << "export " << v.first << "="; if (!printVariable(v.first)) return 1; std::cout << std::endl; } } else { if (strncmp(argv[1], "-v=", 3)) return 1; const char *var = argv[1] + 3; return static_cast<int>(printVariable(var)); } return 0;}
开发者ID:carriercomm,项目名称:osxcross,代码行数:59,
注:本文中的splitPath函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 C++ splitString函数代码示例 C++ split函数代码示例 |