blob: d2d104d52e66f4c4d6c9d4494a530c17bd34c6b2 (
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
|
// *****************************************************************************
// * This file is part of the FreeFileSync project. It is distributed under *
// * GNU General Public License: https://www.gnu.org/licenses/gpl-3.0 *
// * Copyright (C) Zenju (zenju AT freefilesync DOT org) - All Rights Reserved *
// *****************************************************************************
#ifndef FILE_ID_DEF_H_013287632486321493
#define FILE_ID_DEF_H_013287632486321493
#include <sys/stat.h>
namespace zen
{
namespace impl { typedef struct ::stat StatDummy; } //sigh...
using VolumeId = decltype(impl::StatDummy::st_dev);
using FileIndex = decltype(impl::StatDummy::st_ino);
struct FileId //always available on Linux, and *generally* available on Windows)
{
FileId() {}
FileId(VolumeId volId, FileIndex fIdx) : volumeId(volId), fileIndex(fIdx)
{
if (volId == 0 || fIdx == 0)
{
volumeId = 0;
fileIndex = 0;
}
}
VolumeId volumeId = 0;
FileIndex fileIndex = 0;
bool operator==(const FileId&) const = default;
};
inline
FileId generateFileId(const struct ::stat& fileInfo)
{
return FileId(fileInfo.st_dev, fileInfo.st_ino);
}
}
#endif //FILE_ID_DEF_H_013287632486321493
|