-
Notifications
You must be signed in to change notification settings - Fork 64
/
Filepath.txt
154 lines (121 loc) · 5.63 KB
/
Filepath.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
*vital/System/Filepath.txt* path string utilities library.
Maintainer: thinca <[email protected]>
tyru <[email protected]>
==============================================================================
CONTENTS *Vital.System.Filepath-contents*
INTRODUCTION |Vital.System.Filepath-introduction|
INTERFACE |Vital.System.Filepath-interface|
Functions |Vital.System.Filepath-functions|
==============================================================================
INTRODUCTION *Vital.System.Filepath-introduction*
*Vital.System.Filepath* is Path String Utilities Library.
It provides some functions to manipulate path strings.
==============================================================================
INTERFACE *Vital.System.Filepath-interface*
------------------------------------------------------------------------------
FUNCTIONS *Vital.System.Filepath-functions*
to_slash({path}) *Vital.System.Filepath.to_slash()*
Use when you quote path string for scripting languages, without
worrying about the runtime operating system is if windows or not.
e.g.
>
let code = printf(
\ '(neoclojure-init "%s")',
\ shellescape(s:F.to_slash(path)))
..
let path = s:F.from_slash(
\ s:get_path_like_string_from_something())
<
This function intentionally ignores 'shellslash' option, so that you
can simply use this function for path string not only from Vim but
also from others, such as environment vars, problem output, or really
anything.
See also: |Vital.System.Filepath.from_slash()|
from_slash({path}) *Vital.System.Filepath.from_slash()*
This is opposite to |Vital.System.Filepath.to_slash()|. See its doc.
separator() *Vital.System.Filepath.separator()*
Return OS related directory separator as string.
This returns "/" on non-Windows, or Windows and |'shellslash'| is on.
This returns "\" on Windows and |'shellslash'| is off.
path_separator() *Vital.System.Filepath.path_separator()*
Return OS related path separator as string.
This returns ";" on Windows.
Otherwise this returns ":".
You can get list of each filepath of $PATH by:
>
split($PATH, s:F.path_separator())
<
path_extensions() *Vital.System.Filepath.path_extensions()*
Return OS related path extensions as array of string.
unify_separator({path}) *Vital.System.Filepath.unify_separator()*
Return path string replaced all directory separators with '/'.
which({command} [, {path}]) *Vital.System.Filepath.which()*
Returns the full path of {command}. This searches from {path} or
$PATH. If the command is not found, returns empty string.
split({path}) *Vital.System.Filepath.split()*
Return |List| of elements in {path} string.
join({args}...) *Vital.System.Filepath.join()*
Join the path in {args}.
is_absolute({path}) *Vital.System.Filepath.is_absolute()*
When {path} is absolute path, return 1.
Otherwise, return 0.
cf. |Vital.System.Filepath.is_relative()|
is_relative({path}) *Vital.System.Filepath.is_relative()*
When {path} is relative path, return 1.
Otherwise, return 0.
cf. |Vital.System.Filepath.is_absolute()|
dirname({path}) *Vital.System.Filepath.dirname()*
Return directory name from {path}.
basename({path}) *Vital.System.Filepath.basename()*
Return basename from {path}.
remove_last_separator({path}) *Vital.System.Filepath.remove_last_separator()*
Remove last directory separator if exists.
is_case_tolerant() *Vital.System.Filepath.is_case_tolerant()*
Return non-zero if filesystem ignores alphabetic case of a filename,
zero otherwise.
expand_home({path}) *Vital.System.Filepath.expand_home()*
Return a home-expanded path of {path}. The home directory expansion
will not have a trailing directory separator.
Like |expand()|, but only expanding a leading "~" home directory
sequence, or like |fnamemodify()| with the ":p" modifier, but without
full path expansion or unpredictable results if a file name doesn't
exist and doesn't have an absolute path. See |filename-modifiers|.
abspath({path}) *Vital.System.Filepath.abspath()*
Return an absolute path of {path}.
If the {path} is already an absolute path, it returns the {path}.
cf. |Vital.System.Filepath.relpath()|
relpath({path}) *Vital.System.Filepath.relpath()*
Return a relative path of {path}.
If the {path} is already a relative path, it returns the {path}.
cf. |Vital.System.Filepath.abspath()|
unixpath({path}) *Vital.System.Filepath.unixpath()*
Return a unix path of {path}.
All backslashes (\) in {path} will be substituted to slashes (/).
winpath({path}) *Vital.System.Filepath.winpath()*
Return a windows path of {path}.
All slashes (/) in {path} will be substituted to backslashes (\).
realpath({path}) *Vital.System.Filepath.realpath()*
Return a real path of {path} of the current operation system.
In non Windows OS, it calls |Vital.System.Filepath.unixpath()|
internally.
In windows, it calls |Vital.System.Filepath.unixpath()| when the
Vim is compiled with '+shellslash' and |shellslash| is specified.
Otherwise it calls |Vim.System.Filepath.winpath()| internally.
is_root_directory({path}) *Vital.System.Filepath.is_root_directory()*
Return 1 if the given {path} points to the root directory, otherwise
0.
>
is_root_directory('/') == 1
is_root_directory('/aaa') == 0
is_root_directory('/aaa/..') == 0 " It doesn't resolve.
is_root_directory('C:/') == 1 " If it's on Windows.
<
contains({path}, {base}) *Vital.System.Filepath.contains()*
Return 1 if {path} contains {base}, otherwise 0.
{path} and {base} must be a full path.
>
contains('/foo/bar/buz', '/foo/bar') == 1
contains('/foo/hoge/buz', '/foo/bar') == 0
<
==============================================================================
vim:tw=78:fo=tcq2mM:ts=8:ft=help:norl