Opened 6 years ago

Closed 5 years ago

#7135 closed defect (wontfix)

VSI ReadDir: Inconsistent handling of '.' and '..' directories.

Reported by: tveastman Owned by: warmerdam
Priority: normal Milestone: closed_because_of_github_migration
Component: default Version: unspecified
Severity: normal Keywords: VSI vsis3 vsizip readdir
Cc: robert.coup@…

Description

On-disk filesystems tend to have . and .. in their directory listings, but this behaviour is inconsistent between different VSI drivers.

a local filesystem listing, dots present

   >>> gdal.ReadDir('/home/vagrant/a-local-directory')
   ['..', 'file.txt', '.']

inside a zip file: no dot files

   >>> gdal.ReadDir('/vsizip//home/vagrant/a-local-directory/a-zip-file.zip/')
   ['a-zip-file']
   >>> gdal.ReadDir('/vsizip//home/vagrant/a-local-directory/a-zip-file.zip/a-zip-file')
   ['a-subdir', 'file-one.txt']

an EMPTY s3 bucket has a single '.' for some reason:

   >>>gdal.ReadDir('/vsis3/an-irish-bucket/')
   ['.']

...but if the bucket has contents, the . disappears:
   >>> gdal.ReadDir('/vsis3/public-bucket-gdal-vsis3-tests/')
   ['alpha', 'alpha/', 'beta']

I think the presence or absence of . and .. should be consistent in all calls to ReadDir() no matter what the underlaying driver is, my personal opinion is that they be removed from listings.

Change History (3)

comment:1 by Even Rouault, 6 years ago

Would probably makes sense to remove . and .. . "." is useful for an empty directory as the return of ReadDir() is not empty then. The code, in particular in /vsicurl, /vsis3 etc, currently more or less treats NULL or len() == 0 the same, so a fix for that would require treating them differently

comment:2 by tveastman, 6 years ago

In Python, at least, it makes sense for an empty directory to simply be [], but is an empty list less meaningful at the lower level API?

comment:3 by Even Rouault, 5 years ago

Milestone: closed_because_of_github_migration
Resolution: wontfix
Status: newclosed

This ticket has been automatically closed because Trac is no longer used for GDAL bug tracking, since the project has migrated to GitHub. If you believe this ticket is still valid, you may file it to https://github.com/OSGeo/gdal/issues if it is not already reported there.

Note: See TracTickets for help on using tickets.