| 1 |
/* gtkmm example Copyright (C) 2002 gtkmm development team |
| 2 |
* |
| 3 |
* This program is free software; you can redistribute it and/or modify |
| 4 |
* it under the terms of the GNU General Public License as published by |
| 5 |
* the Free Software Foundation; either version 2 of the License, or |
| 6 |
* (at your option) any later version. |
| 7 |
* |
| 8 |
* This program is distributed in the hope that it will be useful, |
| 9 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 10 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 11 |
* GNU General Public License for more details. |
| 12 |
* |
| 13 |
* You should have received a copy of the GNU General Public License along |
| 14 |
* with this program; if not, see <https://www.gnu.org/licenses/>. |
| 15 |
*/ |
| 16 |
|
| 17 |
#include <giomm.h> |
| 18 |
#include <iostream> |
| 19 |
|
| 20 |
|
| 21 |
int main(int /* argc */, char** /* argv */) |
| 22 |
{ |
| 23 |
Gio::init(); |
| 24 |
|
| 25 |
try |
| 26 |
{ |
| 27 |
auto directory = Gio::File::create_for_path("/etc"); |
| 28 |
if(!directory) |
| 29 |
std::cerr << "Gio::File::create_for_path() returned an empty RefPtr." << std::endl; |
| 30 |
|
| 31 |
auto enumerator = directory->enumerate_children(); |
| 32 |
if(!enumerator) |
| 33 |
std::cerr << "Gio::File::enumerate_children() returned an empty RefPtr." << std::endl; |
| 34 |
|
| 35 |
auto file_info = enumerator->next_file(); |
| 36 |
while(file_info) |
| 37 |
{ |
| 38 |
std::cout << "file: " << file_info->get_name() << std::endl; |
| 39 |
file_info = enumerator->next_file(); |
| 40 |
} |
| 41 |
|
| 42 |
} |
| 43 |
catch(const Glib::Error& ex) |
| 44 |
{ |
| 45 |
std::cerr << "Exception caught: " << ex.what() << std::endl; |
| 46 |
} |
| 47 |
|
| 48 |
|
| 49 |
return 0; |
| 50 |
} |
| 51 |
|