Opened 13 years ago

Closed 13 years ago

#3185 closed Bugs (invalid)

absolute path error

Reported by: tmmikolajczyk@… Owned by: Beman Dawes
Milestone: Boost 1.40.0 Component: filesystem
Version: Boost 1.37.0 Severity: Problem
Keywords: filesystem absolute path Cc:

Description

I have the following function that checks if a particular path is absolute or relative:

bool isPathAbsolute(const std::string& path) {

return !boost::filesystem::path(path).root_directory().empty();

}

Seems that it works fine for the following paths:

"/" absolute "/root" absolute "/" absolute "" absolute

However, for unknown reason function says that the path "" is not absolute. See attached very simple code that presents this problem.

Attachments (1)

boost_absolute_path_test.tar.gz (560 bytes ) - added by tmmikolajczyk@… 13 years ago.
the code printing the path's relativity checking result

Download all attachments as: .zip

Change History (2)

by tmmikolajczyk@…, 13 years ago

the code printing the path's relativity checking result

comment:1 by Beman Dawes, 13 years ago

Resolution: invalid
Status: newclosed

This isn't a bug - it is done deliberately to conform to POSIX. Here is the POSIX definition of Absolute Pathname:

3.2 Absolute Pathname

A pathname beginning with a single or more than two slashes; see also Pathname.

IIRC, Windows also treats two slashes differently, although it has been a while since I looked at how Windows handles multiple slashes.

HTH,

--Beman

Note: See TracTickets for help on using tickets.