getDirectoryContents without special directories "." and ".."

Whenever I call System.Directory.getDirectoryContents, the first thing I do is to filter out "." and "..". Is there a portable and simple way to do this? I even think that "." and ".." should not be part of the result at all, but that's a different discussion.

-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA256 I don't know about non-POSIX systems, but On 13/12/14 20:49, Henning Thielemann wrote:
I even think that "." and ".." should not be part of the result at all, but that's a different discussion. This would be horribly implicit and categorically The Wrong Thing. '.' and '..' are not magical convenience things put there by 'getDirectoryContents'. They are actual files.
Alexander alexander@plaimi.net https://secure.plaimi.net/~alexander -----BEGIN PGP SIGNATURE----- Version: GnuPG v2 Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/ iF4EAREIAAYFAlSMn6kACgkQRtClrXBQc7WblwD/ZTA567ktNlKxWeqVU3byqT9E 25roLdrDau0B7w7Vbc8BALMasSFXJUcjhxNjaQGgpHj/ZAhomyqAvq6tScU1P4+Z =YSzG -----END PGP SIGNATURE-----

On Sat, 13 Dec 2014, Alexander Berntsen wrote:
On 13/12/14 20:49, Henning Thielemann wrote:
I even think that "." and ".." should not be part of the result at all, but that's a different discussion.
This would be horribly implicit and categorically The Wrong Thing. '.' and '..' are not magical convenience things put there by 'getDirectoryContents'. They are actual files.
In the 'unix' package this would be the right behaviour, but I think not in 'directory'.

-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA256 On 13/12/14 21:24, Henning Thielemann wrote:
In the 'unix' package this would be the right behaviour, but I think not in 'directory'. «getDirectoryContents dir returns a list of all entries in dir.» There is nothing about the name or documentation of the function that implies it will leave out random files from its result.
Alexander alexander@plaimi.net https://secure.plaimi.net/~alexander -----BEGIN PGP SIGNATURE----- Version: GnuPG v2 Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/ iF4EAREIAAYFAlSMohsACgkQRtClrXBQc7W1IgD/UmTIl1BqfX/XWoRLK7sXLinr n4/eHWNjsSz8QoOK3O8BAI98lhQOa+K/UDV36hBjEWc2/ydSWvjUVPSlKLcq6wI8 =U3fO -----END PGP SIGNATURE-----

You can use `ls` in the shelly package which besides filtering '.' and '..'
will also give relative results if a relative path is given
On Sat, Dec 13, 2014 at 12:31 PM, Alexander Berntsen
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA256
On 13/12/14 21:24, Henning Thielemann wrote:
In the 'unix' package this would be the right behaviour, but I think not in 'directory'. «getDirectoryContents dir returns a list of all entries in dir.» There is nothing about the name or documentation of the function that implies it will leave out random files from its result.
Alexander alexander@plaimi.net https://secure.plaimi.net/~alexander -----BEGIN PGP SIGNATURE----- Version: GnuPG v2 Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/
iF4EAREIAAYFAlSMohsACgkQRtClrXBQc7W1IgD/UmTIl1BqfX/XWoRLK7sXLinr n4/eHWNjsSz8QoOK3O8BAI98lhQOa+K/UDV36hBjEWc2/ydSWvjUVPSlKLcq6wI8 =U3fO -----END PGP SIGNATURE----- _______________________________________________ Libraries mailing list Libraries@haskell.org http://www.haskell.org/mailman/listinfo/libraries
participants (3)
-
Alexander Berntsen
-
Greg Weber
-
Henning Thielemann