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


C++ COFile::open方法代码示例

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


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

示例1: on_saveAsPushButton_clicked

void CTile_edit_dlg::on_saveAsPushButton_clicked()
{
	QFileDialog::Options options;
	QString selectedFilter;
	QString fileName = QFileDialog::getSaveFileName(this, tr("Save Bank"), this->mainFile.absoluteFilePath(), tr("NeL tile bank files (*.bank);;All Files (*.*);;"), &selectedFilter, options);
	if (!fileName.isEmpty())
	{
		// Set MainFile
		mainFile = QFileInfo(fileName);
		ui.savePushButton->setEnabled(true);


		string fullPath = this->mainFile.absoluteFilePath().toUtf8();
		if ( !fullPath.empty() )
		{
			COFile stream;
			if ( stream.open( fullPath.c_str() ) )
			{
				tileBank.serial (stream);
				QString s = tr("Bank %1 saved").arg( QString( fullPath.c_str() ) );
				QMessageBox::information(this, tr("Bank Saved"), s);
				return;
			}
		}

		QMessageBox::information(this, tr("Error"), tr("Can't Save Bank, check the path"));

	}

}
开发者ID:AzyxWare,项目名称:ryzom,代码行数:30,代码来源:tile_edit_dlg.cpp

示例2: on_exportPushButton_clicked

void CTile_edit_dlg::on_exportPushButton_clicked()
{
	QFileDialog::Options options;
	QString selectedFilter;
	QString fileName = QFileDialog::getSaveFileName(this, tr("Export Bank"), this->mainFile.absolutePath() + QDir::separator() + tr("*.smallbank"), tr("NeL tile small bank files (*.smallbank);;All Files (*.*);;"), &selectedFilter, options);
	if (!fileName.isEmpty())
	{
		// Copy the bank
		CTileBank copy=tileBank;

		// Remove unused data
		copy.cleanUnusedData ();

		QFileInfo fileInfo(fileName);
		string fullPath = fileInfo.absoluteFilePath().toUtf8();
		if ( !fullPath.empty() )
		{
			COFile stream;
			if ( stream.open( fullPath.c_str() ) )
			{
				copy.serial (stream);
				QString s = tr("Bank %1 exported").arg( QString( fullPath.c_str() ) );
				QMessageBox::information(this, tr("Bank Saved"), s);
				return;
			}
		}

		QMessageBox::information(this, tr("Error"), tr("Can't Export the Bank, check the path"));
	}
}
开发者ID:AzyxWare,项目名称:ryzom,代码行数:30,代码来源:tile_edit_dlg.cpp

示例3: exportVegetable

bool CNelExport::exportVegetable (const char *sPath, INode& node, TimeValue time)
{
	bool bRet=false;

	// Build a vegetable
	NL3D::CVegetableShape vegetable;
	if (_ExportNel->buildVegetableShape (vegetable, node, time))
	{
		// Open a file
		COFile file;
		if (file.open (sPath))
		{
			try
			{
				// Serial the shape
				vegetable.serial (file);

				// All is good
				bRet=true;
			}
			catch (Exception &e)
			{
				// Message box
				const char *message = e.what();
				_ExportNel->outputErrorMessage ("Error during vegetable serialisation");
			}
		}
	}
	return bRet;
}
开发者ID:mixxit,项目名称:solinia,代码行数:30,代码来源:nel_export_export.cpp

示例4: save

