问题描述
我试图找出一个办法,我可以使用C ++ code改变我的电流输出目录 - 也需要一个方法是平台无关。
I'm trying to figure out a way where I can change my current output directory using C++ code - and also need that method to be platform agnostic.
我找到了direct.h头文件是Windows兼容,这是UNIX / POSIX兼容的unistd.h中。任何解决方案?
I found the direct.h header file which is Windows compatible, and the unistd.h which is UNIX/POSIX compatible. Any solutions?
干杯。
推荐答案
的 CHDIR
函数可以使用了POSIX(的)和Windows(被称为存在,但一个别名 CHDIR
存在)。
The chdir
function works on both POSIX (manpage) and Windows (called _chdir
there but an alias chdir
exists).
这两种实现上的错误返回成功零和-1。正如你可以在手册页看到,更显尊贵errno值是POSIX变种可能的,但不应该真正发挥作用。
Both implementations return zero on success and -1 on error. As you can see in the manpage, more distinguished errno values are possible in the POSIX variant, but that shouldn't really make a difference.
这篇关于改变当前的工作目录ç的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!