当前位置: 首页>>代码示例>>C++>>正文


C++ FileName::fileContents方法代码示例

本文整理汇总了C++中FileName::fileContents方法的典型用法代码示例。如果您正苦于以下问题:C++ FileName::fileContents方法的具体用法?C++ FileName::fileContents怎么用?C++ FileName::fileContents使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在FileName的用法示例。


在下文中一共展示了FileName::fileContents方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: texFileList

QStringList texFileList(QString const & filename)
{
	QStringList list;
	FileName const file = libFileSearch(QString(), filename);
	if (file.empty())
		return list;

	// FIXME Unicode.
	vector<docstring> doclist = 
		getVectorFromString(file.fileContents("UTF-8"), from_ascii("\n"));

	// Normalise paths like /foo//bar ==> /foo/bar
	QSet<QString> set;
	for (size_t i = 0; i != doclist.size(); ++i) {
		QString file = toqstr(doclist[i]);
		file.replace("\r", "");
		while (file.contains("//"))
			file.replace("//", "/");
		if (!file.isEmpty())
			set.insert(file);
	}

	// remove duplicates
	return QList<QString>::fromSet(set);
}
开发者ID:hashinisenaratne,项目名称:HSTML,代码行数:25,代码来源:qt_helpers.cpp

示例2: doSubstitution


//.........这里部分代码省略.........
	string const basename = changeExtension(
			onlyFileName(filename), string());
	string const absname = makeAbsPath(filename, parentpath).absFileName();

	string result = s;
	if (what != ALL_BUT_PATHS) {
		string const filepath = onlyPath(filename);
		string const abspath = onlyPath(absname);
		string const masterpath = external_in_tmpdir ?
			masterBuffer->temppath() :
			masterBuffer->filePath();
		// FIXME UNICODE
		string relToMasterPath = onlyPath(
				to_utf8(makeRelPath(from_utf8(absname),
							     from_utf8(masterpath))));
		if (relToMasterPath == "./")
			relToMasterPath.clear();
		// FIXME UNICODE
		string relToParentPath = onlyPath(
				to_utf8(makeRelPath(from_utf8(absname),
							     from_utf8(parentpath))));
		if (relToParentPath == "./")
			relToParentPath.clear();

		result = subst_path(result, "$$FPath", filepath,
				    use_latex_path,
				    PROTECT_EXTENSION,
				    ESCAPE_DOTS);
		result = subst_path(result, "$$AbsPath", abspath,
				    use_latex_path,
				    PROTECT_EXTENSION,
				    ESCAPE_DOTS);
		result = subst_path(result, "$$RelPathMaster",
				    relToMasterPath, use_latex_path,
				    PROTECT_EXTENSION,
				    ESCAPE_DOTS);
		result = subst_path(result, "$$RelPathParent",
				    relToParentPath, use_latex_path,
				    PROTECT_EXTENSION,
				    ESCAPE_DOTS);
		if (FileName::isAbsolute(filename)) {
			result = subst_path(result, "$$AbsOrRelPathMaster",
					    abspath, use_latex_path,
					    PROTECT_EXTENSION,
					    ESCAPE_DOTS);
			result = subst_path(result, "$$AbsOrRelPathParent",
					    abspath, use_latex_path,
					    PROTECT_EXTENSION,
					    ESCAPE_DOTS);
		} else {
			result = subst_path(result, "$$AbsOrRelPathMaster",
					    relToMasterPath, use_latex_path,
					    PROTECT_EXTENSION,
					    ESCAPE_DOTS);
			result = subst_path(result, "$$AbsOrRelPathParent",
					    relToParentPath, use_latex_path,
					    PROTECT_EXTENSION,
					    ESCAPE_DOTS);
		}
	}

	if (what == PATHS)
		return result;

	result = subst_path(result, "$$FName", filename, use_latex_path,
			    EXCLUDE_EXTENSION);
	result = subst_path(result, "$$Basename", basename, use_latex_path,
			    PROTECT_EXTENSION, ESCAPE_DOTS);
	result = subst_path(result, "$$Extension",
			'.' + getExtension(filename), use_latex_path);
	result = subst_path(result, "$$Tempname", params.tempname().absFileName(), use_latex_path);
	result = subst_path(result, "$$Sysdir",
				package().system_support().absFileName(), use_latex_path);

	// Handle the $$Contents(filename) syntax
	if (contains(result, "$$Contents(\"")) {
		// Since use_latex_path may be true we must extract the file
		// name from s instead of result and do the substitutions
		// again, this time with use_latex_path false.
		size_t const spos = s.find("$$Contents(\"");
		size_t const send = s.find("\")", spos);
		string const file_template = s.substr(spos + 12, send - (spos + 12));
		string const file = doSubstitution(params, buffer,
						   file_template, false,
						   external_in_tmpdir, what);
		string contents;

		FileName const absfile(
			makeAbsPath(file, masterBuffer->temppath()));
		if (absfile.isReadableFile())
			// FIXME UNICODE
			contents = to_utf8(absfile.fileContents("UTF-8"));

		size_t const pos = result.find("$$Contents(\"");
		size_t const end = result.find("\")", pos);
		result.replace(pos, end + 2, contents);
	}

	return result;
}
开发者ID:bsjung,项目名称:Lyx,代码行数:101,代码来源:ExternalSupport.cpp


注:本文中的FileName::fileContents方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。