File indexing completed on 2024-04-28 04:21:24
0001 /* SPDX-FileCopyrightText: 2003-2019 The KPhotoAlbum Development Team 0002 0003 SPDX-License-Identifier: GPL-2.0-or-later 0004 */ 0005 0006 #include "FileUtil.h" 0007 0008 #include <QDir> 0009 #include <QFileInfo> 0010 0011 extern "C" { 0012 #include <unistd.h> 0013 } 0014 0015 bool Utilities::copyOrOverwrite(const QString &from, const QString &to) 0016 { 0017 if (QFileInfo::exists(to)) 0018 QDir().remove(to); 0019 return QFile::copy(from, to); 0020 } 0021 0022 bool Utilities::makeHardLink(const QString &from, const QString &to) 0023 { 0024 if (link(from.toLocal8Bit().constData(), to.toLocal8Bit().constData()) != 0) 0025 return false; 0026 else 0027 return true; 0028 } 0029 0030 bool Utilities::makeSymbolicLink(const QString &from, const QString &to) 0031 { 0032 if (symlink(from.toLocal8Bit().constData(), to.toLocal8Bit().constData()) != 0) 0033 return false; 0034 else 0035 return true; 0036 } 0037 0038 // vi:expandtab:tabstop=4 shiftwidth=4: