You can find the following code in the tarball (subdirectory test/):
Example 1:
Opens the device /dev/hda and prints the disktype name.
using namespace std;
int main(int argc, char **argv) {
Ped::Device *test = new Ped::Device("/dev/hda");
Ped::Disk disk(*test);
cout << "Disk type is: " << disk.get_disktype().get_name() << endl;
delete test;
return 0;
}
Example 2:
Basically does the same as in example 1, but lets you specify the
device. If a bad device is entered the device constructor throws an
exception which can be catched.
std::string s;
std::cout << "Enter device path: ";
std::cin >> s;
try {
Ped::Device test(s);
Ped::Disk disk(test);
std::cout << "Disk type is: " << disk.get_disktype().get_name() << std::endl;
}
catch (runtime_error &e) {
std::cout << e.what() << std::endl;
}
|