You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardexpand all lines: os/path.html
+17-12
Original file line number
Diff line number
Diff line change
@@ -111,8 +111,7 @@ <H2>Instance API</H2>
111
111
<DD>initializes a path object from the string <CODE>S</CODE>. <CODE>WIN</CODE>
112
112
indicates that it should be considered a Windows-style path: this usually
113
113
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.
116
115
<DT><CODE>{P initFromRecord(+R)}</CODE>
117
116
<DD>initializes the path object from its record-based representation
<DD>this method is also meant to be overriden to create derived
128
126
instances from a string <CODE>S</CODE>
@@ -136,28 +134,34 @@ <H2>Instance API</H2>
136
134
<DT><CODE>{P isRelative($)}</CODE>
137
135
<DD>returns true (resp. false) iff the path is absolute
138
136
<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>
142
139
<DT><CODE>{P basename($)}</CODE>
143
140
<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>
145
146
<DT><CODE>{P exists($)}</CODE>
146
147
<DD>returns true iff path <CODE>P</CODE> exists
147
148
<DT><CODE>{P stat($)}</CODE>
148
149
<DD>returns a record representation of the stat information for path
149
150
<CODE>P</CODE>
150
151
<DT><CODE>{P isDir($)}</CODE>
151
152
<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>
154
158
<DD>returns the size of file <CODE>P</CODE> in bytes
155
159
<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
157
161
<DT><CODE>{P resolve(+P2 $)}</CODE>
158
162
<DD>returns a new path object that results from resolving <CODE>P2</CODE>
159
163
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.
161
165
<DT><CODE>{P getcwd($)}</CODE>
162
166
<DD>returns a path object representing the current working directory
163
167
<DT><CODE>{P mkdir}</CODE>
@@ -178,6 +182,7 @@ <H2>Instance API</H2>
178
182
<DT><CODE>{P dropExtension($)}</CODE>
179
183
<DD>returns a new path object with the extension of <CODE>P</CODE>, if any,
180
184
omitted
185
+
<dt> </dt>
181
186
<DT><CODE>{P addExtension(+VS $)}</CODE>
182
187
<DD>returns a new path object which is like <CODE>P</CODE> but with the
0 commit comments