]> git.ipfire.org Git - thirdparty/gcc.git/blob - libstdc++-v3/testsuite/27_io/filesystem/operations/all.cc
Update copyright years.
[thirdparty/gcc.git] / libstdc++-v3 / testsuite / 27_io / filesystem / operations / all.cc
1 // { dg-options "-fno-inline" }
2 // { dg-do link { target c++17 } }
3 // { dg-require-filesystem-ts "" }
4
5 // Copyright (C) 2019-2022 Free Software Foundation, Inc.
6 //
7 // This file is part of the GNU ISO C++ Library. This library is free
8 // software; you can redistribute it and/or modify it under the
9 // terms of the GNU General Public License as published by the
10 // Free Software Foundation; either version 3, or (at your option)
11 // any later version.
12
13 // This library is distributed in the hope that it will be useful,
14 // but WITHOUT ANY WARRANTY; without even the implied warranty of
15 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 // GNU General Public License for more details.
17
18 // You should have received a copy of the GNU General Public License along
19 // with this library; see the file COPYING3. If not see
20 // <http://www.gnu.org/licenses/>.
21
22 // C++17 30.10.15 Filesystem operation functions [fs.op.funcs]
23
24 #include <filesystem>
25
26 // Link-only test to ensure all operation functions are exported from the lib.
27
28 int
29 main()
30 {
31 const std::filesystem::path p;
32 std::filesystem::path p2;
33 const std::filesystem::copy_options copyopts{};
34 const std::filesystem::file_status st{};
35 std::filesystem::file_status st2;
36 const std::filesystem::file_time_type t;
37 std::filesystem::file_time_type t2;
38 const std::filesystem::perms perms{};
39 const std::filesystem::perm_options permopts{};
40 std::filesystem::space_info sp;
41 std::error_code ec;
42 bool b [[maybe_unused]];
43 std::uintmax_t size;
44
45 std::filesystem::absolute(p);
46 std::filesystem::absolute(p, ec);
47
48 std::filesystem::canonical(p);
49 std::filesystem::canonical(p, ec);
50
51 std::filesystem::copy(p, p);
52 std::filesystem::copy(p, p, ec);
53 std::filesystem::copy(p, p, copyopts);
54 std::filesystem::copy(p, p, copyopts, ec);
55
56 std::filesystem::copy_file(p, p);
57 std::filesystem::copy_file(p, p, ec);
58 std::filesystem::copy_file(p, p, copyopts);
59 std::filesystem::copy_file(p, p, copyopts, ec);
60
61 std::filesystem::copy_symlink(p, p);
62 std::filesystem::copy_symlink(p, p, ec);
63
64 std::filesystem::create_directories(p);
65 std::filesystem::create_directories(p, ec);
66
67 std::filesystem::create_directory(p);
68 std::filesystem::create_directory(p, ec);
69
70 std::filesystem::create_directory(p, p);
71 std::filesystem::create_directory(p, p, ec);
72
73 std::filesystem::create_directory_symlink(p, p);
74 std::filesystem::create_directory_symlink(p, p, ec);
75
76 std::filesystem::create_hard_link(p, p);
77 std::filesystem::create_hard_link(p, p, ec);
78
79 std::filesystem::create_symlink(p, p);
80 std::filesystem::create_symlink(p, p, ec);
81
82 p2 = std::filesystem::current_path();
83 p2 = std::filesystem::current_path(ec);
84 std::filesystem::current_path(p);
85 std::filesystem::current_path(p, ec);
86
87 b = std::filesystem::equivalent(p, p);
88 b = std::filesystem::equivalent(p, p, ec);
89
90 b = std::filesystem::exists(st);
91 b = std::filesystem::exists(p);
92 b = std::filesystem::exists(p, ec);
93
94 size = std::filesystem::file_size(p);
95 size = std::filesystem::file_size(p, ec);
96
97 size = std::filesystem::hard_link_count(p);
98 size = std::filesystem::hard_link_count(p, ec);
99
100 b = std::filesystem::is_block_file(st);
101 b = std::filesystem::is_block_file(p);
102 b = std::filesystem::is_block_file(p, ec);
103
104 b = std::filesystem::is_character_file(st);
105 b = std::filesystem::is_character_file(p);
106 b = std::filesystem::is_character_file(p, ec);
107
108 b = std::filesystem::is_directory(st);
109 b = std::filesystem::is_directory(p);
110 b = std::filesystem::is_directory(p, ec);
111
112 b = std::filesystem::is_empty(p);
113 b = std::filesystem::is_empty(p, ec);
114
115 b = std::filesystem::is_fifo(st);
116 b = std::filesystem::is_fifo(p);
117 b = std::filesystem::is_fifo(p, ec);
118
119 b = std::filesystem::is_other(st);
120 b = std::filesystem::is_other(p);
121 b = std::filesystem::is_other(p, ec);
122
123 b = std::filesystem::is_regular_file(st);
124 b = std::filesystem::is_regular_file(p);
125 b = std::filesystem::is_regular_file(p, ec);
126
127 b = std::filesystem::is_socket(st);
128 b = std::filesystem::is_socket(p);
129 b = std::filesystem::is_socket(p, ec);
130
131 b = std::filesystem::is_symlink(st);
132 b = std::filesystem::is_symlink(p);
133 b = std::filesystem::is_symlink(p, ec);
134
135 t2 = std::filesystem::last_write_time(p);
136 t2 = std::filesystem::last_write_time(p, ec);
137 std::filesystem::last_write_time(p, t);
138 std::filesystem::last_write_time(p, t, ec);
139
140 std::filesystem::permissions(p, perms);
141 std::filesystem::permissions(p, perms, permopts);
142 std::filesystem::permissions(p, perms, ec);
143 std::filesystem::permissions(p, perms, permopts, ec);
144
145 p2 = std::filesystem::proximate(p, ec);
146 p2 = std::filesystem::proximate(p);
147 p2 = std::filesystem::proximate(p, p);
148 p2 = std::filesystem::proximate(p, p, ec);
149
150 p2 = std::filesystem::read_symlink(p);
151 p2 = std::filesystem::read_symlink(p, ec);
152
153 p2 = std::filesystem::relative(p, ec);
154 p2 = std::filesystem::relative(p);
155 p2 = std::filesystem::relative(p, p);
156 p2 = std::filesystem::relative(p, p, ec);
157
158 b = std::filesystem::remove(p);
159 b = std::filesystem::remove(p, ec);
160
161 size = std::filesystem::remove_all(p);
162 size = std::filesystem::remove_all(p, ec);
163
164 std::filesystem::rename(p, p);
165 std::filesystem::rename(p, p, ec);
166
167 std::filesystem::resize_file(p, size);
168 std::filesystem::resize_file(p, size, ec);
169
170 sp = std::filesystem::space(p);
171 sp = std::filesystem::space(p, ec);
172
173 st2 = std::filesystem::status(p);
174 st2 = std::filesystem::status(p, ec);
175
176 b = std::filesystem::status_known(st);
177
178 st2 = std::filesystem::symlink_status(p);
179 st2 = std::filesystem::symlink_status(p, ec);
180
181 p2 = std::filesystem::temp_directory_path();
182 p2 = std::filesystem::temp_directory_path(ec);
183
184 p2 = std::filesystem::weakly_canonical(p);
185 p2 = std::filesystem::weakly_canonical(p, ec);
186 }