Opened 6 years ago

Last modified 21 months 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: francis.thibault@… Owned by: Beman Dawes
Milestone: To Be Determined Component: filesystem
Version: Boost 1.59.0 Severity: Problem
Keywords: create_directories() Cc: francis.thibault@…


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?


Change History (12)

comment:1 Changed 6 years ago by anonymous

I have same issue!

comment:2 Changed 6 years ago by randydu@…

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:3 Changed 5 years ago by anonymous

I have the same issue!! =)

comment:4 Changed 5 years ago by anonymous

Version: Boost 1.52.0Boost 1.55.0

comment:5 Changed 4 years ago by gilaldpellaeon@…

Version: Boost 1.55.0Boost 1.57.0

I have the same issue with Boost 1.57.0 (linux).

comment:6 Changed 4 years ago by hadatko

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 Changed 3 years ago by Beman Dawes

Resolution: fixed
Status: newclosed

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.



comment:8 Changed 3 years ago by anonymous

Resolution: fixed
Status: closedreopened
Version: Boost 1.57.0Boost 1.59.0


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:9 Changed 3 years ago by anonymous

By the way, I forgot to mention that I'm running Windows 8.1 pro

comment:10 Changed 3 years ago by Beman Dawes

Milestone: To Be DeterminedBoost 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

If it is still failing for you on the current develop branch, please submit a small program that isolates the problem.



comment:11 Changed 21 months ago by Smithd407

Component: filesystemxpressive
Milestone: Boost 1.60.0Website 1.X
Severity: ProblemNot Applicable
Type: BugsLibrary Submissions
Version: Boost 1.59.0Boost.Build-M3

Thanksamundo for the post.Really thank you! Awesome. ekegdddkdcadbkgf

comment:12 Changed 21 months ago by Kohei Takahashi

Component: xpressivefilesystem
Milestone: Website 1.XTo Be Determined
Severity: Not ApplicableProblem
Type: Library SubmissionsBugs
Version: Boost.Build-M3Boost 1.59.0

I couldn't undo milestone to 1.60 due to closed.

Note: See TracTickets for help on using tickets.