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


C++ FileReader::close方法代码示例

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


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

示例1: saveJASPArchive

void JASPExporter::saveJASPArchive(archive *a, DataSetPackage *package, boost::function<void (const std::string &, int)> progressCallback)
{
	if (package->hasAnalyses)
	{
		struct archive_entry *entry;

		Json::Value &analysesJson = package->analysesData;

		//Create new entry for archive NOTE: must be done before data is added
		string analysesString = analysesJson.toStyledString();
		int sizeOfAnalysesString = analysesString.size();

		entry = archive_entry_new();
		string dd4 = string("analyses.json");
		archive_entry_set_pathname(entry, dd4.c_str());
		archive_entry_set_size(entry, sizeOfAnalysesString);
		archive_entry_set_filetype(entry, AE_IFREG);
		archive_entry_set_perm(entry, 0644); // Not sure what this does
		archive_write_header(a, entry);

		archive_write_data(a, analysesString.c_str(), sizeOfAnalysesString);

		archive_entry_free(entry);

		char imagebuff[8192];
		for (Json::Value::iterator iter = analysesJson.begin(); iter != analysesJson.end(); iter++)
		{
			Json::Value &analysisJson = *iter;
			vector<string> paths = tempfiles_retrieveList(analysisJson["id"].asInt());
			for (int j = 0; j < paths.size(); j++)
			{
				FileReader fileInfo = FileReader(tempfiles_sessionDirName() + "/" + paths[j]);
				if (fileInfo.exists())
				{
					int imageSize = fileInfo.size();

					entry = archive_entry_new();
					string dd4 = paths[j];
					archive_entry_set_pathname(entry, dd4.c_str());
					archive_entry_set_size(entry, imageSize);
					archive_entry_set_filetype(entry, AE_IFREG);
					archive_entry_set_perm(entry, 0644); // Not sure what this does
					archive_write_header(a, entry);

					int bytes = 0;
					int errorCode = 0;
					while ((bytes = fileInfo.readData(imagebuff, sizeof(imagebuff), errorCode)) > 0 && errorCode == 0) {
						archive_write_data(a, imagebuff, bytes);
					}

					archive_entry_free(entry);

					if (errorCode < 0)
						throw runtime_error("Required resource files could not be accessed.");
				}
				fileInfo.close();
			}
		}
	}
}
开发者ID:daniloap,项目名称:jasp-desktop,代码行数:60,代码来源:jaspexporter.cpp

示例2: loadLoginMessage

void ZoneServerImplementation::loadLoginMessage() {
	Locker locker(_this.getReferenceUnsafeStaticCast());

	File* file;
	FileReader* reader;

	try {
		file = new File("conf/motd.txt");
		reader = new FileReader(file);

		String line;
		while(reader->readLine(line)) {
			loginMessage += line;
		}

		reader->close();
	} catch (FileNotFoundException& e) {
		file = NULL;
		reader = NULL;
	}

	loginMessage += "\nLatest Commits:\n";
	loginMessage += ConfigManager::instance()->getRevision();

	delete reader;
	delete file;
}
开发者ID:JigglyPoofSWG,项目名称:BSS,代码行数:27,代码来源:ZoneServerImplementation.cpp

示例3: loadRevision

void ConfigManager::loadRevision() {
	File* file;
	FileReader* reader;

	revision = "";

	try {
		file = new File("conf/rev.txt");
		reader = new FileReader(file);

		String line;

		while (reader->readLine(line))
			revision += line;

		reader->close();
	} catch (FileNotFoundException& e) {
		file = NULL;
		reader = NULL;
	} catch (Exception& e) {
		file = NULL;
		reader = NULL;
	}

	//revision = revision.replaceAll("\n", "");

	delete reader;
	delete file;
}
开发者ID:Chilastra-Reborn,项目名称:Core3,代码行数:29,代码来源:ConfigManager.cpp

示例4: loadMOTD

void ConfigManager::loadMOTD() {
	messageOfTheDay = "";

	File* file;
	FileReader* reader;

	try {
		file = new File("conf/motd.txt");
		reader = new FileReader(file);

		String line;

		while(reader->readLine(line)) {
			messageOfTheDay += line;
		}

		reader->close();
	} catch (FileNotFoundException& e) {
		file = NULL;
		reader = NULL;
	}

	delete reader;
	delete file;
}
开发者ID:Chilastra-Reborn,项目名称:Core3,代码行数:25,代码来源:ConfigManager.cpp

示例5: loadResource

ShaderPtr Shader::loadResource(const string &name)
{
	FileReader *fileReader;

	fileReader = new FileReader(util::getAbsoluteFilePath(name + ".vert"));
	string vertexSource = fileReader->readAll();
	fileReader->close();
	delete fileReader;

	fileReader = new FileReader(util::getAbsoluteFilePath(name + ".frag"));
	string fragmentSource = fileReader->readAll();
	fileReader->close();
	delete fileReader;

	LOG("Compiling shader program: %s", name.c_str());

	return ShaderPtr(new Shader(vertexSource, fragmentSource));
}
开发者ID:hkbruvold,项目名称:x2D-Game-Engine,代码行数:18,代码来源:shader.cpp

示例6: main

signed main() {
	static constexpr StringRef const path{"data/file_stream.bin"};
	{
		FileWriter writer;
		TOGO_ASSERTE(!writer.is_open());
		TOGO_ASSERTE(writer.open(path, false));
		TOGO_ASSERTE(writer.is_open());
		test_writer(writer, true);
		writer.close();
	}
	{
		FileReader reader;
		TOGO_ASSERTE(!reader.is_open());
		TOGO_ASSERTE(reader.open(path));
		TOGO_ASSERTE(reader.is_open());
		test_reader(reader, true);
		reader.close();
	}
	return 0;
}
开发者ID:AbstractAlgorithm,项目名称:togo,代码行数:20,代码来源:file_stream.cpp


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