Godot: Directory - A way to get_next() without getting . or ..

Created on 17 Dec 2016  路  8Comments  路  Source: godotengine/godot

Every single time I work with directory, I never want to use . or .. that appears during get_next().
If there was a way to disable it all-together, we would save time and work. :)

Would anyone mind adding a Directory function that allows us to enable/disable . .. from appearing during get_next()?

Ex.:

var dir = Directory.new()
dir.ignore_dots(true)
enhancement junior job core

Most helpful comment

I'd rather prefer to extend dir.list_dir_begin() with optional parameters.
Like dir.list_dir_begin(ignore_internal, ignore_hidden)
I'm not a UNIX expert. Are dotted file system entries the only way to "hide" them? For a Windows user, this would be really confusing.

All 8 comments

Should this method also disable unix-hidden files and directories? (e.g. .fscache, .git/...)

Good question.
Perhaps we could use dir.ignore_hidden(true) that would cover those as well. :)

Does this https://github.com/godotengine/godot/issues/7158 (File browser "up to folder" duplicate icons) also belong together?

@puppetmaster- No.

The other issue is for the FileDialog/EditorFileDialog node, while this is for the Directory class.

I'd rather prefer to extend dir.list_dir_begin() with optional parameters.
Like dir.list_dir_begin(ignore_internal, ignore_hidden)
I'm not a UNIX expert. Are dotted file system entries the only way to "hide" them? For a Windows user, this would be really confusing.

@RayKoopa Sounds cool, though ignore_internal sounds really confusing to me (and I'm a linux user even).
Also, ignore_hidden should ignore .<stuff> as well as <stuff>~ on linux, mind it. On windows, I don't remember how hidden files were made, so can't really help there :smiley:.
Edit: realised that the above about <stuff>~ being considered hidden is untrue, so, disregard it.

I was about to name them skip_hidden and skip_navigational now... is that better? I wonder if . and .. have a real term to describe them both...

Also I'll let Windows additionally ignore hidden entries by attribute. The . and .. and .prefix skipping is solved with common code in the _Directory class. Nevermind, someone already did some work there I can use for a cleaner implementation.

Fixed by #7563.

Was this page helpful?
0 / 5 - 0 ratings