Quote Originally Posted by MK27 View Post
The person who wrote this code for you wasn't doing you any favours! The way the file permissions are set, for example (0777), is just wrong (this is not "chmod").
It is correct. chmod takes mode values in octal. 0777 is an octal constant. This is masked by the umask to produce the actual file mode. Passing 0777 as the initial mode is, in almost all circumstances, the right thing to do, since it allows the user to control his/her default file permissions via the umask.