示例#1
0
文件: XML.cpp 项目: xcyanx/Ptyxiakh
XML::~XML()
{
	maFileClose(file);

	file = XML::file = maFileOpen(fname.c_str(), MA_ACCESS_READ_WRITE);

	maFileSeek(file, 0, MA_SEEK_END);

	CloseRoot();
	maFileClose(file);

	delete _ActivityIndicator;
}
示例#2
0
	/**
	 * @return >0 on success, <0 on error.
	 */
	static int FileWrite(const String& path, const String& data, int position)
	{
		MAHandle file = maFileOpen(path.c_str(), MA_ACCESS_READ_WRITE);	if (file < 0)
		{
			return -1;
		}

		// TODO: Now we assume file must exist. Is that ok?
		//int exists = maFileExists(file);

		// TODO: Should we check that position is within file size?
		// int size = maFileSize(file);

		// If we start writing from the beginning of the file, we truncate
		// the file. Not clear what the specification says about this.
		// TODO: Check how this should work! It makes no sense to truncate here.
	//	if (position == 0)
	//	{
	//		maFileTruncate(file, 0);
	//	}

		int result = maFileSeek(file, position, MA_SEEK_SET);

		// New position must equal requested position.
		if (result != position)
		{
			return -1;
		}

		result = maFileWrite(file, data.c_str(), data.size());
		if (result < 0)
		{
			return -1;
		}

		maFileClose(file);

		return 1;
	}