Index: boost/filesystem/convenience.hpp =================================================================== RCS file: /cvsroot/boost/boost/boost/filesystem/convenience.hpp,v retrieving revision 1.1 diff -u -r1.1 convenience.hpp --- boost/filesystem/convenience.hpp 18 Dec 2002 17:05:19 -0000 1.1 +++ boost/filesystem/convenience.hpp 25 Apr 2003 07:18:10 -0000 @@ -31,6 +31,12 @@ */ void create_directories(const path& ph); + std::string extension(const path& ph); + + std::string basename(const path& ph); + + path change_extension(const path& ph, const std::string& new_extension); + } // namespace filesystem } // namespace boost #endif // BOOST_FILESYSTEM_CONVENIENCE_HPP Index: libs/filesystem/doc/convenience.htm =================================================================== RCS file: /cvsroot/boost/boost/libs/filesystem/doc/convenience.htm,v retrieving revision 1.3 diff -u -r1.3 convenience.htm --- libs/filesystem/doc/convenience.htm 23 Dec 2002 20:09:06 -0000 1.3 +++ libs/filesystem/doc/convenience.htm 25 Apr 2003 07:18:10 -0000 @@ -24,6 +24,9 @@
Contributed by Vladimir Prus.
+ ++ ++ ++ +
std::string extension( const path & ph );
Precondition:
!ph.leaf().empy()
+Returns: if
ph.leaf()
contains a dot ('.'), +returns the substring ofph.leaf()
starting from the last dot and +ending at the string's end. Otherwise, returns empty string. +Rationale:
+
+- The dot is included in the return value so that it's +possible to tell if extension is empty or absent. +
- It was noted that this defintion of extension is probably not sufficient +when using Alternate Data Streams — +a filesystem feature specific to NTFS. However, semantic in this case was not +clear, and the current one is quite usefull still. +
Acknowlegements: Carl Daniel and Pavel Vozenilek noticed and +discussed the ADS issue. + +
+ ++ ++ +
std::string basename( const path & ph );
Precondition:
!ph.leaf().empy()
+Returns: if
+ph.leaf()
contains a dot ('.'), +returns the substring ofph.leaf()
starting from beginning and +ending at the last dot (the dot is not included). Otherwise, returns +ph.leaf()
+ +
+ ++ ++ +
path basename( const path & ph, const std::string & new_extension );
Precondition:
!ph.leaf().empy()
+Postcondition:
basename(return_value) == basename(ph) +&& extension(return_value) == new_extension
+Note: It follows from the semantic of
+extension
that +new_extension
should include dot. + +
© Copyright Beman Dawes, 2002
Index: libs/filesystem/src/convenience.cpp =================================================================== RCS file: /cvsroot/boost/boost/libs/filesystem/src/convenience.cpp,v retrieving revision 1.1 diff -u -r1.1 convenience.cpp --- libs/filesystem/src/convenience.cpp 18 Dec 2002 17:05:58 -0000 1.1 +++ libs/filesystem/src/convenience.cpp 25 Apr 2003 07:18:10 -0000 @@ -10,6 +10,7 @@ // See http://www.boost.org/libs/filesystem for documentation. #include