2014-02-18 15:54:40 +04:00
|
|
|
/*
|
|
|
|
* Copyright (C) by Olivier Goffart <ogoffart@owncloud.com>
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
2016-10-25 12:00:07 +03:00
|
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
|
|
* (at your option) any later version.
|
2014-02-18 15:54:40 +04:00
|
|
|
*
|
|
|
|
* This program 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 General Public License
|
|
|
|
* for more details.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
2015-05-20 22:42:08 +03:00
|
|
|
#include "config.h"
|
|
|
|
|
2014-02-18 15:54:40 +04:00
|
|
|
#include <QString>
|
|
|
|
#include <ctime>
|
|
|
|
|
2014-07-11 00:58:58 +04:00
|
|
|
#include <owncloudlib.h>
|
2017-08-30 20:34:41 +03:00
|
|
|
// Chain in the base include and extend the namespace
|
|
|
|
#include "common/filesystembase.h"
|
2014-07-11 00:58:58 +04:00
|
|
|
|
2015-02-25 12:51:05 +03:00
|
|
|
class QFile;
|
|
|
|
|
2014-11-10 00:34:07 +03:00
|
|
|
namespace OCC {
|
2014-02-18 15:54:40 +04:00
|
|
|
|
2018-05-22 12:49:02 +03:00
|
|
|
class SyncJournal;
|
|
|
|
|
2015-06-29 19:56:09 +03:00
|
|
|
/**
|
2015-06-26 18:07:47 +03:00
|
|
|
* \addtogroup libsync
|
|
|
|
* @{
|
2014-02-18 15:54:40 +04:00
|
|
|
*/
|
|
|
|
|
2015-06-26 18:07:47 +03:00
|
|
|
/**
|
2015-06-29 19:56:09 +03:00
|
|
|
* @brief This file contains file system helper
|
2015-06-26 18:07:47 +03:00
|
|
|
*/
|
2014-02-18 15:54:40 +04:00
|
|
|
namespace FileSystem {
|
|
|
|
|
2015-06-29 19:56:09 +03:00
|
|
|
/**
|
2018-05-22 11:40:45 +03:00
|
|
|
* @brief compare two files with given filename and return true if they have the same content
|
|
|
|
*/
|
2014-02-18 15:54:40 +04:00
|
|
|
bool fileEquals(const QString &fn1, const QString &fn2);
|
|
|
|
|
2015-06-29 19:56:09 +03:00
|
|
|
/**
|
2018-05-22 11:40:45 +03:00
|
|
|
* @brief Get the mtime for a filepath
|
|
|
|
*
|
|
|
|
* Use this over QFileInfo::lastModified() to avoid timezone related bugs. See
|
|
|
|
* owncloud/core#9781 for details.
|
|
|
|
*/
|
2015-02-25 12:51:05 +03:00
|
|
|
time_t OWNCLOUDSYNC_EXPORT getModTime(const QString &filename);
|
2014-09-04 13:20:41 +04:00
|
|
|
|
2017-02-07 21:31:55 +03:00
|
|
|
bool OWNCLOUDSYNC_EXPORT setModTime(const QString &filename, time_t modTime);
|
2014-02-18 15:54:40 +04:00
|
|
|
|
2015-06-29 19:56:09 +03:00
|
|
|
/**
|
2018-05-22 11:40:45 +03:00
|
|
|
* @brief Get the size for a file
|
|
|
|
*
|
|
|
|
* Use this over QFileInfo::size() to avoid bugs with lnk files on Windows.
|
|
|
|
* See https://bugreports.qt.io/browse/QTBUG-24831.
|
|
|
|
*/
|
2015-02-12 13:02:56 +03:00
|
|
|
qint64 OWNCLOUDSYNC_EXPORT getSize(const QString &filename);
|
2015-02-25 12:51:05 +03:00
|
|
|
|
2015-06-29 19:56:09 +03:00
|
|
|
/**
|
2018-05-22 11:40:45 +03:00
|
|
|
* @brief Check if \a fileName has changed given previous size and mtime
|
|
|
|
*
|
|
|
|
* Nonexisting files are covered through mtime: they have an mtime of -1.
|
|
|
|
*
|
|
|
|
* @return true if the file's mtime or size are not what is expected.
|
|
|
|
*/
|
2016-06-03 14:28:44 +03:00
|
|
|
bool OWNCLOUDSYNC_EXPORT fileChanged(const QString &fileName,
|
|
|
|
qint64 previousSize,
|
|
|
|
time_t previousMtime);
|
2015-05-07 12:41:29 +03:00
|
|
|
|
2015-06-29 19:56:09 +03:00
|
|
|
/**
|
2018-05-22 11:40:45 +03:00
|
|
|
* @brief Like !fileChanged() but with verbose logging if the file *did* change.
|
|
|
|
*/
|
2015-05-07 12:41:29 +03:00
|
|
|
bool verifyFileUnchanged(const QString &fileName,
|
|
|
|
qint64 previousSize,
|
|
|
|
time_t previousMtime);
|
2018-05-22 12:49:02 +03:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Removes a directory and its contents recursively
|
|
|
|
*
|
|
|
|
* Returns true if all removes succeeded.
|
|
|
|
* onDeleted() is called for each deleted file or directory, including the root.
|
|
|
|
* errors are collected in errors.
|
|
|
|
*/
|
|
|
|
bool OWNCLOUDSYNC_EXPORT removeRecursively(const QString &path,
|
|
|
|
const std::function<void(const QString &path, bool isDir)> &onDeleted = nullptr,
|
|
|
|
QStringList *errors = nullptr);
|
2015-06-26 18:07:47 +03:00
|
|
|
}
|
|
|
|
|
2015-06-29 19:56:09 +03:00
|
|
|
/** @} */
|
2015-06-26 18:07:47 +03:00
|
|
|
}
|