void CSoundAnimation::save()
{
	// File stream
	COFile file;
	vector<NLMISC::CSheetId>	sounds;

	// Open the file
	if (!file.open(_Filename.c_str()))
	{
		throw NLMISC::Exception("Can't open the file for writing");
	}

	// Create the XML stream
	COXml output;

	// Init
	if (output.init (&file, "1.0"))
	{
		xmlDocPtr xmlDoc = output.getDocument();

		// Create the first node
		xmlNodePtr root = xmlNewDocNode (xmlDoc, NULL, (const xmlChar*)"SOUNDANIMATION", NULL);
		xmlDocSetRootElement (xmlDoc, root);

		vector<CSoundAnimMarker*>::iterator iter;
		for (iter = _Markers.begin(); iter != _Markers.end(); iter++)
		{
			CSoundAnimMarker* marker = (*iter);

			set<string>::iterator iter;

			char s[64];
			smprintf(s, 64, "%f", marker->getTime());

			xmlNodePtr markerNode = xmlNewChild (root, NULL, (const xmlChar*)"MARKER", NULL);
			xmlSetProp (markerNode, (const xmlChar*) "time", (const xmlChar*) s);

			marker->getSounds(sounds);

			vector<NLMISC::CSheetId>::iterator iter2;
			for (iter2 = sounds.begin(); iter2 != sounds.end(); iter2++)
			{
				xmlNodePtr soundNode = xmlNewChild ( markerNode, NULL, (const xmlChar*)"SOUND", NULL );
				xmlSetProp (soundNode, (const xmlChar*)"name", (const xmlChar*)iter2->toString().c_str() /*CStringMapper::unmap(*iter2).c_str()*/);
			}

			sounds.clear();
		}

		// Flush the stream, write all the output file
		output.flush ();
	}

	// Close the file
	file.close ();

	_Dirty = false;
}
开发者ID:CCChaos,项目名称:RyzomCore,代码行数:58,代码来源:sound_animation.cpp

示例5: main

int main(int argc, char* argv[])
{
	// Arg ?
	if (argc<3)
	{
		// Doc
		printf ("build_smallbank [input.bank] [output.smallbank] [new_absolute_path]\n");
	}
	else
	{
		try
		{
			// Load the bank
			CTileBank bank;

			// Input file
			CIFile input;
			if (input.open (argv[1]))
			{
				// Serial the bank
				bank.serial (input);

				// Make a small bank
				bank.cleanUnusedData ();

				// Absolute path ?
				if (argc>3)
					bank.setAbsPath (argv[3]);

				// Output file
				COFile output;
				if (output.open (argv[2]))
				{
					// Serial the bank
					bank.serial (output);
				}
				else
				{
					// Error
					nlwarning ("ERROR can't open the file %s for writing", argv[2]);
				}
			}
			else
			{
				// Error
				nlwarning ("ERROR can't open the file %s for reading", argv[1]);
			}

		}
		catch (const Exception& e)
		{
			// Error
			nlwarning ("ERROR fatal error: %s", e.what());
		}
	}
	return 0;
}
开发者ID:CCChaos,项目名称:RyzomCore,代码行数:57,代码来源:build_smallbank.cpp

示例6: main

int main(int argc, char *argv[])
{
	if(argc != 4)
	{
		usage();
		return -1;
	}
	else
	{
		CBitmap		btmp;
		CIFile		inFile;
		COFile		outFile;

		uint	divideRatio;
		NLMISC::fromString(argv[3], divideRatio);
		if(divideRatio==0 || !isPowerOf2(divideRatio))
		{
			printf("divideRatio must be a powerOf2 (1, 2, 4, 8 ...) \n");
			return 0;
		}

		try
		{
			// read.
			if (!inFile.open(argv[1]))
			{
				printf("Can't open input file %s \n", argv[1]);
				return -1;
			}
			uint8	depth= btmp.load(inFile);
			if(depth==0)
				throw Exception("Bad File Format");
			inFile.close();

			// resize.
			btmp.resample(btmp.getWidth() / divideRatio, btmp.getHeight() / divideRatio);

			// output.
			if (!outFile.open(argv[2]))
			{
				printf("Can't open output file %s \n", argv[2]);
				return -1;
			}
			btmp.writeTGA(outFile, depth);
		}
		catch (const Exception &e)
		{
			printf("Error: %s\n", e.what());
				return -1;
		}

		return 0;
	}
}
开发者ID:CCChaos,项目名称:RyzomCore,代码行数:54,代码来源:main.cpp

示例7: generateSpellList

/** Generate list of spell
  */
