Notebook: Directory listing should not show hidden or system files

Created on 11 Jun 2016  路  10Comments  路  Source: jupyter/notebook

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.

Needs Info Bug

Most helpful comment

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?

All 10 comments

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.

@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:
# ...

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)):

@takluyver ok, but hope the idea was correct

Here's the list of file attribute constants:

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

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.

Good catch, do you want to make a PR?

Done.

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?

Was this page helpful?
0 / 5 - 0 ratings