19 #if defined(Q_OS_WIN32)
31 touch_file(
const QString &filename,
bool createdir, QString *errmsg)
39 if (createdir && !
create_path(QFileInfo(expanded).absolutePath())) {
45 if (!QFileInfo(expanded).exists()) {
46 if (!file.open(QIODevice::WriteOnly)) {
47 return err(errmsg, file.errorString());
59 if (!dir.mkpath(dir.absolutePath())) {
70 copy_dir(
const QString &source,
const QString &dest)
77 QFileInfoList contents = src.entryInfoList(QDir::Files | QDir::Dirs
78 | QDir::NoDotAndDotDot);
81 foreach (QFileInfo fileInfo, contents) {
83 QString fileName = fileInfo.fileName();
84 QString srcFilePath = src.absoluteFilePath(fileName);
85 QString dstFilePath = dst.absoluteFilePath(fileName);
87 if (fileInfo.isDir()) {
89 if (!dst.mkdir(fileName))
91 if (!
copy_dir(srcFilePath, dstFilePath))
93 }
else if (fileInfo.isFile()) {
95 if (!QFile::copy(srcFilePath, dstFilePath))
110 QString fname = filename;
111 #if defined(Q_OS_WIN32)
112 if (fname.startsWith(
"%APPDATA%\\") ||
113 fname.startsWith(
"%APPDATA%/"))
116 if (fname.startsWith(
"%PROGRAMFILES%\\") ||
117 fname.startsWith(
"%PROGRAMFILES%/"))
120 if (fname.startsWith(
"~/"))
121 return fname.replace(0, 1, QDir::homePath());
bool touch_file(const QString &filename, bool createdir, QString *errmsg)
QString expand_filename(const QString &filename)
bool err(QString *str, const QString &errmsg)
bool create_path(const QString &path)
QString win32_program_files_folder()
bool copy_dir(const QString &source, const QString &dest)
QString win32_app_data_folder()