Skip to content

Commit 8f43eb0

Browse files
author
t-anders
committedMar 10, 2008
Fixed/extended documentation for init, dirname, isDir, isFile, resolve, dropExtension, addExtension. Added doc for dirnameString, isDir2, isFile2.
git-svn-id: https://gforge.info.ucl.ac.be/svn/mozart@16880 ada56829-ad1f-0410-b00f-83cda6628aec
1 parent 05fb830 commit 8f43eb0

File tree

1 file changed

+17
-12
lines changed

1 file changed

+17
-12
lines changed
 

‎os/path.html

+17-12
Original file line numberDiff line numberDiff line change
@@ -111,8 +111,7 @@ <H2>Instance API</H2>
111111
<DD>initializes a path object from the string <CODE>S</CODE>. <CODE>WIN</CODE>
112112
indicates that it should be considered a Windows-style path: this usually
113113
defaults to false, except on Windows where it defaults to true.
114-
<CODE>EXACT</CODE> indicates whether we should keep a terminal slash;
115-
the default is false.
114+
It is possible to indicate a directory by additing a terminal '/' or '\' (depending on OS). However, this slash/backslash is removed in the string output when <CODE>EXACT</CODE> is set to false, which is its default value.
116115
<DT><CODE>{P initFromRecord(+R)}</CODE>
117116
<DD>initializes the path object from its record-based representation
118117
<DT><CODE>{P newFromRecord(R $)}</CODE>
@@ -121,8 +120,7 @@ <H2>Instance API</H2>
121120
<CODE CLASS="DISPLAY">
122121
meth newFromRecord(R $)
123122
{New Path initFromRecord(R)}
124-
end
125-
</CODE>
123+
end</CODE>
126124
<DT><CODE>{P new(+S windows:WIN&lt;=ISWIN exact:EXACT&lt;=false)}</CODE>
127125
<DD>this method is also meant to be overriden to create derived
128126
instances from a string <CODE>S</CODE>
@@ -136,28 +134,34 @@ <H2>Instance API</H2>
136134
<DT><CODE>{P isRelative($)}</CODE>
137135
<DD>returns true (resp. false) iff the path is absolute
138136
<DT><CODE>{P dirname($)}</CODE>
139-
<DD>returns a new path object representing the parent directory of <CODE>P</CODE>
140-
<DT><CODE>{P basenameString($)}</CODE>
141-
<DD>returns the string representation for the last component of <CODE>P</CODE>
137+
<DD>returns a new path object representing the parent directory of <CODE>P</CODE>. If <CODE>P</CODE> contains only a single component (i.e. <CODE>P</CODE> is a plain file) then dirname returns<CODE> nil</CODE>.
138+
<DD>
142139
<DT><CODE>{P basename($)}</CODE>
143140
<DD>returns a new path object representing just the last component
144-
of path <CODE>P</CODE>
141+
of path <CODE>P</CODE>
142+
<DD>
143+
<DT><CODE>{P dirnameString($)}</CODE>
144+
<DD> returns the string representation for the parent directory of <CODE>P</CODE><DT><CODE>{P basenameString($)}</CODE>
145+
<DD>returns the string representation for the last component of <CODE>P</CODE>
145146
<DT><CODE>{P exists($)}</CODE>
146147
<DD>returns true iff path <CODE>P</CODE> exists
147148
<DT><CODE>{P stat($)}</CODE>
148149
<DD>returns a record representation of the stat information for path
149150
<CODE>P</CODE>
150151
<DT><CODE>{P isDir($)}</CODE>
151152
<DT><CODE>{P isFile($)}</CODE>
152-
<DD>returns true iff <CODE>P</CODE> is a directory (resp. a regular file)
153-
<DT><CODE>{P size($)}</CODE>
153+
<DD>returns true iff <CODE>P</CODE> is a directory (resp. a regular file). Note that these methods only work for an actually existing file which is either an absolute path or relative to the current path (the implementation calls<CODE> stat</CODE>)<DT>
154+
<DT><CODE>{P isDir2($)}</CODE>
155+
<DT>
156+
<DT><CODE>{P isFile2($)}</CODE>
157+
<DD><CODE>isDir2</CODE> returns true if <CODE>P</CODE> ends in a slash or backslash (depending on OS), and <CODE>isFile2</CODE> returns true if <CODE>P</CODE> does <em>not</em> end in a slash or backslash. Note that this is not a foolproof technique for checking for directories, but it works also for non-existing pathes<DT><CODE>{P size($)}</CODE>
154158
<DD>returns the size of file <CODE>P</CODE> in bytes
155159
<DT><CODE>{P mtime($)}</CODE>
156-
<DD>returns the time of last modification as an integer
160+
<DD>returns the time of the last modification as an integer
157161
<DT><CODE>{P resolve(+P2 $)}</CODE>
158162
<DD>returns a new path object that results from resolving <CODE>P2</CODE>
159163
relative to <CODE>P</CODE> (if <CODE>P2</CODE> is not a path, it is made
160-
into one)
164+
into one). In other words, <CODE>P2</CODE> is attached to the end of <CODE>P</CODE>. However, if <CODE>P2</CODE> is an absolute path, then it returns a path object only for <CODE>P2</CODE>. Note that resolve also 'appends' <CODE>P2</CODE> to <CODE>P</CODE> in case <CODE>P</CODE> is a regular file.
161165
<DT><CODE>{P getcwd($)}</CODE>
162166
<DD>returns a path object representing the current working directory
163167
<DT><CODE>{P mkdir}</CODE>
@@ -178,6 +182,7 @@ <H2>Instance API</H2>
178182
<DT><CODE>{P dropExtension($)}</CODE>
179183
<DD>returns a new path object with the extension of <CODE>P</CODE>, if any,
180184
omitted
185+
<dt>&nbsp;</dt>
181186
<DT><CODE>{P addExtension(+VS $)}</CODE>
182187
<DD>returns a new path object which is like <CODE>P</CODE> but with the
183188
extension <CODE>VS</CODE> added

0 commit comments

Comments
 (0)