Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What permissions does a file written with fstream have?

Suppose I create a file for writing like this:

std::ofstream my_file("filename", std::ios_base::out | std::ios_base::trunc);

How are the permissions of this file determined? I've had a program running overnight generating files about once a minute - some are 0644 but others are 0660, and there's nothing in my code that should make it change. (I've seen that some implementations allow a third argument to set the file permissions - I'm using gcc 4.1.2 which doesn't appear to support this).

like image 838
jrb Avatar asked Jul 07 '10 09:07

jrb


1 Answers

It depends on the umask.

like image 167
Sjoerd Avatar answered Sep 25 '22 18:09

Sjoerd