static void generateSpellList(CConfigFile &cf, const std::string &sheetName)
{
	CConfigFile::CVar *spellList = cf.getVarPtr("spell_list");
	if (!spellList)
	{
		nlwarning("Can't read spell list");
		return;
	}	
	COFile f;
	if (!f.open(sheetName, false, true))
	{
		nlwarning("Can't write %s", sheetName.c_str());
		return;
	}
	try
	{	
		COXml xmlStreamOut;
		xmlStreamOut.init(&f);
		xmlStreamOut.xmlPush("FORM");
		IStream &xmlStream = xmlStreamOut;
		xmlStream.xmlPush("STRUCT");
		xmlStream.xmlPushBegin("ARRAY");
			xmlStream.xmlSetAttrib("Name");
			std::string name = "List";
			xmlStream.serial(name);					
		xmlStream.xmlPushEnd();				
		for(uint k = 0; k < (uint) spellList->size(); ++k)
		{
			std::vector<std::string> result;
			NLMISC::splitString(spellList->asString(k), "|", result);
			if (result.size()  < 2)
			{
				nlwarning("Should provide at list spell name and id");
			}
			xmlStream.xmlPush("STRUCT");				
				writeAtom(xmlStream, "ID", result[1]);
				writeAtom(xmlStream, "SheetBaseName", result[0]);
			xmlStream.xmlPop();
		}
		xmlStream.xmlPop(); // STRUCT
		xmlStream.xmlPop(); // FORM
	}
	catch(const EStream &)
	{
		nlwarning("Cant write %s", sheetName.c_str());
	}
}
开发者ID:Kiddinglife,项目名称:ryzom,代码行数:49,代码来源:build_spell_sheet.cpp

示例8: MakeTyp

// ---------------------------------------------------------------------------
void CGeorgesImpl::MakeTyp( const std::string& filename, TType type, TUI ui, const std::string& _min, const std::string& _max, const std::string& _default, const std::vector< std::pair< std::string, std::string > >* const _pvpredef )
{
	AFX_MANAGE_STATE(AfxGetStaticModuleState());

	// Create a type
	CType t;
	t.Type = (CType::TType)type;
	t.UIType = (CType::TUI)ui;
	t.Min= _min;
	t.Max = _max;
	t.Default = _default;

	if (_pvpredef)
	{
		t.Definitions.resize (_pvpredef->size ());
		uint i;
		for (i=0; i<_pvpredef->size (); i++)
		{
			t.Definitions[i].Label = (*_pvpredef)[i].first;
			t.Definitions[i].Value = (*_pvpredef)[i].second;
		}
	}

	// Save the type
	COFile output;
	if (output.open (filename))
	{
		try
		{
			// XML stream
			COXml outputXml;
			outputXml.init (&output);

			// Write
			t.write (outputXml.getDocument ());
		}
		catch (Exception &e)
		{
			nlwarning ("Error during writing file '%s' : ", filename.c_str (), e.what ());
		}
	}
	else
	{
		nlwarning ("Can't open the file %s for writing", filename.c_str ());
	}
}
开发者ID:sythaeryn,项目名称:pndrpg,代码行数:47,代码来源:georges_implementation.cpp

示例9: on_savePushButton_clicked

void CTile_edit_dlg::on_savePushButton_clicked()
{
	string fullPath = this->mainFile.absoluteFilePath().toUtf8();
	if ( !fullPath.empty() )
	{
		COFile stream;
		if ( stream.open( fullPath.c_str() ) )
		{
			tileBank.serial (stream);
			QString s = tr("Bank %1 saved").arg( QString( fullPath.c_str() ) );
			QMessageBox::information(this, tr("Bank Saved"), s);
			return;
		}
	}

	QMessageBox::information(this, tr("Error"), tr("Can't Save Bank, check the path"));
}
开发者ID:AzyxWare,项目名称:ryzom,代码行数:17,代码来源:tile_edit_dlg.cpp

示例10: createInstanceFile

// ---------------------------------------------------------------------------
void CGeorgesImpl::createInstanceFile (const std::string &_sxFullnameWithoutExt, const std::string &_dfnname)
{
	AFX_MANAGE_STATE(AfxGetStaticModuleState());

	CFormLoader formLoader;
	CFormDfn *dfn = formLoader.loadFormDfn (_dfnname.c_str(), false);
	if (!dfn)
	{
		char msg[512];
		smprintf (msg, 512, "Can't load DFN '%s'", _dfnname);
		theApp.outputError (msg);
		return;
	}

	NLMISC::CSmartPtr<NLGEORGES::UForm> Form = new CForm;

	std::string fullName;
	fullName = _sxFullnameWithoutExt + ".";

	int i = 0;
	if (_dfnname[i] == '.') ++i;
	for (; i < (int)_dfnname.size(); ++i)
	{
		if (_dfnname[i] == '.') break;
		fullName += _dfnname[i];
	}

	((CFormElmStruct*)&Form->getRootNode ())->build (dfn);
	COFile f;
	COXml ox;
	if (f.open (fullName))
	{
		ox.init(&f);
		((NLGEORGES::CForm*)((UForm*)Form))->write (ox.getDocument(), _sxFullnameWithoutExt.c_str ());
		ox.flush();
		f.close();
	}
	else
	{
		char msg[512];
		smprintf (msg, 512, "Can't write '%s'", fullName);
		theApp.outputError (msg);
		return;
	}
}
开发者ID:sythaeryn,项目名称:pndrpg,代码行数:46,代码来源:georges_implementation.cpp

