6#include "../Strings/StringView.h"
27#if SC_PLATFORM_WINDOWS
36 bool endsWithSeparator =
false;
166 static const char Separator =
'\\';
168 [[nodiscard]]
static constexpr StringView SeparatorStringView() {
return "\\"_a8; };
173 static const char Separator =
'/';
175 [[nodiscard]]
static constexpr StringView SeparatorStringView() {
return "/"_a8; }
179#if SC_PLATFORM_WINDOWS
186#if SC_PLATFORM_WINDOWS
222 Type outputType = AsNative);
245 [[nodiscard]]
static bool appendTrailingSeparator(
String& path,
Type type);
#define SC_COMPILER_EXPORT
Macro for symbol visibility in non-MSVC compilers.
Definition: Compiler.h:78
Holds the various parsed components of a path.
Definition: Path.h:35
StringView root
Ex. "C:\\" on windows - "/" on posix.
Definition: Path.h:41
bool parseWindows(StringView input)
Parses all components on windows input path.
StringView base
Ex. "base" for "C:\\dir\\base" on windows or "/dir/base" on posix.
Definition: Path.h:43
StringView name
Ex. "name" for "C:\\dir\\name.ext" on windows or "/dir/name.ext" on posix.
Definition: Path.h:44
StringView ext
Ex. "ext" for "C:\\dir\\name.ext" on windows or "/dir/name.ext" on posix.
Definition: Path.h:45
Type type
Indicates if this is a windows or posix path.
Definition: Path.h:40
StringView directory
Ex. "C:\\dir" on windows - "/dir" on posix.
Definition: Path.h:42
bool parsePosix(StringView input)
Parses all components on posix input path.
Represents a posix or windows file system path.
Definition: Path.h:21
static constexpr char Separator
Path separator char for current platform.
Definition: Path.h:182
static StringView basename(StringView input, StringView suffix)
Returns the base name of a path.
static bool relativeFromTo(StringView source, StringView destination, String &output, Type type, Type outputType=AsNative)
Get relative path that appended to source resolves to destination.
static bool parseNameExtension(const StringView input, StringView &name, StringView &extension)
Splits a StringView of type "name.ext" into "name" and "ext".
static bool append(String &output, Span< const StringView > paths, Type inputType)
Append to an existing path a series of StringView with a separator.
static bool join(String &output, Span< const StringView > inputs, StringView separator=SeparatorStringView(), bool skipEmpty=false)
Joins multiple StringView with a Separator into an output String.
static StringView removeStartingSeparator(StringView path)
Return a path without its (potential) starting separator.
static bool normalize(StringView view, Vector< StringView > &components, String *output, Type type)
Resolves all .. to output a normalized path String.
static bool parse(StringView input, Path::ParsedView &pathView, Type type)
Splits a Posix or Windows path into a ParsedView.
static StringView dirname(StringView input, Type type, int repeat=0)
Returns the directory name of a path.
static constexpr StringView SeparatorStringView()
Path separator StringView for current platform.
Definition: Path.h:189
static bool endsWithSeparator(StringView path)
Check if the path ends with a Windows or Posix separator.
static StringView basename(StringView input, Type type)
Returns the base name of a path.
Type
Path type (windows or posix)
Definition: Path.h:24
static bool isAbsolute(StringView input, Type type)
Checks if a path is absolute.
View over a contiguous sequence of items (pointer + size in elements).
Definition: Span.h:21
A non-modifiable owning string with associated encoding.
Definition: String.h:30
Non-owning view over a range of characters with UTF Encoding.
Definition: StringView.h:47
A contiguous sequence of heap allocated elements.
Definition: Vector.h:51