Skip to content

Refine real path expansion logic#19

Merged
jakewilliami merged 12 commits intomasterfrom
real-path-expansion
Sep 27, 2022
Merged

Refine real path expansion logic#19
jakewilliami merged 12 commits intomasterfrom
real-path-expansion

Conversation

@jakewilliami
Copy link
Copy Markdown
Owner

We need to expand the path into its real path in order to correctly assess whether the file begins with a full stop. However, we only need to check this for Unix. As such, we should only expand this where needed.

The reason this is an important distinction to make is due to #18, in which I realised that /tmp expands to /private/tmp on macOS, which is not a system file (despite /tmp being one).

We should probably add some tests on macOS and BSD in particular to see if our custom C calls and low-level functions still work without realpath at the top-most level, or if we need to call normpath as well.

We need to expand the path into its real path in order to correctly
assess whether the file begins with a full stop.  However, we only
need to check this for Unix.

We should probably add some tests on macOS and BSD in particular to
see if our custom C calls and low-level functions still work without
realpath at the top-most level, or if we need to call normpath as well.
For reasons described in updated documentation, the package/bundle
check for macOS should also expand to real path.  Implement tests to
test that our functionality still works.
Some internal functions need to use the real path, where some don't.
We check calculate the real path anyway, to ensure that the path
exists, so we are now going to pass it around to the individual
_ishidden-* functions for use as required.
For whatever reason, Julia < 1.2 on Windows does not error on realpath
if the path does not exist.  This is nonstandard behaviour, but the
behaviour nonetheless.  We need to try to construct the real path, and
then manually check if the path exists.
@jakewilliami
Copy link
Copy Markdown
Owner Author

jakewilliami commented Sep 26, 2022

TODO: change version number

EDIT: resolved by 9d31a1b.

@jakewilliami jakewilliami changed the title Draft: Refine real path expansion logic Refine real path expansion logic Sep 27, 2022
@jakewilliami jakewilliami merged commit c06777b into master Sep 27, 2022
@jakewilliami jakewilliami deleted the real-path-expansion branch September 27, 2022 07:41
jakewilliami added a commit that referenced this pull request Sep 27, 2022
Instead of keeping track of both the file given by the user _and_ the
real path of the file (which some internal functions require, and
others necessarily don't), we can construct a PathStruct object and
pass that around internally.  This also allows us to perform error
checking within the PathStruct object, rather than in the ishidden
function.

Related: #19.

Still to do:
  - Write documentation for PathStruct and InvaliidRealPathError
  - Implement further tests
  - Refine error checking for PathStruct constructor with method
    PathStruct(path::AbstractString, rp::AbstractString)
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