Stroika Library 3.0d16
 
Loading...
Searching...
No Matches
Disk.h
Go to the documentation of this file.
1/*
2 * Copyright(c) Sophist Solutions, Inc. 1990-2025. All rights reserved
3 */
4#ifndef _Stroika_Foundation_IO_FileSystem_Disk_h_
5#define _Stroika_Foundation_IO_FileSystem_Disk_h_ 1
6
7#include "Stroika/Foundation/StroikaPreComp.h"
8
9#include <filesystem>
10#include <optional>
11
13#include "Stroika/Foundation/Common/Common.h"
14#include "Stroika/Foundation/Containers/KeyedCollection.h"
15
16/**
17 * \file
18 *
19 * \note Code-Status: <a href="Code-Status.md#Alpha">Alpha</a>
20 *
21 * TODO:
22 * @todo Underneath DiskInfoType - include partitions (which I think maybe like volumnes for windows - maybe not)
23 *
24 * @todo KeyedCollection<DiskInfoType> FileSystem::GetAvailableDisks ()
25 * for linux
26 * https://github.com/karelzak/util-linux/blob/master/misc-utils/lsblk.c
27 * iterate_block_devices
28 */
29
31
32 using Characters::String;
33
34 /**
35 * \note Common::DefaultNames<> supported
36 * \note These print names are mostly for display and debugging purposes, and they are not guaranteed to be safe for
37 * persistence (so be sure to version).
38 */
39 enum class BlockDeviceKind {
40 /**
41 * On Windoze, corresponds to https://msdn.microsoft.com/en-us/library/aa394173%28v=vs.85%29.aspx?f=255&MSPPError=-2147217396 "Removable Disk" or
42 * https://msdn.microsoft.com/en-us/library/windows/desktop/aa364939%28v=vs.85%29.aspx DRIVE_REMOVABLE
43 */
45
46 /**
47 * On Windoze, corresponds to https://msdn.microsoft.com/en-us/library/aa394173%28v=vs.85%29.aspx?f=255&MSPPError=-2147217396 "Local Disk" or
48 * https://msdn.microsoft.com/en-us/library/windows/desktop/aa364939%28v=vs.85%29.aspx DRIVE_FIXED
49 */
51
52 /**
53 * On Windoze, corresponds to https://msdn.microsoft.com/en-us/library/aa394173%28v=vs.85%29.aspx?f=255&MSPPError=-2147217396 "Network Drive" or
54 * https://msdn.microsoft.com/en-us/library/windows/desktop/aa364939%28v=vs.85%29.aspx DRIVE_REMOTE
55 */
57
58 /**
59 * On Windoze, corresponds to https://msdn.microsoft.com/en-us/library/aa394173%28v=vs.85%29.aspx?f=255&MSPPError=-2147217396 "RAM Disk" or
60 * https://msdn.microsoft.com/en-us/library/windows/desktop/aa364939%28v=vs.85%29.aspx DRIVE_RAMDISK
61 * On Linux, this is tmpfs
62 */
64
65 /**
66 * On Windoze, corresponds to https://msdn.microsoft.com/en-us/library/aa394173%28v=vs.85%29.aspx?f=255&MSPPError=-2147217396 "Compact Disc" or
67 * https://msdn.microsoft.com/en-us/library/windows/desktop/aa364939%28v=vs.85%29.aspx DRIVE_CDROM
68 */
70
71 /**
72 * e.g. Linux procfs
73 */
75
77 };
78
79 /**
80 * Information for a physical disk (not for a partition).
81 */
82 struct DiskInfoType {
83 // DeviceName was string until Stroika v2.1b2, but then switched to path (hope thats right)??? --LGP 2020-06/30
84 filesystem::path fDeviceName;
85
86 /*
87 * Is the 'disk' a 'remote' device (network), CD-ROM, direct-attached hard disk (e.g. internal) or removable drive,
88 */
89 optional<BlockDeviceKind> fDeviceKind;
90
91 /*
92 * This is the size of the physical block device. All the filesystems must fit in it.
93 */
94 optional<uint64_t> fSizeInBytes;
95
96 /**
97 * @see Characters::ToString ();
98 */
99 nonvirtual String ToString () const;
100 };
101
102 /**
103 * Fetch all the available disks (DiskInfoType) installed on the system, keyed by fDeviceName
104 */
106
107}
108
109/*
110 ********************************************************************************
111 ***************************** Implementation Details ***************************
112 ********************************************************************************
113 */
114#include "Disk.inl"
115
116#endif /*_Stroika_Foundation_IO_FileSystem_Disk_h_*/
#define Stroika_Define_Enum_Bounds(FIRST_ITEM, LAST_ITEM)
String is like std::u32string, except it is much easier to use, often much more space efficient,...
Definition String.h:201
a cross between Mapping<KEY, T> and Collection<T> and Set<T>
Containers::KeyedCollection< DiskInfoType, filesystem::path > GetAvailableDisks()
Definition Disk.cpp:222