1 | #include <cassert>
|
---|
2 | #include <boost/filesystem/operations.hpp>
|
---|
3 |
|
---|
4 |
|
---|
5 | int main()
|
---|
6 | {
|
---|
7 | // "C:\Gehua" is a junction point of "D:\Gehua"
|
---|
8 | fs::path work("d:/Gehua/work");
|
---|
9 | fs::path work_canonical(fs::canonical(work));
|
---|
10 | std::wstring s = fs::canonical(work_canonical).native();
|
---|
11 | // True path passes
|
---|
12 | assert(s == L"d:/Gehua\\work");
|
---|
13 |
|
---|
14 | // try the junction path
|
---|
15 | fs::path work_junction("c:/Gehua/work");
|
---|
16 | // this passes
|
---|
17 | assert(fs::exists(work_junction));
|
---|
18 |
|
---|
19 | s = fs::canonical(work_junction).native();
|
---|
20 | // this one fails!
|
---|
21 | // s has value "c:/Gehua\\Gehua\\work"
|
---|
22 | assert(s == L"d:/Gehua\\work");
|
---|
23 | return 0;
|
---|
24 | }
|
---|