2017-01-16 4 views
0
#include <string> 
#include <iostream> 
#include <experimental/filesystem> 

namespace fs = std::experimental::filesystem; 

int main() 
{ 
    fs::path p("/usr/include/c++/../sys/*"); 
    p = fs::canonical(p); 
} 

のgcc 6.2.0はOKコンパイルしますが、実行時エラーが言う:std :: experimental :: filesystem :: pathが "*"のようなワイルドカードを受け入れないのはなぜですか?

terminate called after throwing an instance of 'std::experimental::filesystem::v1::__cxx11::filesystem_error'
what(): filesystem error: cannot canonicalize: No such file or directory [/usr/include/c++/../sys/*] [/data/svn/yaoxinliu] Aborted

はなぜstd::experimental::filesystem::path*のようなワイルドカードを受け付けないのですか? std::experimental::filesystem::canonicalもパスに含まれているシンボリックリンクを参照し、それが唯一の既存のファイルまたはディレクトリのパスを受け入れることができなければならないためdocumentation

std::experimental::filesystem::canonical converts path p to a canonical absolute path, i.e. an absolute path that has no dot, dot-dot elements or symbolic links.

によると

+2

設計上、パスはファイルの任意のセットではなく、単一のファイルに対応することが基本です。 –

答えて

関連する問題