XU XUv0.8.8
中文

API

#path

import: #path

counts: 11 fns, 0 methods, 0 types, 0 consts, 0 ifaces

POSIX slash paths: join/clean/split/base/dir/ext/matches.

is_abs

XuAPI
pub fn is_abs(p &string) bool

Purpose

Slash-separated path helpers, aligned with `path` package (not `path/filepath`). All operations allocate owned strings; slices copy.

Parameters

p &string
p (borrowed; caller keeps it; type &string)

Returns

bool — true or false

base

XuAPI
pub fn base(p &string) string

Purpose

Base name.

Parameters

p &string
p (borrowed; caller keeps it; type &string)

Returns

string — result string

dir

XuAPI
pub fn dir(p &string) string

Purpose

Directory.

Parameters

p &string
p (borrowed; caller keeps it; type &string)

Returns

string — result string

ext

XuAPI
pub fn ext(p &string) string

Purpose

Extension.

Parameters

p &string
p (borrowed; caller keeps it; type &string)

Returns

string — result string

split_list

XuAPI
pub fn split_list(s &string) []string

Purpose

Split list.

Parameters

s &string
source string (borrowed; caller keeps it; type &string)

Returns

[]string — slice result

join

XuAPI
pub fn join(parts []string) string

Purpose

Join pieces with a separator.

Parameters

parts []string
parts ([]string)

Returns

string — result string

split

XuAPI
pub fn split(p &string) []string

Purpose

split returns [dir, file] like path.Split (dir keeps trailing /).

Parameters

p &string
p (borrowed; caller keeps it; type &string)

Returns

[]string — slice result

clean

XuAPI
pub fn clean(p &string) string

Purpose

clean folds.,.., and repeated separators ( path.Clean). Uses an int offset stack + string buffer (not []string[len-1] rebuild) that branch was not taken (frame/index poison).

Parameters

p &string
p (borrowed; caller keeps it; type &string)

Returns

string — result string

matches

XuAPI
pub fn matches(pattern &string, name &string) bool

Purpose

match reports whether name matches pattern ( path.Match (Xu: matches)).

Parameters

pattern &string
pattern (borrowed; caller keeps it; type &string)
name &string
name (borrowed; caller keeps it; type &string)

Returns

bool — true or false

has_prefix

XuAPI
pub fn has_prefix(p &string, prefix string) bool

Purpose

Report whether the value has the given prefix.

Parameters

p &string
p (borrowed; caller keeps it; type &string)
prefix string
prefix (string)

Returns

bool — true or false

has_suffix

XuAPI
pub fn has_suffix(p &string, suffix string) bool

Purpose

Report whether the value has the given suffix.

Parameters

p &string
p (borrowed; caller keeps it; type &string)
suffix string
suffix (string)

Returns

bool — true or false