예제 #1
0
ExpressionValue expFuncRead(const std::vector<ExpressionValue>& parameters)
{
	ExpressionValue result;
	T buffer;

	if (parameters[0].isString() == false || (parameters.size() >= 2 && parameters[1].isInt() == false))
	{
		Logger::queueError(Logger::Error,L"Invalid parameter");
		return result;
	}

	std::wstring fileName = getFullPathName(parameters[0].strValue);
	u64 pos = parameters.size() >= 2 ? parameters[1].intValue : 0;

	BinaryFile file;
	if (file.open(fileName,BinaryFile::Read) == false)
	{
		Logger::queueError(Logger::Error,L"Could not open %s",fileName);
		return result;
	}

	file.setPos((long)pos);

	if (file.read(&buffer,sizeof(T)) == sizeof(T))
	{
		result.type = ExpressionValueType::Integer;
		result.intValue = (u64) buffer;
	}

	return result;
}
예제 #2
0
ExpressionValue expFuncRead(const std::wstring& funcName, const std::vector<ExpressionValue>& parameters)
{
	const std::wstring* fileName;
	u64 pos;

	GET_PARAM(parameters,0,fileName);
	GET_OPTIONAL_PARAM(parameters,1,pos,0);

	std::wstring fullName = getFullPathName(*fileName);

	BinaryFile file;
	if (file.open(fullName,BinaryFile::Read) == false)
	{
		Logger::queueError(Logger::Error,L"Could not open %s",fileName);
		return ExpressionValue();
	}

	file.setPos((long)pos);

	T buffer;
	if (file.read(&buffer,sizeof(T)) != sizeof(T))
		return ExpressionValue();

	return ExpressionValue((u64) buffer);
}