/* * Copyright (c) 1998 Denis Perchine * Copyright (c) 2004 Szombathelyi György * Former maintainer: Adriaan de Groot * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public * License version 2 or at your option version 3 as published by * the Free Software Foundation. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Library General Public License for more details. * * You should have received a copy of the GNU Library General Public License * along with this library; see the file COPYING.LIB. If not, write to * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, * Boston, MA 02110-1301, USA. **/ #include "globals.h" #include #ifdef HAVE_SYS_STAT_H #include #endif #include #include #ifdef HAVE_UNISTD_H #include #endif #ifdef HAVE_CRYPT_H #include #endif #include #include #include #include #include #include #include "ku_misc.h" bool backup(const QString & name) { QString tmp = name + QString::fromLatin1(KU_BACKUP_EXT); QFile::remove( tmp ); if (copyFile(QLatin1String( QFile::encodeName(name) ), QLatin1String( QFile::encodeName(tmp) )) == -1) { QString str; KMessageBox::error( 0, i18n("Can not create backup file for %1", name) ); return false; } return true; } time_t now() { struct timeval tv; gettimeofday( &tv, NULL ); return ( tv.tv_sec ); } void copyDir(const QString &srcPath, const QString &dstPath, uid_t uid, gid_t gid) { mode_t mode; QDir s(srcPath); QDir d(dstPath); QString dot = QString::fromLatin1("."); QString dotdot = QString::fromLatin1(".."); s.setFilter( QDir::AllEntries | QDir::Hidden | QDir::System ); for (uint i=0; i