Opened 10 years ago
Last modified 6 years ago
#7258 reopened Bugs
boost::filesystem::create_directories(const &path) returns false if the path contains a slash at the end of the string
Reported by: | Owned by: | Beman Dawes | |
---|---|---|---|
Milestone: | To Be Determined | Component: | filesystem |
Version: | Boost 1.59.0 | Severity: | Problem |
Keywords: | create_directories() | Cc: | francis.thibault@… |
Description
for example, if we want to create that following directory: path="C:/users/test/"
the function create_directories(path) returns false even if the directory is created and exists.
However, if we remove the slash at the end of the string path="C:/users/test", the function returns true.
Is it the normal behavior of that function?
Thanks.
Change History (12)
comment:1 by , 10 years ago
comment:2 by , 10 years ago
It also happens on Mac.
The problem is:
path dir("foo/"); dir.parent_path() ==> "foo"; (not "")
hence when create_directories() is called, according to the current implementation (operations.cpp), the parent_path is created ("foo") first, then create_directory("foo/") is called and returns FALSE with an error (BOOST_ERROR_ALREADY_EXISTS).
If the trailing slash is removed:
path dir("foo"); dir.parent_path() ==> ""; (now empty: "")
then everything works perfectly.
So the bug fix is creating a public wrapper of create_directories() to remove trailing slash of input parameter before calling internal create_directories().
Thanks, Randy
comment:4 by , 9 years ago
Version: | Boost 1.52.0 → Boost 1.55.0 |
---|
comment:5 by , 8 years ago
Version: | Boost 1.55.0 → Boost 1.57.0 |
---|
I have the same issue with Boost 1.57.0 (linux).
comment:6 by , 8 years ago
Still problem 1.55.1 you can make this useful with this if(!boost::filesystem::is_directory(dir)) {
boost::filesystem::create_directories(dir); if(!boost::filesystem::is_directory(dir)) {
error code
}
}
comment:7 by , 7 years ago
Resolution: | → fixed |
---|---|
Status: | new → closed |
Fixed. Also fixed related issues if path contains dot or dot-dot elements, and added test cases to the test suite.
The fixes have been applied to the develop branch and will be merged to master once sufficient regression tests have cycled.
Thanks,
--Beman
comment:8 by , 7 years ago
Resolution: | fixed |
---|---|
Status: | closed → reopened |
Version: | Boost 1.57.0 → Boost 1.59.0 |
Hi,
I'm running Boost 1.59 and have found the exact same problem. The bug ISN'T fixed!
Thanks !
# g++ --version
g++ (x86_64-posix-seh-rev0, Built by MinGW-W64 project) 5.2.0 Copyright (C) 2015 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
g++.exe -Wall -fexceptions -g -march=corei7 -std=c++0x -g -IC:\boost_1_59_0 -c C:\temp\c++\main.cpp -o obj\Debug\main.o g++.exe -LC:\boost_1_59_0\stage\lib -o bin\Debug\_recolle_futures.exe obj\Debug\main.o C:\boost_1_59_0\stage\lib\libboost_system-mgw52-mt-1_59.a C:\boost_1_59_0\stage\lib\libboost_filesystem-mgw52-mt-1_59.a C:\boost_1_59_0\stage\lib\libboost_regex-mgw52-mt-1_59.a C:\boost_1_59_0\stage\lib\libboost_program_options-mgw52-mt-1_59.a C:\boost_1_59_0\stage\lib\libboost_date_time-mgw52-mt-1_59.a C:\boost_1_59_0\stage\lib\libboost_iostreams-mgw52-mt-1_59.a
comment:10 by , 7 years ago
Milestone: | To Be Determined → Boost 1.60.0 |
---|
It is fixed in the develop branch for Boost 1.60. Did you test against 1.59 or against the current develop branch of the filesystem repo at https://github.com/boostorg/filesystem?
If it is still failing for you on the current develop branch, please submit a small program that isolates the problem.
Thanks,
--Beman
comment:11 by , 6 years ago
Component: | filesystem → xpressive |
---|---|
Milestone: | Boost 1.60.0 → Website 1.X |
Severity: | Problem → Not Applicable |
Type: | Bugs → Library Submissions |
Version: | Boost 1.59.0 → Boost.Build-M3 |
Thanksamundo for the post.Really thank you! Awesome. ekegdddkdcadbkgf
comment:12 by , 6 years ago
Component: | xpressive → filesystem |
---|---|
Milestone: | Website 1.X → To Be Determined |
Severity: | Not Applicable → Problem |
Type: | Library Submissions → Bugs |
Version: | Boost.Build-M3 → Boost 1.59.0 |
I couldn't undo milestone to 1.60 due to closed.
I have same issue!