Re: umask() and chmod()
| From: | David T-G | Date: | Thu, 15 Apr 2004 20:08:29 +0000 |
| Subject: | Re: umask() and chmod() | ||
| References: | 1 2 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-183560@lists.php.net to get a copy of this message | ||
Mike, et al --
Responding to your second one first...
..and then Ford, Mike [LSS] said...
%
% On 15 April 2004 16:26, David T-G wrote:
%
% > When I move_uploaded_file() a file into place, I want to give it the
..
% > but chmod() needs a permissions setting rather than a umask.
% >
% > The challenge is in representing this as octal. With some
..
%
% I've just re-read this properly, and realised you want to feed the end value to chmod() -- so
all the guff about octal representations is a complete red herring. What you want to feed to the
2nd parameter of chmod() is just:
%
% 0777 ^ umask()
Ah! Cool! A bitwise NOT operator!
Perfect :-)
%
% Within the computer, the value is just an integer, and that's what umask() provides and what
chmod() expects for its 2nd argument -- so no conversions required. Even 0777 is an integer --
it's just a different way of representing 511 which is more understandable to us poor humans in
that context.
Right.
%
% Your original offering was, in fact, barking up the wrong tree -- what it was printing out,
although it looked right, was the *decimal* value 664, which in octal would be 01230 and really not
what you want.
Right; I wanted to get it as a string and then turn the string into
octal.
%
% I guess what this boils down to is that integers are just integers when you manipulate them in
your script -- octal, decimal, hex and any other representations are just convenient notations for
making them more human readable.
Yep :-)
%
% Cheers!
%
% Mike
Thanks again & HAND
:-D
--
David T-G
davidtg@justpickone.org
http://justpickone.org/davidtg/ Shpx gur
Pbzzhavpngvbaf Qrprapl Npg!