Re: umask() and chmod()

From: Date: Thu, 15 Apr 2004 20:21:21 +0000
Subject: Re: umask() and chmod()
References: 1 2  Groups: php.general 
Request: Send a blank email to php-general+get-183563@lists.php.net to get a copy of this message
Mike -- ..and then Ford, Mike [LSS] said... % % On 15 April 2004 17:26, David T-G wrote: % % > ...and then Ford, Mike [LSS] said... % > % % > % I'm not sure, however, that this is a totally foolproof way % > of doing it, as % > % it would fail with any permission set (however unlikely) % > where the owner % > % > Would it? Suppose I were setting it to 007; that would be 0007 with % > the leading zero and should still be fine. % % No. The way you're building it, $r would be an integer before you add the leading zero -- 007 would thus be represented as just 7, and adding the leading zero the way I've shown above would give '07'. Not good. Indeed. But of course I was trying to work with a string... % .. % > Heck, I'll take any advice I can get :-) I think, though, that the % > problem is that I'm trying to use a string -- if I can get it built % > correctly in the first place -- as an octal digit. % % Possibly, but I think you're making the whole thing more complicated than it need be. After a quick look at the manual, I'd suggest this: As I clearly was. But where did you see ^ in the manual? Oh, I see it. I had to look for it as ^ but I found it. Oops; and it's an XOR rather than a NOT. % .. % Of course, I've been quite verbose there -- the short version is: % % $r = sprintf('%04o', 0777 ^ umask()); And the final version, I'm happy to say, is chmod ($target,0777^umask()) ; and it works perfectly :-) % % ... ;)) % % Cheers! % % Mike Thanks again & HAND :-D -- David T-G davidtg@justpickone.org http://justpickone.org/davidtg/ Shpx gur Pbzzhavpngvbaf Qrprapl Npg!

« previous php.general (#183563) next »