]>
git.ipfire.org Git - thirdparty/gcc.git/blob - 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 "" }
5 // Copyright (C) 2019-2022 Free Software Foundation, Inc.
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)
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.
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/>.
22 // C++17 30.10.15 Filesystem operation functions [fs.op.funcs]
26 // Link-only test to ensure all operation functions are exported from the lib.
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
;
42 bool b
[[maybe_unused
]];
45 std::filesystem::absolute(p
);
46 std::filesystem::absolute(p
, ec
);
48 std::filesystem::canonical(p
);
49 std::filesystem::canonical(p
, ec
);
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
);
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
);
61 std::filesystem::copy_symlink(p
, p
);
62 std::filesystem::copy_symlink(p
, p
, ec
);
64 std::filesystem::create_directories(p
);
65 std::filesystem::create_directories(p
, ec
);
67 std::filesystem::create_directory(p
);
68 std::filesystem::create_directory(p
, ec
);
70 std::filesystem::create_directory(p
, p
);
71 std::filesystem::create_directory(p
, p
, ec
);
73 std::filesystem::create_directory_symlink(p
, p
);
74 std::filesystem::create_directory_symlink(p
, p
, ec
);
76 std::filesystem::create_hard_link(p
, p
);
77 std::filesystem::create_hard_link(p
, p
, ec
);
79 std::filesystem::create_symlink(p
, p
);
80 std::filesystem::create_symlink(p
, p
, ec
);
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
);
87 b
= std::filesystem::equivalent(p
, p
);
88 b
= std::filesystem::equivalent(p
, p
, ec
);
90 b
= std::filesystem::exists(st
);
91 b
= std::filesystem::exists(p
);
92 b
= std::filesystem::exists(p
, ec
);
94 size
= std::filesystem::file_size(p
);
95 size
= std::filesystem::file_size(p
, ec
);
97 size
= std::filesystem::hard_link_count(p
);
98 size
= std::filesystem::hard_link_count(p
, ec
);
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
);
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
);
108 b
= std::filesystem::is_directory(st
);
109 b
= std::filesystem::is_directory(p
);
110 b
= std::filesystem::is_directory(p
, ec
);
112 b
= std::filesystem::is_empty(p
);
113 b
= std::filesystem::is_empty(p
, ec
);
115 b
= std::filesystem::is_fifo(st
);
116 b
= std::filesystem::is_fifo(p
);
117 b
= std::filesystem::is_fifo(p
, ec
);
119 b
= std::filesystem::is_other(st
);
120 b
= std::filesystem::is_other(p
);
121 b
= std::filesystem::is_other(p
, ec
);
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
);
127 b
= std::filesystem::is_socket(st
);
128 b
= std::filesystem::is_socket(p
);
129 b
= std::filesystem::is_socket(p
, ec
);
131 b
= std::filesystem::is_symlink(st
);
132 b
= std::filesystem::is_symlink(p
);
133 b
= std::filesystem::is_symlink(p
, ec
);
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
);
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
);
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
);
150 p2
= std::filesystem::read_symlink(p
);
151 p2
= std::filesystem::read_symlink(p
, ec
);
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
);
158 b
= std::filesystem::remove(p
);
159 b
= std::filesystem::remove(p
, ec
);
161 size
= std::filesystem::remove_all(p
);
162 size
= std::filesystem::remove_all(p
, ec
);
164 std::filesystem::rename(p
, p
);
165 std::filesystem::rename(p
, p
, ec
);
167 std::filesystem::resize_file(p
, size
);
168 std::filesystem::resize_file(p
, size
, ec
);
170 sp
= std::filesystem::space(p
);
171 sp
= std::filesystem::space(p
, ec
);
173 st2
= std::filesystem::status(p
);
174 st2
= std::filesystem::status(p
, ec
);
176 b
= std::filesystem::status_known(st
);
178 st2
= std::filesystem::symlink_status(p
);
179 st2
= std::filesystem::symlink_status(p
, ec
);
181 p2
= std::filesystem::temp_directory_path();
182 p2
= std::filesystem::temp_directory_path(ec
);
184 p2
= std::filesystem::weakly_canonical(p
);
185 p2
= std::filesystem::weakly_canonical(p
, ec
);