Skip to content

Draft: Identify macOS UNIX-specific system directories#18

Open
jakewilliami wants to merge 11 commits intomasterfrom
macos-system-files
Open

Draft: Identify macOS UNIX-specific system directories#18
jakewilliami wants to merge 11 commits intomasterfrom
macos-system-files

Conversation

@jakewilliami
Copy link
Copy Markdown
Owner

@jakewilliami jakewilliami commented Sep 26, 2022

According to this, there as some UNIX-specific system directories that exist as part of the BSD-layer which are important and hidden by default. We need some way of identifying these.

Addresses #1.

Related question.

TODO:

  • Determine if file is hidden due to being a system directory
    • Implement _issystemdir function
    • Implement Item Info (ref)
      • Write implementation
        • Write main implementation (010c589)
        • Construct LSItemInfoRecord struct properly
        • Ensure all functions are not deprecated (d364ce1)
  • Make a decision about realpath vs normpath (ref) (edit 2025: has this been resolved by PathStruct?)
  • Implement unit tests
  • Write docstrings

Getting back to the task of checking whether a directory is a _system_
directory, I reviewed an old link I posted in #1:
https://stackoverflow.com/a/1140345/12069968.  While a lot of these
function appear to be deprecated now, it seems to work somewhat well.
For example, `_isinvisible_alt` returns `true` on all UNIX-specific
directories listed in the macOS resources for this type of hidden
file.

We still need to:
  - Implement tests for all of these UNIX-specific directories;
  - Find non-deprecated system calls to obtain the same information;
  - Correctly construct LSItemInfoRecord (rather than allocating a
    reasonably large buffer because I don't know how large it needs
    to be), and find the correct offset for flags.

Addresses #1

Ref:
#1 (comment)

```
julia> HiddenFiles._isinvisible_alt("/bin")
true

julia> HiddenFiles._isinvisible_alt("/dev/")
true

julia> HiddenFiles._isinvisible_alt("/dev")
true

julia> HiddenFiles._isinvisible_alt("/etc")
true

julia> HiddenFiles._isinvisible_alt("/sbin/")
true

julia> HiddenFiles._isinvisible_alt("/sbin")
true

julia> HiddenFiles._isinvisible_alt("/tmp")
true

julia> HiddenFiles._isinvisible_alt("/usr")
true

julia> HiddenFiles._isinvisible_alt("/var")
true
```
Moved _isinvisible_alt to main module file, and renamed to
_isinvisible_macos_item_info, and corrected tests accordingly.

Currently tests are failing because `realpath` expands some
directories (e.g., `/tmp`) to `/private/tmp`.  I should perhaps use
`normpath` instead of `realpath`.
@jakewilliami jakewilliami force-pushed the master branch 9 times, most recently from c82f365 to 3c1e657 Compare June 20, 2025 05:28
Accidentally made it the same value as (the deprecated) value
KLS_ITEM_INFO_IS_INVISIBLE.
I think this package came out in 2014

    6f46bde - initial empty commit (Wed 15 Oct 2014) <@MikeInnes>

But it wasn't working on Julia till Tim picked it up in 2024

    91eda41 - Replace REQUIRE with Project.toml. (Tue 28 Feb 2023) <@maleadt>

Which is *after* my initial work on HiddenFiles.jl

    243ee48 - Initial commit (Wed 24 Aug 2022) <@jakewilliami>

I think its current state would be easier to work with.

See #8
Stat was behaving stangely (i.e., differently given /tmp and its real
path (see 54ced37)).  In order to remove one thing from the
equation (i.e., getting the offset wrong), I have moved the output of
stat into its own struct, allowing me to directly access the fields I
need.

Closes #14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant