← index #2929Issue #2466
Duplicate · high · value 2.482
QUERY · ISSUE

VFS FatFS: mkdir with trailing slash fails when it should succeed

openby dpgeorgeopened 2017-03-03updated 2017-03-08

On CPython and unix uPy, os.mkdir('directory/') makes the requested directory. But on bare metal ports using VFS with FatFS it fails with ENOENT because of the trailing slash. I'd say this should be fixed. (And in fact CPy and unix uPy allow any number of trailing slashes).

CANDIDATE · ISSUE

stmhal: os directory operations throw cryptic errors on paths with trailing '/'

closedby ryannathansopened 2016-09-30updated 2024-09-29

It seems as though directory operations (listdir, mkdir, chdir, etc.) with the 'os' module throw cryptic errors when the path contains a trailing '/'. For example: '/sd/cache/' as opposed to the working '/sd/cache'.

>>> os.listdir('/flash/cache/')
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
OSError: [Errno 22] EINVAL

>>> os.listdir('/flash/cache')
[]
>>> os.mkdir('/sd/cache/test2/')
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
OSError: Error creating directory '/sd/cache/test2/'
>>> os.mkdir('/sd/cache/test2')

>>> os.chdir('/flash/cache/')
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
OSError: No such file or directory: '/flash/cache/'
>>> os.chdir('/flash/cache')

Keyboard

j / / n
next pair
k / / p
previous pair
1 / / h
show query pane
2 / / l
show candidate pane
c
copy suggested comment
r
toggle reasoning
g i
go to index
?
show this help
esc
close overlays

press ? or esc to close

copied