source: project/wiki/filepath @ 12292

Last change on this file since 12292 was 12292, checked in by Ivan Raikov, 13 years ago

Initial documentation for filepath egg.

File size: 4.9 KB
Line 
1[[tags: eggs]]
2[[toc:]]
3
4== filepath
5
6=== Description
7
8The {{filepath}} library contains procedures for cross-platform
9parsing and manipulation of file paths. It supports both Windows and
10POSIX paths, including Windows share paths.
11
12=== Library Procedures
13
14==== Platform Flags
15
16<procedure>(filepath:posix [BOOL]) => BOOL</procedure>
17
18If invoked without arguments, this procedure returns whether the
19library procedures assume POSIX-style paths or not. Invoking the
20procedure with a boolean argument disables or enables POSIX-style
21paths. If set to false, the library procedures assume Windows-style
22paths.
23
24<procedure>(filepath:is-windows?) => BOOL</procedure>
25
26Convenience function that returns the inverse of {{(filepath:posix)}}.
27
28<procedure>(filepath:is-posix?) => BOOL</procedure>
29
30Convenience function that returns the result of {{(filepath:posix)}}.
31
32==== Path Separators
33
34<procedure>(filepath:path-separator) => CHAR</procedure>
35
36The character that separates directories. On platforms where more than
37one character is possible, this procedure returns the default one.
38
39<procedure>(filepath:path-separator-set) => CHAR-SET</procedure>
40
41The set of all possible path separator characters.
42
43<procedure>(filepath:is-path-separator? CHAR) => BOOL</procedure>
44
45A predicate that returns whether the given character is a path
46separator for the current platform.
47
48<procedure>(filepath:search-path-separator) => CHAR</procedure>
49
50The character that is used to separate the entries in the {{PATH}}
51environment variable.
52
53<procedure>(filepath:is-search-path-separator? CHAR) => BOOL</procedure>
54
55A predicate that returns whether the given character can be used a
56separator in the {{PATH}} environment variable.
57
58<procedure>(filepath:ext-separator) => CHAR</procedure>
59
60The character that is used to separate file extensions.
61
62<procedure>(filepath:is-ext-separator? CHAR) => BOOL</procedure>
63
64A predicate that returns whether the given character is a file
65extension separator.
66
67==== Search Path
68
69<procedure>(filepath:split-search-path STRING) => LIST</procedure>
70
71Splits a string on the search path separator character.
72
73<procedure>(filepath:get-search-path) => STRING</procedure>
74
75Returns search path from the OS environment.
76
77==== Extension procedures
78
79  filepath:split-extension
80
81  filepath:take-extension
82
83  filepath:replace-extension
84 
85  filepath:drop-extension
86
87  filepath:add-extension
88 
89  filepath:has-extension?
90 
91  filepath:split-all-extensions
92
93  filepath:drop-all-extensions
94 
95  filepath:take-all-extensions
96
97==== Drive procedures
98
99filepath:split-drive
100
101filepath:join-drive
102
103filepath:take-drive
104
105filepath:has-drive?
106
107filepath:drop-drive
108
109filepath:is-drive?
110
111==== Operations on a file path
112
113filepath:split-file-name
114
115filepath:take-file-name
116
117filepath:replace-file-name
118
119filepath:drop-file-name
120
121filepath:take-base-name
122
123filepath:replace-base-name
124
125filepath:take-directory
126
127filepath:replace-directory
128
129filepath:combine
130
131filepath:split-path
132
133filepath:join-path
134
135filepath:split-directories
136
137==== Trailing Separators
138
139filepath:has-trailing-path-separator?
140
141filepath:add-trailing-path-separator
142
143filepath:drop-trailing-path-separator
144
145==== File Name Normalization
146
147filepath:normalise
148
149filepath:path-equal?
150
151filepath:make-relative
152
153filepath:is-relative?
154
155filepath:is-absolute?
156
157filepath:is-valid?
158
159filepath:make-valid
160
161
162
163
164=== Requires
165
166; [[matchable]]
167
168=== Version History
169
170* 1.0 Initial Release
171
172=== License
173
174
175Based on the [[http://www-users.cs.york.ac.uk/~ndm/filepath|Haskell FilePath library]] by Neil Mitchell.
176
177Copyright 2008 Ivan Raikov.
178
179Redistribution and use in source and binary forms, with or without
180modification, are permitted provided that the following conditions are
181met:
182
183- Redistributions of source code must retain the above copyright
184  notice, this list of conditions and the following disclaimer.
185
186- Redistributions in binary form must reproduce the above copyright
187  notice, this list of conditions and the following disclaimer in the
188  documentation and/or other materials provided with the distribution.
189
190- Neither name of the copyright holders nor the names of its
191  contributors may be used to endorse or promote products derived from
192  this software without specific prior written permission.
193
194THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND THE
195CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING,
196BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
197FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
198COPYRIGHT HOLDERS OR THE CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
199INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
200(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
201SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
202HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
203STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
204IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
205POSSIBILITY OF SUCH DAMAGE.
206
Note: See TracBrowser for help on using the repository browser.