Skip site navigation (1)Skip section navigation (2)

FreeBSD Manual Pages

  
 
  

home | help
std::experi...::path::stem(3) C++ Standard Libarystd::experi...::path::stem(3)

NAME
       std::experimental::filesystem::path::stem - std::experimental::filesys-
       tem::path::stem

Synopsis
	  path stem() const;  (filesystem TS)

	  Returns  the	filename identified by the path	stripped of its	exten-
       sion.

	  Returns the substring	from the beginning of filename() up to and not
       including the
	  last period (.) character.

	  If the filename is one of the	special	filesystem components  dot  or
       dot-dot,	or if it
	  has no periods, the function returns the entire filename().

Parameters
	  (none)

Return value
	  The stem of the filename identified by the path.

Exceptions
	  May throw implementation-defined exceptions.

Example
       // Run this code

	#include <iostream>
	#include <experimental/filesystem>
	namespace fs = std::experimental::filesystem;

	int main()
	{
	    std::cout << fs::path("/foo/bar.txt").stem() << '\n'
		      << fs::path("/foo/.bar").stem() << '\n';

	    for	 (fs::path  p =	"foo.bar.baz.tar"; !p.extension().empty(); p =
       p.stem())
		std::cout << p.extension() << '\n';
	}

Output:
	"bar"
	""
	".tar"
	".baz"
	".bar"

See also
	  filename  returns the	filename path component
		    (public member function)
	  extension returns the	file extension path component
		    (public member function)

http://cppreference.com		  2022.07.31	 std::experi...::path::stem(3)

Want to link to this manual page? Use this URL:
<https://man.freebsd.org/cgi/man.cgi?query=std::experimental::filesystem::path::stem&sektion=3&manpath=FreeBSD+Ports+15.0>

home | help