@@ -954,21 +954,22 @@ const UV_DIRENT_BLOCK = Cint(7)
954954
955955A type representing a filesystem entry that contains the name of the entry, the directory, and
956956the raw type of the entry. The full path of the entry can be obtained lazily by accessing the
957- `path` field. The type of the entry can be checked for by calling [`isfile`](@ref), [`isdir`](@ref),
958- [`islink`](@ref), [`isfifo`](@ref), [`issocket`](@ref), [`ischardev`](@ref), and [`isblockdev`](@ref).
957+ `path` field.
959958
960- If constructed manually via `DirEntry(path::String)`, the type of the entry is unknown and so `isfile`
961- etc. will fall back to a `stat` call.
959+ Public fields:
960+ - `dir::String`: The directory containing the entry.
961+ - `name::String`: The name of the entry.
962+ - `path::String`: The full path of the entry, lazily constructed from `dir` and `name`. Also accessible via `joinpath(entry)`.
963+
964+ The type of the entry can be checked for by calling [`isfile`](@ref), [`isdir`](@ref),
965+ [`islink`](@ref), [`isfifo`](@ref), [`issocket`](@ref), [`ischardev`](@ref), and [`isblockdev`](@ref)
966+ on the entry object.
962967"""
963968struct DirEntry
964969 dir:: String
965970 name:: String
966971 rawtype:: Cint
967972end
968- function DirEntry (path:: String )
969- dir, name = splitdir (path)
970- return DirEntry (dir, name, UV_DIRENT_UNKNOWN)
971- end
972973function Base. getproperty (obj:: DirEntry , p:: Symbol )
973974 if p === :path
974975 return joinpath (obj. dir, obj. name)
@@ -1009,12 +1010,13 @@ object will be 0 (`UV_DIRENT_UNKNOWN`) and [`isfile`](@ref) etc. will fall back
10091010
10101011# Examples
10111012```julia
1012- for obj in readdir(DirEntry, ".")
1013- isfile(obj) && println("\$ (obj.name) is a file with path \$ (obj.path)")
1014- end
1015- for obj in readdir(DirEntry(path))
1016- isdir(obj) || continue
1017- for obj2 in readdir(obj)
1013+ for entry in readdir(DirEntry, ".")
1014+ if isfile(entry)
1015+ println("\$ (entry.name) is a file with path \$ (entry.path)")
1016+ continue
1017+ end
1018+ isdir(entry) || continue
1019+ for entry2 in readdir(entry)
10181020 ...
10191021 end
10201022end
0 commit comments