1 /*
2  * Copyright 2003-2021 The Music Player Daemon Project
3  * http://www.musicpd.org
4  *
5  * This program is free software; you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License as published by
7  * the Free Software Foundation; either version 2 of the License, or
8  * (at your option) any later version.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License along
16  * with this program; if not, write to the Free Software Foundation, Inc.,
17  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
18  */
19 
20 #ifndef MPD_STORAGE_FILE_INFO_HXX
21 #define MPD_STORAGE_FILE_INFO_HXX
22 
23 #include <chrono>
24 
25 #include <cstdint>
26 
27 struct StorageFileInfo {
28 	enum class Type : uint8_t {
29 		OTHER,
30 		REGULAR,
31 		DIRECTORY,
32 	};
33 
34 	Type type;
35 
36 	/**
37 	 * The file size in bytes.  Only valid for #Type::REGULAR.
38 	 */
39 	uint64_t size;
40 
41 	/**
42 	 * The modification time.  A negative value means unknown /
43 	 * not applicable.
44 	 */
45 	std::chrono::system_clock::time_point mtime;
46 
47 	/**
48 	 * Device id and inode number.  0 means unknown / not
49 	 * applicable.
50 	 */
51 	uint64_t device, inode;
52 
53 	StorageFileInfo() = default;
54 
StorageFileInfoStorageFileInfo55 	explicit constexpr StorageFileInfo(Type _type)
56 		:type(_type),
57 		 size(0),
58 		 mtime(std::chrono::system_clock::time_point::min()),
59 		 device(0), inode(0) {}
60 
IsRegularStorageFileInfo61 	constexpr bool IsRegular() const {
62 		return type == Type::REGULAR;
63 	}
64 
IsDirectoryStorageFileInfo65 	constexpr bool IsDirectory() const {
66 		return type == Type::DIRECTORY;
67 	}
68 };
69 
70 #endif
71