Beispiel #1
0
bool FileLogger::Log(const gs2d::str_type::string& str, const TYPE& type) const
{
	#if defined(WIN32) || defined(APPLE_IOS) || defined(MACOSX)
	GS2D_COUT << str << std::endl;
	if (type == ERROR)
	{
		GS2D_CERR << GS_L("\x07");
	}
	#endif
	if (type == ERROR)
		WriteToErrorLog(str);
	else if (type == WARNING)
		WriteToWarningLog(str);

	#ifdef ANDROID
		switch (type)
		{
		case ERROR:
		case WARNING:
			LOGE(str.c_str());
			break;
		default:
			LOGI(str.c_str());
		}
	#endif
	return AppendToFile(m_fileName, str);
}
bool ETHBackBufferTargetManager::ComputeLength(gs2d::VideoPtr video, const gs2d::str_type::string& thisSide, const gs2d::str_type::string& otherSide, const bool isWidth)
{
	if (IsAuto(thisSide))
	{
		const gs2d::math::Vector2 screenSize(video->GetScreenSizeF());
		if (IsAuto(otherSide))
		{
			m_bufferSize = screenSize;
			return true;
		}
		else
		{
			float otherValue = -1.0f;
			ENML_SSCANF(otherSide.c_str(), GS_L("%f"), &otherValue);
			if (isWidth)
				m_bufferSize.x = ceilf(otherValue * (screenSize.x / screenSize.y));
			else
				m_bufferSize.y = ceilf(otherValue * (screenSize.y / screenSize.x));
			return false;
		}
	}
	else
	{
		int value = -1;
		ENML_SSCANF(thisSide.c_str(), GS_L("%i"), &value);
		if (isWidth)
			m_bufferSize.x = static_cast<float>(value);
		else
			m_bufferSize.y = static_cast<float>(value);
		return false;
	}
}
Beispiel #3
0
std::vector<gs2d::str_type::string> SplitString(gs2d::str_type::string str, const gs2d::str_type::string& c)
{
	std::vector<gs2d::str_type::string> v;
	std::size_t pos;
	while ((pos = str.find(c)) != gs2d::str_type::string::npos)
	{
		v.push_back(str.substr(0, pos));
		str = str.substr(pos + c.length(), gs2d::str_type::string::npos);
	}
	v.push_back(str);
	return v;
}
Beispiel #4
0
bool IsExtensionRight(const gs2d::str_type::string& fileName, const gs2d::str_type::string& ext)
{
	const std::size_t pos = fileName.rfind(ext);
	if (fileName.size() - pos == ext.size())
	{
		return true;
	}
	else
	{
		return false;
	}
}
Beispiel #5
0
bool FileManager::ConvertAnsiFileToUTF16LE(const gs2d::str_type::string& fileName)
{
	str_type::string content;
	if (!GetAnsiFileString(fileName, content))
	{
		return false;
	}

	const unsigned short utf16bom = 0xFEFF;
	str_type::ofstream ofs(fileName.c_str(), std::ios::out | std::ios::binary);
	if (ofs.is_open())
	{
		ofs.write((str_type::char_t*)&utf16bom, 2);

		const std::size_t length = content.length();
		for (std::size_t t = 0; t < length; t++)
		{
			ofs.write((str_type::char_t*)&content[t], 1);
			const char c = '\0';
			ofs.write((str_type::char_t*)&c, 1);
		}
		ofs.close();
		return true;
	}
	else
	{
		return false;
	}
}
Beispiel #6
0
FileLogger::FileLogger(const gs2d::str_type::string& fileName) : m_fileName(fileName)
{
	gs2d::str_type::ofstream ofs(fileName.c_str());
	if (ofs.is_open())
	{
		ofs << GS_L("[") << fileName << GS_L("]") << std::endl;
		ofs.close();
	}
}
Beispiel #7
0
bool AppendToFile(const gs2d::str_type::string& fileName, const gs2d::str_type::string& str)
{
	gs2d::str_type::ofstream ofs(fileName.c_str(), std::ios::out | std::ios::app);
	if (ofs.is_open())
	{
		ofs << str << std::endl;
		ofs.close();
		return true;
	}
	else
	{
		return false;
	}
}
Beispiel #8
0
bool StdFileManager::FileExists(const gs2d::str_type::string& fileName) const
{
	FILE* file = 0;
	errno_t err = _wfopen_s(&file, fileName.c_str(), L"rb");
	if (err || !file)
	{
		return false;
	}
	else
	{
		fclose(file);
		return true;
	}
}
Beispiel #9
0
gs2d::str_type::string AddLastSlash(const gs2d::str_type::string& path)
{
	if (path.empty())
	{
		return GS_L("");
	}
	gs2d::str_type::string r = (path);
	FixSlashes(r);
	const std::size_t lastChar = r.size()-1;

	if (r.at(lastChar) == GS_L('\\'))
	{
		r[lastChar] = GS_L('/');
		return r;
	}
	else if (r.at(lastChar) != GS_L('/'))
	{
		return r + GS_L("/");
	}
	else
	{
		return r;
	}
}
bool ETHBackBufferTargetManager::IsAuto(const gs2d::str_type::string& str)
{
	return (str == GS_L("auto") || str.empty());
}