Mercurial > dedupe
comparison DataController.cpp @ 106:95fb1bcf7e24
Constant for turning follow symlinks on and off.
| author | Tom Fredrik Blenning Klaussen <bfg@bfgconsult.no> |
|---|---|
| date | Tue, 18 Feb 2014 17:05:48 +0100 |
| parents | 6bc013d5788b |
| children |
comparison
equal
deleted
inserted
replaced
| 105:0df1552123e7 | 106:95fb1bcf7e24 |
|---|---|
| 25 | 25 |
| 26 #include <boost/filesystem.hpp> | 26 #include <boost/filesystem.hpp> |
| 27 | 27 |
| 28 void DataController::findFiles(const QDir& dir, QStringList& list) | 28 void DataController::findFiles(const QDir& dir, QStringList& list) |
| 29 { | 29 { |
| 30 const bool FOLLOW_SYMLINKS = false; | |
| 30 #if USE_BOOST_FIND | 31 #if USE_BOOST_FIND |
| 31 namespace fs = boost::filesystem; | 32 namespace fs = boost::filesystem; |
| 32 fs::path someDir(dir.path().toStdString()); | 33 fs::path someDir(dir.path().toStdString()); |
| 33 fs::directory_iterator end_iter; | 34 fs::directory_iterator end_iter; |
| 34 boost::system::error_code ec; | 35 boost::system::error_code ec; |
| 43 catch (boost::system::system_error &e) { | 44 catch (boost::system::system_error &e) { |
| 44 printf("%s\n", dir_iter->path().c_str()); | 45 printf("%s\n", dir_iter->path().c_str()); |
| 45 std::cout << e.what() << std::endl; | 46 std::cout << e.what() << std::endl; |
| 46 } | 47 } |
| 47 if (!wpath.empty()) { | 48 if (!wpath.empty()) { |
| 48 if (fs::is_directory(dir_iter->status()) ) { | 49 if (fs::is_directory(FOLLOW_SYMLINKS? |
| 50 dir_iter->status(): | |
| 51 dir_iter->symlink_status()) | |
| 52 ) { | |
| 49 findFiles(QString::fromStdWString(wpath), list); | 53 findFiles(QString::fromStdWString(wpath), list); |
| 50 } | 54 } |
| 51 if (fs::is_regular_file(dir_iter->symlink_status()) ) { | 55 else if (fs::is_regular_file(dir_iter->symlink_status()) ) { |
| 52 list << QString::fromStdWString(wpath); | 56 list << QString::fromStdWString(wpath); |
| 53 } | 57 } |
| 54 } | 58 } |
| 55 } | 59 } |
| 56 } | 60 } |
