UDocumentation UE5.7 10.02.2026 (Source)
API documentation for Unreal Engine 5.7
FilePathUtils.h
Go to the documentation of this file.
1// Copyright Epic Games, Inc. All Rights Reserved.
2
3#pragma once
4
6
7namespace uLang
8{
9namespace FilePathUtils
10{
11
12/*
13 * Replaces backslashes with slashes and make drive letters uppercase
14 */
15ULANGCORE_API CUTF8String NormalizePath(const CUTF8StringView& Path);
16
17/*
18 * Determine if a path is relative (i.e. not fully qualified)
19 */
20ULANGCORE_API bool IsPathRelative(const CUTF8StringView& Path);
21
22/*
23 * Splits a path into the file name and the directory in front of it
24 * The directory will have a slash or no slash at the end as specified by bIncludeDirEndSlash
25 * If there's no slash in the path, returns false.
26 */
27ULANGCORE_API bool SplitPath(const CUTF8StringView& FilePath, CUTF8StringView& OutDir, CUTF8StringView& OutFileName, bool bIncludeDirEndSlash = false);
28
29/*
30 * Invoke a lambda with each part of a path from left to right
31 * Slashes at either begin or end of path, as well as double slashes, will result in an invocation with an empty part
32 */
33template<typename FunctionType>
34void ForeachPartOfPath(const CUTF8StringView& Path, FunctionType&& Lambda)
35{
36 const UTF8Char* PartBegin = Path._Begin;
37 for (const UTF8Char* Ch = PartBegin; Ch <= Path._End; ++Ch)
38 {
39 if (Ch == Path._End || *Ch == '/' || *Ch == '\\')
40 {
42 PartBegin = Ch + 1;
43 }
44 }
45}
46
47/*
48 * Appends a slash to the path if there isn't one already
49 */
51
52/*
53 * Gets the containing directory of a file or directory
54 */
56
57/*
58 * Gets the unqualified name of a file or directory (without the containing path)
59 */
61
62/*
63 * Splits a file name into stem (name) and extension (including the dot)
64 */
66
67/*
68 * Combines two paths
69 */
71
72/*
73 * Checks if a path is relative, and if so, combines it with given base path
74 */
76
77/*
78 * Creates a relative path by removing BasePath from the head of FullPath. Result will be empty if this is not possible.
79 */
81
82/*
83 * Gets stem/name of given file, or if stem is empty, name of enclosing directory
84 */
86
87/*
88 * Check if a file/directory is a descendant of a given directory
89 * NOTE: This fails in a number of cases, but the most obvious one is when the parent directory passed in is a symbolic link and the second argument is the actual file/directory path.
90 */
92
93}
94}
UE_FORCEINLINE_HINT TSharedRef< CastToType, Mode > StaticCastSharedRef(TSharedRef< CastFromType, Mode > const &InSharedRef)
Definition SharedPointer.h:127
Definition UTF8StringView.h:15
CUTF8StringView GetNameFromFileOrDir(const CUTF8StringView &FilePath)
Definition FilePathUtils.cpp:222
CUTF8String ConvertFullPathToRelative(const CUTF8StringView &FullPath, const CUTF8StringView &BasePath)
Definition FilePathUtils.cpp:160
CUTF8String GetDirectory(const CUTF8StringView &Path, bool bIncludeDirEndSlash)
Definition FilePathUtils.cpp:80
CUTF8String GetFileName(const CUTF8StringView &Path)
Definition FilePathUtils.cpp:87
bool SplitPath(const CUTF8StringView &FilePath, CUTF8StringView &OutDir, CUTF8StringView &OutFileName, bool bIncludeDirEndSlash)
Definition FilePathUtils.cpp:44
void SplitFileName(const CUTF8StringView &FileName, CUTF8StringView &Stem, CUTF8StringView &Extension)
Definition FilePathUtils.cpp:94
CUTF8String ConvertRelativePathToFull(const CUTF8StringView &Path, const CUTF8StringView &BasePath)
Definition FilePathUtils.cpp:150
CUTF8String CombinePaths(const CUTF8StringView &LhsPath, const CUTF8StringView &RhsPath)
Definition FilePathUtils.cpp:116
bool IsDescendantOfDirectory(const CUTF8StringView &ParentDirectory, const CUTF8StringView &PotentialDescendantDirectory)
Definition FilePathUtils.cpp:237
void ForeachPartOfPath(const CUTF8StringView &Path, FunctionType &&Lambda)
Definition FilePathUtils.h:34
bool IsPathRelative(const CUTF8StringView &Path)
Definition FilePathUtils.cpp:39
CUTF8String NormalizePath(const CUTF8StringView &Path)
Definition FilePathUtils.cpp:12
CUTF8String AppendSlash(const CUTF8StringView &Path)
Definition FilePathUtils.cpp:68
Definition VVMEngineEnvironment.h:23
uLang::TUTF8String< CHeapRawAllocator > CUTF8String
A string allocated on the heap.
Definition UTF8String.h:269
uint8_t UTF8Char
UTF-8 octet.
Definition Unicode.h:20
Definition VstNode.h:1828