Back to index

lshw  02.16
osutils.h
Go to the documentation of this file.
00001 #ifndef _OSUTILS_H_
00002 #define _OSUTILS_H_
00003 
00004 #include <string>
00005 #include <vector>
00006 #include <sys/types.h>
00007 #include <stdint.h>
00008 
00009 bool pushd(const std::string & dir = "");
00010 std::string popd();
00011 std::string pwd();
00012 
00013 bool exists(const std::string & path);
00014 bool samefile(const std::string & path1, const std::string & path2);
00015 std::string readlink(const std::string & path);
00016 std::string realpath(const std::string & path);
00017 bool loadfile(const std::string & file, std::vector < std::string > &lines);
00018 
00019 size_t splitlines(const std::string & s,
00020 std::vector < std::string > &lines,
00021 char separator = '\n');
00022 std::string get_string(const std::string & path, const std::string & def = "");
00023 long get_number(const std::string & path, long def = 0);
00024 
00025 std::string find_deventry(mode_t mode, dev_t device);
00026 std::string get_devid(const std::string &);
00027 
00028 std::string uppercase(const std::string &);
00029 std::string lowercase(const std::string &);
00030 std::string tostring(unsigned long long);
00031 std::string tohex(unsigned long long);
00032 std::string utf8(wchar_t);
00033 std::string utf8_sanitize(const std::string &);
00034 std::string utf8(uint16_t *s, ssize_t length = -1, bool forcelittleendian = false);
00035 
00036 std::string spaces(unsigned int count, const std::string & space = " ");
00037 
00038 std::string escape(const std::string &);
00039 std::string escapeJSON(const std::string &);
00040 std::string escapecomment(const std::string &);
00041 
00042 std::string join(const std::string &, const std::string &, const std::string &);
00043 
00044 std::string decimalkilos(unsigned long long value);
00045 std::string kilobytes(unsigned long long value);
00046 
00047 bool matches(const std::string & s, const std::string & pattern, int cflags=0);
00048 
00049 int selectdir(const struct dirent *d);
00050 int selectlink(const struct dirent *d);
00051 int selectfile(const struct dirent *d);
00052 
00053 unsigned short be_short(const void *);
00054 unsigned short le_short(const void *);
00055 unsigned long be_long(const void *);
00056 unsigned long le_long(const void *);
00057 unsigned long long be_longlong(const void *);
00058 unsigned long long le_longlong(const void *);
00059 
00060 int open_dev(dev_t dev, const std::string & name="");
00061 
00062 std::string platform();
00063 std::string operating_system();
00064 #endif