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); }
bool FileUtils::checkExists(const QString &fileName) { if (!existsFullPath(fileName)) { QString error = QString("文件不存在:%0").arg(fileName); //context()->throwError(error); return false; } return true; }
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("保存模板文件失败"); } }
QString FileUtils::readAllText(const QString &fileName) { QString fullPath = getFullPath(fileName); if(existsFullPath(fullPath)) return readAllTextFullPath(fullPath); return ""; }
bool FileUtils::exists(const QString& fileName) { QString newFileName = getFullPath(fileName); return existsFullPath(newFileName); }