source: project/wiki/filepath @ 12293

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

Added some more descriptions and procedure tags.

File size: 6.3 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<procedure>(filepath:split-extension PATH) => (NAME EXT)</procedure>
80
81Splits path on the last extension.
82
83<procedure>(filepath:take-extension PATH) => EXT</procedure>
84
85Returns last extension of given path, or empty string.
86
87<procedure>(filepath:replace-extension PATH EXT) => PATH</procedure>
88 
89Replaces the last path extension with the given extension.
90
91<procedure>(filepath:drop-extension PATH) => PATH</procedure>
92
93Removes last extension and extension separator preceding it.
94
95<procedure>(filepath:add-extension PATH EXT) => PATH</procedure>
96 
97Appends an extension to the given path.
98
99<procedure>(filepath:has-extension? PATH) => BOOL</procedure>
100
101Returns true if the given path has an extension.
102 
103<procedure>(filepath:split-all-extensions PATH) => (NAME EXT)</procedure>
104
105Splits path on the first extension.
106
107<procedure>(filepath:drop-all-extensions PATH) => PATH</procedure>
108 
109Removes all extensions from the path.
110
111<procedure>(filepath:take-all-extensions PATH) => EXT</procedure>
112
113Returns all extensions from the path.
114
115==== Drive procedures
116
117<procedure>filepath:split-drive</procedure> 
118
119<procedure>filepath:join-drive</procedure>
120
121<procedure>filepath:take-drive</procedure>
122
123<procedure>filepath:has-drive?</procedure>
124
125<procedure>filepath:drop-drive</procedure>
126
127<procedure>filepath:is-drive?</procedure>
128
129==== Operations on a file path
130
131<procedure>filepath:split-file-name</procedure> 
132
133<procedure>filepath:take-file-name</procedure>
134
135<procedure>filepath:replace-file-name</procedure>
136
137<procedure>filepath:drop-file-name</procedure>
138
139<procedure>filepath:take-base-name</procedure>
140
141<procedure>filepath:replace-base-name</procedure>
142
143<procedure>filepath:take-directory</procedure>
144
145<procedure>filepath:replace-directory</procedure>
146
147<procedure>filepath:combine</procedure>
148
149<procedure>filepath:split-path</procedure>
150
151<procedure>filepath:join-path</procedure>
152
153<procedure>filepath:split-directories</procedure>
154
155==== Trailing Separators
156
157<procedure>filepath:has-trailing-path-separator?</procedure>
158
159<procedure>filepath:add-trailing-path-separator</procedure>
160
161<procedure>filepath:drop-trailing-path-separator</procedure>
162
163==== File Name Normalization
164
165<procedure>filepath:normalise</procedure>
166
167<procedure>filepath:path-equal?</procedure>
168
169<procedure>filepath:make-relative</procedure>
170
171<procedure>filepath:is-relative?</procedure>
172
173<procedure>filepath:is-absolute?</procedure>
174
175<procedure>filepath:is-valid?</procedure> 
176
177<procedure>filepath:make-valid</procedure>
178
179
180
181
182=== Requires
183
184; [[matchable]]
185
186=== Version History
187
188* 1.0 Initial Release
189
190=== License
191
192
193Based on the [[http://www-users.cs.york.ac.uk/~ndm/filepath|Haskell FilePath library]] by Neil Mitchell.
194
195Copyright 2008 Ivan Raikov.
196
197Redistribution and use in source and binary forms, with or without
198modification, are permitted provided that the following conditions are
199met:
200
201- Redistributions of source code must retain the above copyright
202  notice, this list of conditions and the following disclaimer.
203
204- Redistributions in binary form must reproduce the above copyright
205  notice, this list of conditions and the following disclaimer in the
206  documentation and/or other materials provided with the distribution.
207
208- Neither name of the copyright holders nor the names of its
209  contributors may be used to endorse or promote products derived from
210  this software without specific prior written permission.
211
212THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND THE
213CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING,
214BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
215FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
216COPYRIGHT HOLDERS OR THE CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
217INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
218(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
219SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
220HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
221STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
222IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
223POSSIBILITY OF SUCH DAMAGE.
224
Note: See TracBrowser for help on using the repository browser.