Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add docstring to constants in Base.Filesystem #53247

Merged
merged 6 commits into from
Feb 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
70 changes: 69 additions & 1 deletion base/filesystem.jl
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,45 @@

module Filesystem

"""
JL_O_APPEND
JL_O_ASYNC
JL_O_CLOEXEC
JL_O_CREAT
JL_O_DIRECT
JL_O_DIRECTORY
JL_O_DSYNC
JL_O_EXCL
JL_O_FSYNC
JL_O_LARGEFILE
JL_O_NDELAY
JL_O_NOATIME
JL_O_NOCTTY
JL_O_NOFOLLOW
JL_O_NONBLOCK
JL_O_PATH
JL_O_RANDOM
JL_O_RDONLY
JL_O_RDWR
JL_O_RSYNC
JL_O_SEQUENTIAL
JL_O_SHORT_LIVED
JL_O_SYNC
JL_O_TEMPORARY
JL_O_TMPFILE
JL_O_TRUNC
JL_O_WRONLY

Enum constant for the `open` syscall, where `JL_O_*` corresponds to the `O_*` constant.
Copy link
Member

@stevengj stevengj Feb 9, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not an "enum" in the sense of a Julia @enum value. They are just UInt32 constants.

(For some reason, JL_O_TMPFILE is a UInt16, though?? Is this a bug?)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah, a lot of these are defined incorrectly now, including being the wrong type in some cases, and that they don't follow the UV names that are now consistently defined for them instead our current ad-hoc definitions

See [the libuv docs](https://docs.libuv.org/en/v1.x/fs.html#file-open-constants) for more details.
"""
(:JL_O_APPEND, :JL_O_ASYNC, :JL_O_CLOEXEC, :JL_O_CREAT, :JL_O_DIRECT,
:JL_O_DIRECTORY, :JL_O_DSYNC, :JL_O_EXCL, :JL_O_FSYNC, :JL_O_LARGEFILE,
:JL_O_NOATIME, :JL_O_NOCTTY, :JL_O_NDELAY, :JL_O_NOFOLLOW, :JL_O_NONBLOCK,
:JL_O_PATH, :JL_O_RANDOM, :JL_O_RDONLY, :JL_O_RDWR, :JL_O_RSYNC,
:JL_O_SEQUENTIAL, :JL_O_SHORT_LIVED, :JL_O_SYNC, :JL_O_TEMPORARY,
:JL_O_TMPFILE, :JL_O_TRUNC, :JL_O_WRONLY)

const S_IFDIR = 0o040000 # directory
const S_IFCHR = 0o020000 # character device
const S_IFBLK = 0o060000 # block device
Expand Down Expand Up @@ -31,6 +70,36 @@ const S_IWOTH = 0o0002 # write by other
const S_IXOTH = 0o0001 # execute by other
const S_IRWXO = 0o0007 # mask for other permissions

"""
S_IRUSR
S_IWUSR
S_IXUSR
S_IRGRP
S_IWGRP
S_IXGRP
S_IROTH
S_IWOTH
S_IXOTH

Constants for file access permission bits.
The general structure is `S_I[permission][class]`
where `permission` is `R` for read, `W` for write, and `X` for execute,
and `class` is `USR` for user/owner, `GRP` for group, and `OTH` for other.
"""
(:S_IRUSR, :S_IWUSR, :S_IXUSR, :S_IRGRP, :S_IWGRP, :S_IXGRP, :S_IROTH, :S_IWOTH, :S_IXOTH)

"""
S_IRWXU
S_IRWXG
S_IRWXO

Constants for file access permission masks, i.e. the combination of read, write,
and execute permissions for a class.
The general structure is `S_IRWX[class]`
where `class` is `U` for user/owner, `G` for group, and `O` for other.
"""
(:S_IRWXU, :S_IRWXG, :S_IRWXO)

export File,
StatStruct,
# open,
Expand All @@ -48,7 +117,6 @@ export File,
JL_O_SEQUENTIAL,
JL_O_RANDOM,
JL_O_NOCTTY,
JL_O_NOCTTY,
JL_O_NONBLOCK,
JL_O_NDELAY,
JL_O_SYNC,
Expand Down
2 changes: 1 addition & 1 deletion test/filesystem.jl
Original file line number Diff line number Diff line change
Expand Up @@ -44,5 +44,5 @@ end
@testset "Base.Filesystem docstrings" begin
undoc = Docs.undocumented_names(Base.Filesystem)
@test_broken isempty(undoc)
@test undoc == [:File, :Filesystem, :JL_O_APPEND, :JL_O_ASYNC, :JL_O_CLOEXEC, :JL_O_CREAT, :JL_O_DIRECT, :JL_O_DIRECTORY, :JL_O_DSYNC, :JL_O_EXCL, :JL_O_FSYNC, :JL_O_LARGEFILE, :JL_O_NDELAY, :JL_O_NOATIME, :JL_O_NOCTTY, :JL_O_NOFOLLOW, :JL_O_NONBLOCK, :JL_O_PATH, :JL_O_RANDOM, :JL_O_RDONLY, :JL_O_RDWR, :JL_O_RSYNC, :JL_O_SEQUENTIAL, :JL_O_SHORT_LIVED, :JL_O_SYNC, :JL_O_TEMPORARY, :JL_O_TMPFILE, :JL_O_TRUNC, :JL_O_WRONLY, :S_IRGRP, :S_IROTH, :S_IRUSR, :S_IRWXG, :S_IRWXO, :S_IRWXU, :S_IWGRP, :S_IWOTH, :S_IWUSR, :S_IXGRP, :S_IXOTH, :S_IXUSR, :cptree, :futime, :rename, :sendfile, :unlink]
@test undoc == [:File, :Filesystem, :cptree, :futime, :rename, :sendfile, :unlink]
end