Opened 6 years ago

Last modified 6 years ago

#12665 new Feature Requests

boost::filesystem::path::replace_extension(const path& new_extension) produces inintuitive path on special directory

Reported by: Guillaume Labourey <guillaume.labourey@…> Owned by: Beman Dawes
Milestone: To Be Determined Component: filesystem
Version: Boost 1.62.0 Severity: Problem
Keywords: filesystem path replace_extension Cc:

Description

Hi, I have read the specification of boost::filesystem::path::replace_extension(const path& new_extension). It is very helpful in most of common use but the method may be ignore replacement when path represents the following cases:

  • dot (.)
  • dot-dot (..)
  • root-name (C:, myserver,
    myserver)

The version available in boost 1.62.0 provide the following behaviour

Replace extension on root path: (arguable)
------------------------------------------

replace_extension("/","txt") = "/.txt"
replace_extension("C:\","txt") = "C:\.txt"

Replace extension on special file-name
--------------------------------------

replace_extension(".","txt") = "..txt"
replace_extension("..","txt") = "...txt"
replace_extension("/foo/.","txt") = "/foo/..txt"
replace_extension("/foo/..","txt") = "/foo/...txt"

Replace extension on root-name
------------------------------

replace_extension("C:","txt") = "C:.txt"
replace_extension("\\myserver","txt") = "\\myserver.txt"

Regards, Guillaume

Attachments (1)

replace_extension_on_directories.cpp (1.1 KB ) - added by Guillaume Labourey <guillaume.labourey@…> 6 years ago.

Download all attachments as: .zip

Change History (3)

by Guillaume Labourey <guillaume.labourey@…>, 6 years ago

comment:1 by Guillaume Labourey <guillaume.labourey@…>, 6 years ago

Component: Nonefilesystem
Owner: set to Beman Dawes

comment:2 by Guillaume Labourey <guillaume.labourey@…>, 6 years ago

Change component to good field.

Note: See TracTickets for help on using tickets.