From bc80bd40840e3013f8355b2b105d0bf6149486fa Mon Sep 17 00:00:00 2001 From: Beman Dawes Date: Mon, 1 Nov 2004 21:09:25 +0000 Subject: [PATCH] fix failure to remove dangling symbolic link (Walter Landry) [SVN r26064] --- src/operations_posix_windows.cpp | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/operations_posix_windows.cpp b/src/operations_posix_windows.cpp index fe99bab..55a6a7c 100644 --- a/src/operations_posix_windows.cpp +++ b/src/operations_posix_windows.cpp @@ -605,9 +605,12 @@ namespace boost BOOST_FILESYSTEM_DECL bool remove( const path & ph ) { - if ( exists( ph ) ) - { + if ( exists( ph ) # ifdef BOOST_POSIX + || symbolic_link_exists( ph ) ) // handle dangling symbolic links + { + // note that the POSIX behavior for symbolic links is what we want; + // the link rather than what it points to is deleted if ( std::remove( ph.string().c_str() ) != 0 ) { int error = fs::detail::system_error_code(); @@ -619,6 +622,8 @@ namespace boost "boost::filesystem::remove", ph, error ) ); } # else + ) + { if ( is_directory( ph ) ) { if ( !::RemoveDirectoryA( ph.string().c_str() ) )