如何检查特定路径中的目录,而不是在CWD中

how to check a directory in a particular path not in CWD?

本文关键字:CWD 检查 路径 何检查      更新时间:2023-10-16

我知道要检查当前目录opendir(dir_name),但我需要检查在其他路径中,而不是在CWD(current working directory)中,

执行
时,是否存在将CWD移动到其他目录的函数?

您可以使用opendir(abs_path/dir_name)打开绝对路径abs_path下的目录dir_name

您也可以使用chdir()将cwd更改为其他目录

是,守护进程在执行时将其目录更改为root。在执行时更改工作目录的函数是chdir(PATH_TO_SET_AS_CWD)。