我的文件夹结构是这样的:我打开一个文件夹,然后使用f_chdir将目录更改到该文件夹。问题是f_chdir不更改目录结构变量。
-A1
| A11
| |
| A11.mp3
| A12
| |
| A12.mp3
| A1.mp3
-A2
| A21
| |
| A21.mp3
| A22
| |
| A22.mp3
| A2.mp3
root_path = "/A1";
newPath = "/A1/A11";
f_opendir(dir,root_path );
f_chdir(newPath);
f_readdir(dir,fno);// This results in fno.fname = "/A12"
如何更改:
f_readdir(dir,fno);// This results in fno.fname = "/A12"
对这种行为?:
f_readdir(dir,fno);// Resulting in fno.fname = "A11.mp3"
2条答案
按热度按时间anauzrmj1#
f_readdir
仅适用于已打开的目录。f_chdir
不会以任何方式影响dir
变量。如果要更新dir
,请重新打开所需的目录:或使用点目录:
r8xiu3jd2#
我已经开发了一个版本的f_chdir,改变目录。它将不需要关闭一个目录,并重新打开它。我想知道是否有什么问题是与我的实现: