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

Draft: Identify macOS UNIX-specific system directories #18

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

jakewilliami
Copy link
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)
  • 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`.
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