Changed implementation for listing files in a directory (should work also under Linux)