1 | #include <port/unistd.h> |
---|---|
2 | #include <iostream> |
3 | #include <Poco/File.h> |
4 | #include <Poco/Path.h> |
5 | #include <Common/Exception.h> |
6 | |
7 | |
8 | namespace DB |
9 | { |
10 | namespace ErrorCodes |
11 | { |
12 | extern const int SYSTEM_ERROR; |
13 | } |
14 | } |
15 | |
16 | int main(int, char **) |
17 | try |
18 | { |
19 | Poco::File dir("./test_dir/"); |
20 | dir.createDirectories(); |
21 | |
22 | Poco::File("./test_dir/file").createFile(); |
23 | |
24 | if (0 != symlink("./test_dir", "./test_link")) |
25 | DB::throwFromErrnoWithPath("Cannot create symlink", "./test_link", DB::ErrorCodes::SYSTEM_ERROR); |
26 | |
27 | Poco::File link("./test_link"); |
28 | link.renameTo("./test_link2"); |
29 | |
30 | Poco::File("./test_link2").remove(true); |
31 | return 0; |
32 | } |
33 | catch (...) |
34 | { |
35 | std::cerr << DB::getCurrentExceptionMessage(false) << "\n"; |
36 | return 1; |
37 | } |
38 |