Re: Bug in fs::copy / fs::copy_file
Fabian Keßler <[email protected]> Sun, 6 Sep 2020 17:13:19 +0200
| Newsgroups | gmane.comp.gnu.mingw.user |
|---|---|
| Message-ID | <[email protected]> |
I think I found a bug in MINGW, gcc in the filesystem library:
MINGW v. 8.0
-- The C compiler identification is GNU 10.2.0
-- The CXX compiler identification is GNU 10.2.0
-- Check for working C compiler: P:/MSYS2/mingw64/bin/gcc.exe
-- Check for working C compiler: P:/MSYS2/mingw64/bin/gcc.exe -
works
trying to run:
```
#include <iostream>
#include <fstream>
#include <filesystem>
namespace fs = std::filesystem;
constexpr auto * f1 ="C:\\TEMP\\fred_test.txt";
constexpr auto * f2 ="C:\\TEMP\\fred_test.txt~";
void create_file(char const* p){
std::ofstream ofs1{p};
}
int main() {
try{
fs::remove(f1);
fs::remove(f2);
create_file(f1);
create_file(f2);
fs::copy_file(f1, f2, fs::copy_options::overwrite_existing);
std::cout << "success" << std::endl;
} catch (fs::filesystem_error const& fe) {
std::cout << fe.what() << std::endl;
}
}
```
Gives the following output:
```
filesystem error: cannot copy file: File exists
[C:\TEMP\fred_test.txt] [C:\TEMP\fred_test.txt~]
```
With msvc:
```
success
```
Running CMake with: P:\MSYS2\mingw64\bin\cmake.exe
-DCMAKE_BUILD_TYPE=Debug -G "CodeBlocks - MinGW Makefiles"
C:\Users\Febbe\CLionProjects\test_fs
```
cmake_minimum_required(VERSION 3.17)
project(test_fs)
set(CMAKE_CXX_STANDARD 20)
add_executable(test_fs main.cpp)
```
_______________________________________________
MinGW-Users mailing list
[email protected]
This list observes the Etiquette found at
http://www.mingw.org/Mailing_Lists.
We ask that you be polite and do the same. Disregard for the list etiquette may cause your account to be moderated.
_______________________________________________
You may change your MinGW Account Options or unsubscribe at:
https://lists.osdn.me/mailman/listinfo/mingw-users
Also: mailto:[email protected]?subject=unsubscribe