Contents

removingLastComponent()

Creates a new path with everything up to but not including lastComponent.

Declaration

func removingLastComponent() -> FilePath

Discussion

If the path only contains a root, returns self. If the path has no root and only includes a single component, returns an empty FilePath.

Examples:

  • Unix:

    • /usr/bin/ls => /usr/bin

    • /foo => /

    • / => /

    • foo => ""

  • Windows:

    • C:\foo\bar.exe => C:\foo

    • C:\ => C:\

    • \\server\share\folder\file.txt => \\server\share\folder

    • \\server\share\ => \\server\share\