cxong / tinydir

Lightweight, portable and easy to integrate C directory and file reader

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Cannot open drive root on Windows

wojdyr opened this issue · comments

Hello,

I'm struggling to open the top directory on Windows (C:). Other directories are fine.
For instance, when using file_open_sample.c I get:

C:\msys32\home\IEUser\tinydir>a.exe C:\
Error opening file: No error

C:\msys32\home\IEUser\tinydir>a.exe C:
Error opening file: No error

C:\msys32\home\IEUser\tinydir>a.exe "C:\Program Files"
Path: C:/Program Files
Name: Program Files
Extension:
Is dir? yes
Is regular file? no

i used MinGW here, but I think it's the same with MSVC.
Am I missing something?

commented

This is either a bug or intended; tinydir_file_open is intended for files and the way it works is it looks at the parent folder and then tries to find the file within that folder. For drive roots there is no parent folder.
For now please use tinydir_open if you know it will be a folder. In the meantime I'll try adding a special case here where there is no parent folder.

My test:

  1. Windows: file_open_sample C:\ returns "Error opening file: No such file or directory"
  2. Linux: file_open_sample / returns "Error opening file: No such file or directory"
  3. Linux: file_open_sample /usr returns "Path://usr ***"

The first is fixed in #67.
The second is not fixed yet fixed now.