複数のサブディレクトリを含むディレクトリを実行しています。recursive_directory_iterator を使用しています。ディレクトリ asr->collections-> (複数のディレクトリといくつかのテキスト ファイル) があります。
#include <iostream>
#include <filesystem>
#include <conio.h>
using namespace std::tr2::sys;
int main () {
std::string path_;
std::cout << " Enter the path ";
std::cin >> path_;
auto dir_path = path(path_);
for (auto it = directory_iterator(dir_path); it != directory_iterator(); ++it)
{
const auto& file = it->path();
std::cout << " path : " << file << std::endl;
if (is_directory (status(it->path())))
std::cout << " It is a directory. " << std::endl;
else
std::cout << " It is not a directory. " << std::endl;
}
_getch();
return 0;
}
私はこれを以前に投稿したことを知っています。ばかげた間違いでした、私はそれを変更しました。しかし、それはまだバグです。私が抱えている問題は、 is-directory がすべてに対して false を返すことです。使い方が悪いのでしょうか。以下に MSDN の URL をリンクしました。
ブーストをインストールしてコードを実行しました。出来た !ブーストソース
#include <iostream>
#include <boost\filesystem.hpp>
#include <conio.h>
using namespace boost::filesystem;
int main () {
std::string path_;
std::cout << " Enter the path ";
std::cin >> path_;
auto dir_path = path(path_);
for (auto it = directory_iterator(dir_path); it != directory_iterator(); ++it)
{
const auto& file = it->path();
std::cout << " path : " << file << std::endl;
if (is_directory (status(it->path())))
std::cout << " It is a directory. " << std::endl;
else
std::cout << " It is not a directory. " << std::endl;
}
_getch();
return 0;
}
http://msdn.microsoft.com/en-us/library/hh874754.aspx
また、ブーストファイルシステムのドキュメントをチュートリアルとして使用できますか?これは、何が何で、どのように使用するかについての適切なドキュメントがないためです。