1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
|
Index: /trunk/boost/filesystem/operations.hpp
===================================================================
--- /trunk/boost/filesystem/operations.hpp (revision 48192)
+++ /trunk/boost/filesystem/operations.hpp (revision 48377)
@@ -122,8 +122,4 @@
namespace detail
{
- // singular object used only as a tag; thus initialization and
- // thread-safety are not issues
- BOOST_FILESYSTEM_DECL extern system::error_code throws;
-
typedef std::pair< system::error_code, bool >
query_pair;
@@ -235,5 +231,8 @@
template<class Path>
- unsigned long remove_all_aux( const Path & ph );
+ bool remove_aux( const Path & ph, file_status f );
+
+ template<class Path>
+ unsigned long remove_all_aux( const Path & ph, file_status f );
} // namespace detail
@@ -475,17 +474,22 @@
}
- BOOST_FS_FUNC(void) remove( const Path & ph, system::error_code & ec = detail::throws )
- {
- system::error_code error( detail::remove_api(ph.external_file_string()) );
- if ( error && &ec == &detail::throws )
- boost::throw_exception( basic_filesystem_error<Path>(
- "boost::filesystem::remove", ph, error ) );
- ec = error;
+ BOOST_FS_FUNC(bool) remove( const Path & ph )
+ {
+ system::error_code ec;
+ file_status f = symlink_status( ph, ec );
+ if ( ec )
+ boost::throw_exception( basic_filesystem_error<Path>(
+ "boost::filesystem::remove", ph, ec ) );
+ return detail::remove_aux( ph, f );
}
BOOST_FS_FUNC(unsigned long) remove_all( const Path & ph )
{
- return exists( ph )|| is_symlink( ph )
- ? detail::remove_all_aux( ph ) : 0;
+ system::error_code ec;
+ file_status f = symlink_status( ph, ec );
+ if ( ec )
+ boost::throw_exception( basic_filesystem_error<Path>(
+ "boost::filesystem::remove_all", ph, ec ) );
+ return exists( f ) ? detail::remove_all_aux( ph, f ) : 0;
}
@@ -713,6 +717,8 @@
{ return create_symlink<wpath>( to_ph, from_ph, ec ); }
- inline void remove( const path & ph ) { remove<path>( ph ); }
- inline void remove( const wpath & ph ) { remove<wpath>( ph ); }
+ inline bool remove( const path & ph )
+ { return remove<path>( ph ); }
+ inline bool remove( const wpath & ph )
+ { return remove<wpath>( ph ); }
inline unsigned long remove_all( const path & ph )
@@ -763,18 +769,37 @@
{
template<class Path>
- unsigned long remove_all_aux( const Path & ph )
+ bool remove_aux( const Path & ph, file_status f )
+ {
+ if ( exists( f ) )
+ {
+ system::error_code ec = remove_api( ph.external_file_string() );
+ if ( ec )
+ boost::throw_exception( basic_filesystem_error<Path>(
+ "boost::filesystem::remove", ph, ec ) );
+ return true;
+ }
+ return false;
+ }
+
+ template<class Path>
+ unsigned long remove_all_aux( const Path & ph, file_status f )
{
static const boost::filesystem::basic_directory_iterator<Path> end_itr;
unsigned long count = 1;
- if ( !boost::filesystem::is_symlink( ph ) // don't recurse symbolic links
- && boost::filesystem::is_directory( ph ) )
+ if ( !boost::filesystem::is_symlink( f ) // don't recurse symbolic links
+ && boost::filesystem::is_directory( f ) )
{
for ( boost::filesystem::basic_directory_iterator<Path> itr( ph );
itr != end_itr; ++itr )
{
- count += remove_all_aux( itr->path() );
+ boost::system::error_code ec;
+ boost::filesystem::file_status fn = boost::filesystem::symlink_status( itr->path(), ec );
+ if ( ec )
+ boost::throw_exception( basic_filesystem_error<Path>(
+ "boost::filesystem:remove_all", ph, ec ) );
+ count += remove_all_aux( itr->path(), fn );
}
}
- boost::filesystem::remove( ph );
+ remove_aux( ph, f );
return count;
}
Index: /trunk/libs/filesystem/test/operations_test.cpp
===================================================================
--- /trunk/libs/filesystem/test/operations_test.cpp (revision 47181)
+++ /trunk/libs/filesystem/test/operations_test.cpp (revision 48377)
@@ -777,8 +777,8 @@
BOOST_CHECK( fs::exists( file_ph ) );
BOOST_CHECK( !fs::is_directory( file_ph ) );
- fs::remove( file_ph );
+ BOOST_CHECK( fs::remove( file_ph ) );
BOOST_CHECK( !fs::exists( file_ph ) );
- fs::remove( "no-such-file" );
- fs::remove( "no-such-directory/no-such-file" );
+ BOOST_CHECK( !fs::remove( "no-such-file" ) );
+ BOOST_CHECK( !fs::remove( "no-such-directory/no-such-file" ) );
// remove() directory
@@ -791,5 +791,5 @@
bad_remove_dir = dir;
BOOST_CHECK( CHECK_EXCEPTION( bad_remove, ENOTEMPTY ) );
- fs::remove( d1 );
+ BOOST_CHECK( fs::remove( d1 ) );
BOOST_CHECK( !fs::exists( d1 ) );
@@ -798,5 +798,5 @@
// remove() dangling symbolic link
fs::path link( "dangling_link" );
- fs::remove( link );
+ fs::remove( link ); // remove any residue from past tests
BOOST_CHECK( !fs::is_symlink( link ) );
BOOST_CHECK( !fs::exists( link ) );
@@ -804,14 +804,14 @@
BOOST_CHECK( !fs::exists( link ) );
BOOST_CHECK( fs::is_symlink( link ) );
- fs::remove( link );
+ BOOST_CHECK( fs::remove( link ) );
BOOST_CHECK( !fs::is_symlink( link ) );
// remove() self-refering symbolic link
link = "link_to_self";
- fs::remove( link );
+ fs::remove( link ); // remove any residue from past tests
BOOST_CHECK( !fs::is_symlink( link ) );
BOOST_CHECK( !fs::exists( link ) );
fs::create_symlink( link, link );
- fs::remove( link );
+ BOOST_CHECK( fs::remove( link ) );
BOOST_CHECK( !fs::exists( link ) );
BOOST_CHECK( !fs::is_symlink( link ) );
@@ -820,12 +820,12 @@
link = "link_to_a";
fs::path link2( "link_to_b" );
- fs::remove( link );
- fs::remove( link2 );
+ fs::remove( link ); // remove any residue from past tests
+ fs::remove( link2 ); // remove any residue from past tests
BOOST_CHECK( !fs::is_symlink( link ) );
BOOST_CHECK( !fs::exists( link ) );
fs::create_symlink( link, link2 );
fs::create_symlink( link2, link );
- fs::remove( link );
- fs::remove( link2 );
+ BOOST_CHECK( fs::remove( link ) );
+ BOOST_CHECK( fs::remove( link2 ) );
BOOST_CHECK( !fs::exists( link ) );
BOOST_CHECK( !fs::exists( link2 ) );
@@ -834,5 +834,5 @@
// remove() symbolic link to file
file_ph = "link_target";
- fs::remove( file_ph );
+ fs::remove( file_ph ); // remove any residue from past tests
BOOST_CHECK( !fs::exists( file_ph ) );
create_file( file_ph, "" );
@@ -846,9 +846,9 @@
BOOST_CHECK( fs::is_regular_file( link ) );
BOOST_CHECK( fs::is_symlink( link ) );
- fs::remove( link );
+ BOOST_CHECK( fs::remove( link ) );
BOOST_CHECK( fs::exists( file_ph ) );
BOOST_CHECK( !fs::exists( link ) );
BOOST_CHECK( !fs::is_symlink( link ) );
- fs::remove( file_ph );
+ BOOST_CHECK( fs::remove( file_ph ) );
BOOST_CHECK( !fs::exists( file_ph ) );
}
Index: /trunk/libs/filesystem/test/msvc/fstream_test/fstream_test.vcproj
===================================================================
--- /trunk/libs/filesystem/test/msvc/fstream_test/fstream_test.vcproj (revision 46750)
+++ /trunk/libs/filesystem/test/msvc/fstream_test/fstream_test.vcproj (revision 48377)
@@ -87,5 +87,5 @@
<Tool
Name="VCPostBuildEventTool"
- Description="Auto test run"
+ Description="run test"
CommandLine=""$(TargetDir)\$(TargetName).exe" --result_code=no --report_level=no"
/>
@@ -164,4 +164,6 @@
<Tool
Name="VCPostBuildEventTool"
+ Description="run test"
+ CommandLine=""$(TargetDir)\$(TargetName).exe" --result_code=no --report_level=no"
/>
</Configuration>
Index: /trunk/libs/filesystem/test/msvc/operations_test/operations_test.vcproj
===================================================================
--- /trunk/libs/filesystem/test/msvc/operations_test/operations_test.vcproj (revision 46750)
+++ /trunk/libs/filesystem/test/msvc/operations_test/operations_test.vcproj (revision 48377)
@@ -87,5 +87,5 @@
<Tool
Name="VCPostBuildEventTool"
- Description="Auto test run"
+ Description="run test"
CommandLine=""$(TargetDir)\$(TargetName).exe" --result_code=no --report_level=no"
/>
@@ -164,4 +164,6 @@
<Tool
Name="VCPostBuildEventTool"
+ Description="run test"
+ CommandLine=""$(TargetDir)\$(TargetName).exe" --result_code=no --report_level=no"
/>
</Configuration>
Index: /trunk/libs/filesystem/test/msvc/large_file_support_test/large_file_support_test.vcproj
===================================================================
--- /trunk/libs/filesystem/test/msvc/large_file_support_test/large_file_support_test.vcproj (revision 46750)
+++ /trunk/libs/filesystem/test/msvc/large_file_support_test/large_file_support_test.vcproj (revision 48377)
@@ -87,5 +87,5 @@
<Tool
Name="VCPostBuildEventTool"
- Description="Auto test run"
+ Description="run test"
CommandLine=""$(TargetDir)\$(TargetName).exe" --result_code=no --report_level=no"
/>
@@ -164,4 +164,6 @@
<Tool
Name="VCPostBuildEventTool"
+ Description="run test"
+ CommandLine=""$(TargetDir)\$(TargetName).exe" --result_code=no --report_level=no"
/>
</Configuration>
Index: /trunk/libs/filesystem/test/msvc/simple_ls/simple_ls.vcproj
===================================================================
--- /trunk/libs/filesystem/test/msvc/simple_ls/simple_ls.vcproj (revision 46750)
+++ /trunk/libs/filesystem/test/msvc/simple_ls/simple_ls.vcproj (revision 48377)
@@ -87,4 +87,6 @@
<Tool
Name="VCPostBuildEventTool"
+ Description=""
+ CommandLine=""
/>
</Configuration>
@@ -162,4 +164,6 @@
<Tool
Name="VCPostBuildEventTool"
+ Description=""
+ CommandLine=""
/>
</Configuration>
Index: /trunk/libs/filesystem/test/msvc/wide_test/wide_test.vcproj
===================================================================
--- /trunk/libs/filesystem/test/msvc/wide_test/wide_test.vcproj (revision 46750)
+++ /trunk/libs/filesystem/test/msvc/wide_test/wide_test.vcproj (revision 48377)
@@ -87,5 +87,5 @@
<Tool
Name="VCPostBuildEventTool"
- Description="Auto test run"
+ Description="run test"
CommandLine=""$(TargetDir)\$(TargetName).exe" --result_code=no --report_level=no"
/>
@@ -164,4 +164,6 @@
<Tool
Name="VCPostBuildEventTool"
+ Description="run test"
+ CommandLine=""$(TargetDir)\$(TargetName).exe" --result_code=no --report_level=no"
/>
</Configuration>
Index: /trunk/libs/filesystem/test/msvc/mbcopy/mbcopy.vcproj
===================================================================
--- /trunk/libs/filesystem/test/msvc/mbcopy/mbcopy.vcproj (revision 46750)
+++ /trunk/libs/filesystem/test/msvc/mbcopy/mbcopy.vcproj (revision 48377)
@@ -87,4 +87,6 @@
<Tool
Name="VCPostBuildEventTool"
+ Description="run test"
+ CommandLine=""$(TargetDir)\$(TargetName).exe" --result_code=no --report_level=no"
/>
</Configuration>
@@ -162,4 +164,6 @@
<Tool
Name="VCPostBuildEventTool"
+ Description="run test"
+ CommandLine=""$(TargetDir)\$(TargetName).exe" --result_code=no --report_level=no"
/>
</Configuration>
Index: /trunk/libs/filesystem/test/msvc/convenience_test/convenience_test.vcproj
===================================================================
--- /trunk/libs/filesystem/test/msvc/convenience_test/convenience_test.vcproj (revision 46750)
+++ /trunk/libs/filesystem/test/msvc/convenience_test/convenience_test.vcproj (revision 48377)
@@ -87,5 +87,5 @@
<Tool
Name="VCPostBuildEventTool"
- Description="Auto test run"
+ Description="run test"
CommandLine=""$(TargetDir)\$(TargetName).exe" --result_code=no --report_level=no"
/>
@@ -164,4 +164,6 @@
<Tool
Name="VCPostBuildEventTool"
+ Description="run test"
+ CommandLine=""$(TargetDir)\$(TargetName).exe" --result_code=no --report_level=no"
/>
</Configuration>
Index: /trunk/libs/filesystem/test/msvc/path_test/path_test.vcproj
===================================================================
--- /trunk/libs/filesystem/test/msvc/path_test/path_test.vcproj (revision 46750)
+++ /trunk/libs/filesystem/test/msvc/path_test/path_test.vcproj (revision 48377)
@@ -87,5 +87,5 @@
<Tool
Name="VCPostBuildEventTool"
- Description="Auto test run"
+ Description="run test"
CommandLine=""$(TargetDir)\$(TargetName).exe" --result_code=no --report_level=no"
/>
@@ -164,4 +164,6 @@
<Tool
Name="VCPostBuildEventTool"
+ Description="run test"
+ CommandLine=""$(TargetDir)\$(TargetName).exe" --result_code=no --report_level=no"
/>
</Configuration>
|