Can chdir() accept relative paths?

ⅰ亾dé卋堺 提交于 2019-12-01 05:23:58

问题


In C on linux, can the chdir() function accept a relative path?


回答1:


Yes. The current working directory is a property of the process.


To expand on that a little - here are a couple of the relevant POSIX definitions:

  • The current working directory is defined as "a directory, associated with a process, that is used in pathname resolution for pathnames that do not begin with a slash character" (there is more detail in the section on pathname resolution).

  • chdir() is defined to set the current working directory to a pathname.

It seems somewhat circular, but there is nothing special about a "pathname" in the context of the argument chdir(); it is subject to pathname resolution as normal.



来源:https://stackoverflow.com/questions/4998530/can-chdir-accept-relative-paths

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!