summaryrefslogtreecommitdiff
path: root/diskman/partition.hh
blob: 8e6274bdd1322e7f21233bf497b2dc80db152358 (plain) (blame)
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
/*
 * partition.hh - Definition of the Partition class
 * diskman, the Disk Manipulation library for
 * Project Horizon
 *
 * Copyright (c) 2020 Adélie Linux and contributors.  All rights reserved.
 * This code is licensed under the AGPL 3.0 license, as noted in the
 * LICENSE-code file in the root directory of this repository.
 *
 * SPDX-License-Identifier: AGPL-3.0-only
 */

#ifndef DISKMAN__PARTITION_HH
#define DISKMAN__PARTITION_HH

#include <cstdint>
#include <string>

namespace Horizon {
namespace DiskMan {

class Disk;

class Partition {
public:
    /*! Retrieve the size of the partition in bytes. */
    uint64_t size() const { return this->_size; };
    /*! Retrieve the file system type of this partition. */
    const std::string fstype() const { return this->_fs_type; }
    /*! Retrieve the label of the file system on this partition. */
    const std::string label() const { return this->_label; }
    /*! Retrieve the device node of this partition (for example, /dev/sda1). */
    const std::string node() const { return this->_node; }
private:
    /*! The size of the partition, in bytes. */
    uint64_t _size;
    /*! The type of the file system on this partition (if any) */
    std::string _fs_type;
    /*! The label of the file system on this partition (if any) */
    std::string _label;
    /*! The device node of this partition. */
    std::string _node;
    Partition(Disk &d, void *creation, int type);
    friend class Disk;
};

}
}

#endif  /* !DISKMAN__PARTITION_HH */