diff options
author | A. Wilcox <AWilcox@Wilcox-Tech.com> | 2019-11-01 22:33:30 -0500 |
---|---|---|
committer | A. Wilcox <AWilcox@Wilcox-Tech.com> | 2019-11-01 22:33:30 -0500 |
commit | 05cc72e4f79128ae8c228a638f50963ff9508a9f (patch) | |
tree | b0bd0297506520deffdb954180d05928a7d4fee7 /hscript | |
parent | 810000aff2404c2e602217fdd8ed2a2448a48133 (diff) | |
download | horizon-05cc72e4f79128ae8c228a638f50963ff9508a9f.tar.gz horizon-05cc72e4f79128ae8c228a638f50963ff9508a9f.tar.bz2 horizon-05cc72e4f79128ae8c228a638f50963ff9508a9f.tar.xz horizon-05cc72e4f79128ae8c228a638f50963ff9508a9f.zip |
hscript: Use enumeration for Filesystem::fstype
Diffstat (limited to 'hscript')
-rw-r--r-- | hscript/disk.cc | 17 | ||||
-rw-r--r-- | hscript/disk.hh | 15 |
2 files changed, 28 insertions, 4 deletions
diff --git a/hscript/disk.cc b/hscript/disk.cc index 31143cc..91c766f 100644 --- a/hscript/disk.cc +++ b/hscript/disk.cc @@ -733,6 +733,7 @@ Key *Filesystem::parseFromData(const std::string &data, int lineno, std::string::size_type sep = data.find(' '); std::string device(data.substr(0, sep)); std::string fstype(data.substr(sep + 1)); + FilesystemType type; if(device.size() < 6 || device.compare(0, 5, "/dev/")) { if(errors) *errors += 1; @@ -753,7 +754,21 @@ Key *Filesystem::parseFromData(const std::string &data, int lineno, return nullptr; } - return new Filesystem(lineno, device, fstype); + if(fstype == "ext2") { + type = Ext2; + } else if(fstype == "ext3") { + type = Ext3; + } else if(fstype == "ext4") { + type = Ext4; + } else if(fstype == "jfs") { + type = JFS; + } else if(fstype == "vfat") { + type = VFAT; + } else { + type = XFS; + } + + return new Filesystem(lineno, device, type); } bool Filesystem::validate(ScriptOptions) const { diff --git a/hscript/disk.hh b/hscript/disk.hh index 7722780..2a43192 100644 --- a/hscript/disk.hh +++ b/hscript/disk.hh @@ -185,17 +185,26 @@ public: }; class Filesystem : public Key { +public: + enum FilesystemType { + Ext2, + Ext3, + Ext4, + JFS, + VFAT, + XFS + }; private: const std::string _block; - const std::string _type; + FilesystemType _type; - Filesystem(int _line, const std::string &_b, const std::string &_t) : + Filesystem(int _line, const std::string &_b, FilesystemType _t) : Key(_line), _block(_b), _type(_t) {} public: /*! Retrieve the block device on which to create the filesystem. */ const std::string device() const { return this->_block; } /*! Retreive the type of filesystem to create. */ - const std::string fstype() const { return this->_type; } + FilesystemType fstype() const { return this->_type; } static Key *parseFromData(const std::string &, int, int*, int*); bool validate(ScriptOptions) const override; |