Skip to content

Modern Fs PathStartsWith

Paul Squires edited this page Oct 19, 2026 · 5 revisions

Home › Filesystem › Filesystem Library › PathStartsWith

PathStartsWith

Returns true if a path begins with another, comparing whole parts, not characters.

Syntax

PathStartsWith( p, pre )

Examples

#import "std/fs"
using fs

'' Whole-COMPONENT prefix test, not a string prefix -- which is what
'' makes it safe for a containment check
print PathStartsWith( "C:\dev\src", "C:\dev" )       '' true

'' "C:\development" does NOT start with "C:\dev", though the text does
print PathStartsWith( "C:\development", "C:\dev" )    '' false

'' The check to use before trusting a user-supplied path to stay inside
'' a directory -- after normalising it

Library: Filesystem Library
Category: Filesystem
Documented under: Paths

Clone this wiki locally