I wonder how to interpret the output of stat(), one example is the field “mode”.
Unfortunately, the documentation is not very helpful for me, how can I transfer this in something like “(-rw-rw-rw-)”, or even more comfortable? Is there package around that helps?
Here my script snippet to figure out what is behind the output of “filemode() / stat().mode”
s_fn = raw"C:\tmp\somefile.txt"
if isfile(s_fn)
println("stat(", s_fn, "):")
println(stat(s_fn))
else
error("File: \"", s_fn, "\" does not exist!")
end
mode_of_file = stat(s_fn).mode; # alternative: filemode()
typeof_of_file = typeof(mode_of_file); # UInt64
typeof_converted_to_string = string(mode_of_file)
And how do I interpret the bitfield which is the output of “uperm()”?
I have read the documentation of the package “BitsFields” but I still do not understand,
if this package is useful to read the UInt8-bitfield of “uperm()”
Here a code snippet to clarify the situation for me:
s_bitstring = bitstring(uperm("Project.toml"))
if s_bitstring[8] == '1'
println("File: \"Project.toml\" is executable!")
end
if s_bitstring[7] == '1'
println("File: \"Project.toml\" has write permission.")
end
if s_bitstring[6] == '1'
println("File: \"Project.toml\" has read permission.")
end