本文整理汇总了C++中splitPath函数的典型用法代码示例。如果您正苦于以下问题:C++ splitPath函数的具体用法?C++ splitPath怎么用?C++ splitPath使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了splitPath函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: splitPath
bool 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;
}
示例2: bigWigCorrelateList
void 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);
}
}
}
示例3: convertPathToRelative
static 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;
}
示例4: loadPslTable
void 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);
}
示例5: makeC
void 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);
}
示例6: getFileName
static std::string getFileName(const std::string &path)
{
std::string directory;
std::string file;
splitPath(path, directory, file);
return file;
}
示例7: getDirectory
static std::string getDirectory(const std::string &path)
{
std::string directory;
std::string file;
splitPath(path, directory, file);
return directory;
}
示例8: splitByNamePrefix
void 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);
}
示例9: Q_ASSERT
void 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;
}
示例10: splitPath
//---------------------------------------------------------------------
// remove a file of the dir content - if present
fxp_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;
}
示例11: writeRelevantSplits
void 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);
}
示例12: writeRelevantChains
void 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);
}
示例13: readAllWords
struct 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;
}
示例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);
}
示例15: recurseThroughIncludes
static 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);
}
}
}
}