开发者

Verify if _tmkdir succeeds

开发者 https://www.devze.com 2022-12-10 02:32 出处:网络
Can anybody help me in finding out how to verify that _tmkdir succeeded. For example i wish to create a file within another folder. This folder i will create at runtime.开发者_StackOverflow社区 So i w

Can anybody help me in finding out how to verify that _tmkdir succeeded. For example i wish to create a file within another folder. This folder i will create at runtime.开发者_StackOverflow社区 So i will give the following command.

sFilePath = sFilePath + _T("\\P-Series Communication Logs");
_tmkdir( sFilePath );

where sFilePath would initially contain a software installation path which will be obtained from registry.

i wish to know if _tmkdir succeeded or not.

Thanks


You can check the return value of _tmkdir to see if the call succeeded. If it failed, the errno global variable indicates the reason for failure:

int result = _tmkdir(sFilePath);
if (result == 0) {
    // succeeded
}
else {
    // failed
    if (errno == EEXIST) {
        // already exists!
    }
}

For more information, look at the MSDN documentation for _tmkdir here and errno here.

I hope this helps!

0

精彩评论

暂无评论...
验证码 换一张
取 消