Ejemplo n.º 1
0
bool FileUtils::copyFile(const QString& srcFile, const QString& destFile)
{
	QString srcFullPath = getFullPath(srcFile);
	QString dstFullPath = getFullPath(destFile);
	if(!existsFullPath(srcFullPath)) return false;
	if(!srcFullPath.compare(dstFullPath, Qt::CaseInsensitive)) return true;
	QFileInfo fileInfo(dstFullPath);
	if(!fileInfo.exists())	
	{
		makePath(fileInfo.path());
	}
	else if(existsFullPath(dstFullPath)) 
	{
		QFile::remove(dstFullPath);
	}
	return QFile::copy(srcFullPath, dstFullPath);
}
Ejemplo n.º 2
0
bool FileUtils::checkExists(const QString &fileName)
{
	if (!existsFullPath(fileName))
	{
		QString error = QString("文件不存在:%0").arg(fileName);
		//context()->throwError(error);
		return false;
	}
	return true;
}
Ejemplo n.º 3
0
void FileUtils::copyFile(const QString &src, const QString &dst)
{
	if (existsFullPath(dst))
	{
		QFile::remove(dst);
	}
	bool isSucceed = QFile::copy(src, dst);
	if (!isSucceed)
	{
		//context()->throwError("保存模板文件失败");
	}
}
Ejemplo n.º 4
0
QString FileUtils::readAllText(const QString &fileName)
{
	QString fullPath = getFullPath(fileName);
	if(existsFullPath(fullPath)) return readAllTextFullPath(fullPath);
	return "";
}
Ejemplo n.º 5
0
bool FileUtils::exists(const QString& fileName)
{
	QString newFileName = getFullPath(fileName);
	return existsFullPath(newFileName);
}