示例11: setDebugOutput

//-----------------------------------------------
// setDebugOutput :
// Set an output file to log debugs.
//-----------------------------------------------
void setDebugOutput(const std::string &filename)
{
	// Remove output
	if(filename.empty())
	{
		DebugFile.close();
		IsDebugFile = false;
		return;
	}

	// Open The Item Association File
	if(!DebugFile.open(filename, false, true))
	{
		nlwarning("setDebugOutput: Cannot Open the '%s'.", filename.c_str());
		IsDebugFile = false;
	}
	else
		IsDebugFile = true;
}// setDebugOutput //
开发者ID:AzyxWare,项目名称:ryzom,代码行数:23,代码来源:debug_client.cpp

示例12:

/*
 * Save a Reference index file
 */
bool	CRefIndex::save(const string& filename)
{
	COFile		reffile;
	COXml		oxml;

	if (!reffile.open(filename) || !oxml.init(&reffile))
		return false;

	try
	{
		serial(oxml);
	}
	catch (const Exception&)
	{
		return false;
	}

	return true;
}
开发者ID:Kiddinglife,项目名称:ryzom,代码行数:22,代码来源:pd_server_utils.cpp

示例13: load

//-----------------------------------------------
// load :
// Load all sheets.
//-----------------------------------------------
void CSheetManager::load(NLMISC::IProgressCallback &callBack, bool updatePackedSheet, bool needComputeVS, bool dumpVSIndex)
{
	// Open The Item Association File
	if(!fItemAssoc.open("item_association.dbg", false, true))
		nlwarning("CSheetManager::load: Cannot Open the 'item_association.txt'.");
	else
		ItemAssocFileOpen = true;

	// Initialize the Sheet DB.
	loadAllSheet(callBack, updatePackedSheet, needComputeVS, dumpVSIndex);

	// Close the Item Association File.
	fItemAssoc.close();
	ItemAssocFileOpen = false;

	// Optimize memory taken by all strings of all sheets
	ClientSheetsStrings.memoryCompress();

	return;
}// load //
开发者ID:mixxit,项目名称:solinia,代码行数:24,代码来源:sheet_manager.cpp

示例14: getUserDirectory

void	CMailForumService::openSession( uint32 shardid, string username, string cookie )
{
	string	sessionfile = getUserDirectory(shardid, username) + "session";
	string	checkmailfile = getUserDirectory(shardid, username) + "new_mails";

	COFile	ofile;
	if (ofile.open(sessionfile))
	{
		cookie += "\n";
		ofile.serialBuffer((uint8*)(&cookie[0]), (uint)cookie.size());
	}

	if (CFile::fileExists(checkmailfile))
	{
		CFile::deleteFile(checkmailfile);
		CMessage	msgout("MAIL_NOTIF");
		msgout.serial(shardid, username);
		CUnifiedNetwork::getInstance()->send("EGS", msgout);
	}
}
开发者ID:sythaeryn,项目名称:pndrpg,代码行数:20,代码来源:mail_forum_service.cpp

示例15: fileName

/*
 * Save State
 */
bool	CDatabaseState::save(CRefIndex& ref)
{
	COFile		f;
	COXml		oxml;

	string		filename = fileName(ref);

	if (!f.open(filename) || !oxml.init(&f))
		return false;

	try
	{
		serial(oxml);
	}
	catch (const Exception&)
	{
		return false;
	}

	return true;
}
开发者ID:Kiddinglife,项目名称:ryzom,代码行数:24,代码来源:pd_server_utils.cpp


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