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

Directory listing should not show hidden or system files #1532

Closed
ghost opened this issue Jun 11, 2016 · 10 comments
Closed

Directory listing should not show hidden or system files #1532

ghost opened this issue Jun 11, 2016 · 10 comments

Comments

@ghost
Copy link

ghost commented Jun 11, 2016

Hello,

if a file is hidden (or is system file) by operating system in OS's file browser, it should be hidden also in Jupyter's file / directory listing.

This happens at least on my Windows 8 system, when I launch notebook and go to browser, it shows hidden and system files in the listing.

@Carreau
Copy link
Member

Carreau commented Jun 16, 2016

We do have logic that hides these files. The probable cause is tha the is_hidden(...) function is broken.

If you can figure out why it does not work, and/or what should be added, that would be great, as none of us has windows machine, it's hard to narrow down.

@ghost
Copy link
Author

ghost commented Jun 20, 2016

@Carreau I looked at it and I think it might be because when comparing return value from GetFileAttributesW, it is compared only against 0x02, which is hidden-attribute. But when the file is also system file at same time, it probably should be taken into account, right? At least this comparision against 0x02 seems to return 0 for files which has both system and hidden attributes.

Like this:

_win32_FILE_ATTRIBUTE_HIDDEN = 0x02 | 0x04 # 0x04 means system file
# ...
if attrs > 0 and attrs & _win32_FILE_ATTRIBUTE_HIDDEN:
# ...

@takluyver
Copy link
Member

I think that would only hide files that are both hidden and system. You probably need something like:

if attrs > 0 and ((attrs & HIDDEN) or (attrs & SYSTEM)):

@ghost
Copy link
Author

ghost commented Jun 20, 2016

@takluyver ok, but hope the idea was correct

@ghost
Copy link
Author

ghost commented Jun 21, 2016

Here's the list of file attribute constants:

@takluyver
Copy link
Member

I think the idea is probably correct - I'm not very familiar with Windows file attributes, but it sounds reasonable.

@ghost
Copy link
Author

ghost commented Jun 29, 2016

Hello again! I looked at it more, and noticed, that I was wrong. System files seems to be hidden also, so just checking if it has hidden attribute should work.

But here the path-variable is modified and it contains only directory name and is always the same. And after modifying, it is used to get attributes for that path, which is always the same.

You should check here the abs_path-variable. Changing this line to use abs_path, it works as it should.

@takluyver
Copy link
Member

Good catch, do you want to make a PR?

@ghost
Copy link
Author

ghost commented Jun 29, 2016

Done.

@minrk minrk modified the milestones: 5.0, 4.2.2 Jul 6, 2016
minrk added a commit that referenced this issue Aug 2, 2016
minrk added a commit to minrk/notebook that referenced this issue Aug 2, 2016
minrk added a commit to minrk/notebook that referenced this issue Aug 3, 2016
minrk added a commit to minrk/notebook that referenced this issue Aug 3, 2016
@rgerkin
Copy link

rgerkin commented Sep 1, 2016

I am currently in a situation where I would like the hidden files to be shown (at least certain ones), so that I could edit them in the Jupyter editor, or screenshot a directory listing showing a hidden file (which happens to be a configuration file I'd like to highlight).

Is there any interest in a configuration option that would show hidden files?

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Apr 24, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

4 participants