Skip to content

Commit 35d72bc

Browse files
authored
Merge pull request #24709 from JuliaLang/ksh/fsdts
Doctests for some filesystem methods
2 parents 6827170 + 5888345 commit 35d72bc

File tree

1 file changed

+37
-10
lines changed

1 file changed

+37
-10
lines changed

base/stat.jl

Lines changed: 37 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -165,26 +165,53 @@ Returns `true` if `path` is a FIFO, `false` otherwise.
165165
166166
Returns `true` if `path` is a character device, `false` otherwise.
167167
"""
168-
ischardev(st::StatStruct) = filemode(st) & 0xf000 == 0x2000
168+
ischardev(st::StatStruct) = filemode(st) & 0xf000 == 0x2000
169169

170-
"""
171-
isdir(path) -> Bool
170+
"""
171+
isdir(path) -> Bool
172+
173+
Returns `true` if `path` is a directory, `false` otherwise.
174+
175+
# Examples
176+
```jldoctest
177+
julia> isdir(homedir())
178+
true
172179
173-
Returns `true` if `path` is a directory, `false` otherwise.
174-
"""
175-
isdir(st::StatStruct) = filemode(st) & 0xf000 == 0x4000
180+
julia> f = open("test_file.txt", "w")
181+
IOStream(<file test_file.txt>)
182+
183+
julia> isdir(f)
184+
false
185+
186+
julia> close(f)
187+
```
188+
"""
189+
isdir(st::StatStruct) = filemode(st) & 0xf000 == 0x4000
176190

177-
"""
178-
isblockdev(path) -> Bool
191+
"""
192+
isblockdev(path) -> Bool
179193
180-
Returns `true` if `path` is a block device, `false` otherwise.
181-
"""
194+
Returns `true` if `path` is a block device, `false` otherwise.
195+
"""
182196
isblockdev(st::StatStruct) = filemode(st) & 0xf000 == 0x6000
183197

184198
"""
185199
isfile(path) -> Bool
186200
187201
Returns `true` if `path` is a regular file, `false` otherwise.
202+
203+
# Examples
204+
```jldoctest
205+
julia> isfile(homedir())
206+
false
207+
208+
julia> f = open("test_file.txt", "w");
209+
210+
julia> isfile(f)
211+
true
212+
213+
julia> close(f)
214+
```
188215
"""
189216
isfile(st::StatStruct) = filemode(st) & 0xf000 == 0x8000
190217

0 commit comments

Comments
 (0)