XU XUv0.8.8
中文

API

#path/filepath

import: #path/filepath

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

Host paths (volume, slash conversion), glob, and walk.

to_slash

XuAPI
pub fn to_slash(p &string) string

Purpose

Convert to slash.

Parameters

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

Returns

string — result string

from_slash

XuAPI
pub fn from_slash(p &string) string

Purpose

Build from slash.

Parameters

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

Returns

string — result string

is_abs

XuAPI
pub fn is_abs(p &string) bool

Purpose

Whether it is abs.

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

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

Purpose

Split on the separator.

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 ( filepath.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

list_separator

XuAPI
pub fn list_separator() int

Purpose

List separator.

Parameters

none

Returns

int — a value of this type

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

rel

XuAPI
pub fn rel(base_path &string, target &string) string

Purpose

rel returns a relative path from base_path to target. Both are cleaned; if target cannot be made relative, returns Err. Throws on failure.

Parameters

base_path &string
base_path (borrowed; caller keeps it; type &string)
target &string
target (borrowed; caller keeps it; type &string)

Returns

string — result string

is_local

XuAPI
pub fn is_local(p &string) bool

Purpose

Whether it is local.

Parameters

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

Returns

bool — true or false

volume_name

XuAPI
pub fn volume_name(p &string) string

Purpose

Volume name.

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

matches; returns bool.

Parameters

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

Returns

bool — true or false

abs

XuAPI
pub fn abs(p &string) string

Purpose

Absolute value.

Parameters

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

Returns

string — result string

glob

XuAPI
pub fn glob(pattern &string) []string

Purpose

Glob. Throws on failure.

Parameters

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

Returns

[]string — slice result

walk

XuAPI
pub fn walk(root string, visit fn(string, bool) int)

Purpose

Walk.

Parameters

root string
root (string)
visit fn(string, bool) int
visit callback (function value; type fn(string, bool) int)