From 07a2de27b57848789171dee2559e4bd78d0e921c Mon Sep 17 00:00:00 2001 From: "A. Wilcox" Date: Mon, 21 Oct 2019 01:36:47 -0500 Subject: hscript: Implement DiskLabel, add tests --- hscript/disk.hh | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) (limited to 'hscript/disk.hh') diff --git a/hscript/disk.hh b/hscript/disk.hh index 02ecb98..f8a9574 100644 --- a/hscript/disk.hh +++ b/hscript/disk.hh @@ -37,6 +37,31 @@ public: }; class DiskLabel : public Key { +public: + /*! The type of disklabel. */ + enum LabelType { + /*! Apple Partition Map (APM) */ + APM, + /*! Master Boot Record (MBR) */ + MBR, + /*! GUID Partition Table (GPT) */ + GPT + }; +private: + const std::string _block; + const LabelType _type; + + DiskLabel(int _line, const std::string &_b, const LabelType &_t) : + Key(_line), _block(_b), _type(_t) {} +public: + /*! Retrieve the block device that this key identifies. */ + const std::string device() const { return this->_block; } + /*! Retrieve the type of disklabel for the block device. */ + const LabelType type() const { return this->_type; } + + static Key *parseFromData(const std::string &, int, int*, int*); + bool validate(ScriptOptions) const override; + bool execute(ScriptOptions) const override; }; class Partition : public Key { -- cgit v1.2.3-60-g2f50