mirror of
https://github.com/licsber/micropython.git
synced 2024-09-20 00:50:24 +08:00
be28829ae8
The unwritten API contract expected of a VFS.getcwd() by mp_vfs_getcwd() is that its return value should be either "" or "/" when the CWD is at the root of the VFS and otherwise start with a slash and not end with a slash. This was not correctly implemented in VfsPosix for instances with a non-empty root - the required leading slash, if any, was cut off because the root length includes a trailing slash. This would result in missing slashes in the middle of the return value of os.getcwd() or in uninitialized garbage from beyond a string's null terminator when the CWD was at the VFS root. Signed-off-by: Christian Walther <cwalther@gmx.ch>
24 lines
489 B
Plaintext
24 lines
489 B
Plaintext
listdir("/"): ['subdir']
|
|
listdir("."): ['subdir']
|
|
getcwd() in {"", "/"}: True
|
|
chdir("subdir"): None
|
|
getcwd(): /subdir
|
|
mkdir("two"): None
|
|
listdir("/"): ['subdir']
|
|
listdir("/subdir"): ['file.py', 'one', 'two']
|
|
listdir("."): ['file.py', 'one', 'two']
|
|
print('hello')
|
|
hello
|
|
<module 'file' from 'file.py'>
|
|
chdir("/mnt/dir"): None
|
|
getcwd(): /mnt/dir
|
|
chdir("/mnt"): None
|
|
getcwd(): /mnt
|
|
chdir("/"): None
|
|
getcwd(): /
|
|
chdir("/mnt/dir"): None
|
|
getcwd(): /mnt/dir
|
|
chdir(".."): None
|
|
getcwd(): /mnt
|
|
False
|