So, I just write:
int fdes = open(path, O_WRONLY | O_CREAT | O_TRUNC);
And if the file that the path
referred to doesn't exist, this code works. But if it does, the code returns with errno
13 : Permission Denied. I never use the O_EXCL
mode at all.
I have searched for the solution to this problem a long time and I am really confused. Can you explain the problem?
I use the GCC for windows(4.5.2). Your answer will be appreciated.
O_CREAT
, you should supply a mode as the third argument to open()
.Note that (on Unix at least) you can create a file for writing with mode 0444
(or even 0
); the permissions affect everyone else, but not the process that created the file while it uses the file descriptor that created the file.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With