4#include "../Strings/StringView.h"
21#if SC_PLATFORM_WINDOWS
30 bool endsWithSeparator =
false;
81 StringView separator = SeparatorStringView(),
bool skipEmpty =
false);
160 static const char Separator =
'\\';
162 [[nodiscard]]
static constexpr StringView SeparatorStringView() {
return "\\"_a8; };
167 static const char Separator =
'/';
169 [[nodiscard]]
static constexpr StringView SeparatorStringView() {
return "/"_a8; }
173#if SC_PLATFORM_WINDOWS
174 static constexpr char Separator =
'\\';
176 static constexpr char Separator =
'/';
180#if SC_PLATFORM_WINDOWS
181 [[nodiscard]]
static constexpr StringView SeparatorStringView() {
return "\\"_a8; };
198 template <
int numComponents = 64>
202 return normalize(output, view, type, components);
223 Type outputType = AsNative);
248 [[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:29
StringView root
Ex. "C:\\"</tt> on windows - <tt>"/" on posix.
Definition Path.h:35
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:37
StringView name
Ex. "name" for "C:\\dir\\name.ext" on windows or "/dir/name.ext" on posix.
Definition Path.h:38
StringView ext
Ex. "ext" for "C:\\dir\\name.ext" on windows or "/dir/name.ext" on posix.
Definition Path.h:39
StringView directory
Ex. "C:\\dir" on windows - "/dir" on posix.
Definition Path.h:36
bool parsePosix(StringView input)
Parses all components on posix input path.
Parse and compose filesystem paths for windows and posix.
Definition Path.h:15
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 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:183
static bool normalize(String &output, StringView view, Type type)
Resolves all .. to output a normalized path String.
Definition Path.h:199
static bool endsWithSeparator(StringView path)
Check if the path ends with a Windows or Posix separator.
static bool normalizeUNCAndTrimQuotes(String &outputPath, StringView fileLocation, Type type, Span< StringView > components)
An extended Path::normalize handling a bug with incorrect FILE backslash escape on Windows when using...
static bool normalize(String &output, StringView view, Type type, Span< StringView > components)
Resolves all .. to output a normalized path String (allows custom span of components)
static StringView basename(StringView input, Type type)
Returns the base name of a path.
Type
Path type (windows or posix)
Definition Path.h:18
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:29
Non-owning view over a range of characters with UTF Encoding.
Definition StringView.h:48
A non-modifiable owning string with associated encoding.
Definition String.h:29