Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can a failed fopen impact the filesystem?

Tags:

c

unix

If fopen( path, "w" ) succeeds, then the file will be truncated. If the fopen fails, are there an guarantees that the file is not modified?

like image 972
William Pursell Avatar asked Mar 30 '11 16:03

William Pursell


1 Answers

No there are no guarantees about the state of a file if fopen(path, "w") fails. The failure could be coming from any operation from opening the file, committing the truncation to disk, etc ... The only guarantee a failure provides is that you don't have access to the file.

like image 170
JaredPar Avatar answered Sep 30 '22 02:09

JaredPar