|
Boost Users : |
Subject: Re: [Boost-users] questions about recursing a directory tree
From: Zsolt Ero (zsolt.ero_at_[hidden])
Date: 2010-11-23 07:48:20
OK, I figured out my way, it seems that I could solve most of the
problems. My big problem now is that the recursive_directory_iterator
goes through a file which has a really long name. I think it's more
than 256 characters. It says:
boost::filesystem::last_write_time: The system cannot find the path specified:
Is there a fix or something for boost to handle more than 256
characters in windows path? I am using MSVC2010 + latest Boostpro
installer.
Zsolt
p.s. so far here is my code. If you have any idea about what I am
doing wrong, please don't hesitate to comment:
#define BOOST_FILESYSTEM_VERSION 3
#include "boost/filesystem.hpp"
#include <iostream>
#include <ctime>
using namespace std;
namespace fs = boost::filesystem;
int main() {
fs::recursive_directory_iterator it_end;
fs::recursive_directory_iterator it_dir("e:\\");
fs::path p;
time_t oldest( time(NULL) );
time_t newest(0);
try {
for ( ; it_dir != it_end; ++it_dir ) {
p = *it_dir;
try {
time_t t( last_write_time(p) );
if (t<oldest) oldest=t;
if (t>newest) newest=t;
//if (fs::is_directory(p)) cout << (p) << " " << t << endl;
}
catch (const fs::filesystem_error& ex) {
cout << "\n" << ex.what() << "\n";
}
}
}
catch (const fs::filesystem_error& ex) {
cout << "\n" << ex.what() << "\n";
}
cout << "\nOldest: " << ctime(&oldest);
cout << "Newest: " << ctime(&newest) << endl;
return 0;
}
Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net