2016-11-13 00:09:51 -05:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <mntent.h>
|
|
|
|
|
|
|
|
#include "common.hpp"
|
|
|
|
|
2016-11-19 00:22:44 -05:00
|
|
|
POLYBAR_NS
|
2016-11-13 00:09:51 -05:00
|
|
|
|
|
|
|
namespace mtab_util {
|
|
|
|
/**
|
|
|
|
* Wrapper for reading mtab entries
|
|
|
|
*/
|
|
|
|
class reader {
|
|
|
|
public:
|
|
|
|
explicit reader() {
|
|
|
|
if ((m_ptr = setmntent("/etc/mtab", "r")) == nullptr) {
|
|
|
|
throw system_error("Failed to read mtab");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
~reader() {
|
|
|
|
if (m_ptr != nullptr) {
|
|
|
|
endmntent(m_ptr);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
bool next(mntent** dst) {
|
|
|
|
return (*dst = getmntent(m_ptr)) != nullptr;
|
|
|
|
}
|
|
|
|
|
|
|
|
protected:
|
|
|
|
FILE* m_ptr = nullptr;
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2016-11-19 00:22:44 -05:00
|
|
|
POLYBAR_NS_END
|