blob: 80b2591f711e89e05ee2cd9e43779f391c9b22ad (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
|
/*
* 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
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* 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
#include "config.h"
#include <QString>
#include <ctime>
#include <functional>
#include <owncloudlib.h>
// Chain in the base include and extend the namespace
#include "common/filesystembase.h"
class QFile;
namespace OCC {
class SyncJournal;
/**
* \addtogroup libsync
* @{
*/
/**
* @brief This file contains file system helper
*/
namespace FileSystem {
/**
* @brief compare two files with given filename and return true if they have the same content
*/
bool fileEquals(const QString &fn1, const QString &fn2);
/**
* @brief Get the mtime for a filepath
*
* Use this over QFileInfo::lastModified() to avoid timezone related bugs. See
* owncloud/core#9781 for details.
*/
time_t OWNCLOUDSYNC_EXPORT getModTime(const QString &filename);
bool OWNCLOUDSYNC_EXPORT setModTime(const QString &filename, time_t modTime);
/**
* @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.
*/
qint64 OWNCLOUDSYNC_EXPORT getSize(const QFileInfo &info);
/**
* @brief Retrieve a file inode with csync
*/
bool OWNCLOUDSYNC_EXPORT getInode(const QString &filename, quint64 *inode);
/**
* @brief Check if \a fileName has changed given previous size and mtime
*
* Nonexisting files are covered through mtime: they have an previousMtime of -1.
*
* @return true if the file's mtime or size are not what is expected.
*/
bool OWNCLOUDSYNC_EXPORT fileChanged(const QFileInfo &info,
qint64 previousSize,
time_t previousMtime);
struct RemoveEntry
{
const QString path;
const bool isDir;
};
struct RemoveError
{
const RemoveEntry entry;
const QString error;
};
using RemoveEntryList = std::vector<RemoveEntry>;
using RemoveErrorList = std::vector<RemoveError>;
/**
* Removes a directory and its contents recursively
*
* Returns true if all removes succeeded.
*/
bool OWNCLOUDSYNC_EXPORT removeRecursively(const QString &path,
RemoveEntryList *success,
RemoveEntryList *locked,
RemoveErrorList *errors);
}
/** @} */
}
|