chmod on Windoze

P

Phlip

Rubies:

I'm aware the answer is "because MS Windows is inferior", and I certainly
have no intention of besmirching Ruby, but...

Why does File.chmod() only work on GNU / Un*x? Why does it punt on Windows?
Has someone fixed this since last I checked? Shelling to ATTRIB is icky.

CygWin doesn't have this >cough< problem...
 
D

Daniel Berger

Phlip said:
Rubies:

I'm aware the answer is "because MS Windows is inferior", and I certainly
have no intention of besmirching Ruby, but...

Why does File.chmod() only work on GNU / Un*x? Why does it punt on Windows?
Has someone fixed this since last I checked? Shelling to ATTRIB is icky.

CygWin doesn't have this >cough< problem...

Why can't I do CreateProcess() on Unix? Windows doesn't have this
problem.

Seriously, MS Windows just doesn't do permissions the way Unix does,
though it does have the equivalent of ACL that most flavors of Unix
have. See win32-file if you want to tinker with it.

Oh, and actually, File.chmod *does* work on Windows...kinda. You can
use 0444 to make a file read-only, or 0644 to make it writeable (or
rather, to make it not read-only). You can do trickier things with
win32-file.

Regards,

Dan
 
J

James Britt

Martin said:
Your loss - he answered your question downstream.


I'd venture to guess that if someone is looking is looking for help with
some tool or application or OS, using /. script-kiddie slang, such as
"Windoze", or beginning a request for help by knocking the subject
matter, is probably not the best way to encourage those who may know the
answer to pitch in.

James

--

http://www.ruby-doc.org - The Ruby Documentation Site
http://www.rubyxml.com - News, Articles, and Listings for Ruby & XML
http://www.rubystuff.com - The Ruby Store for Ruby Stuff
http://www.jamesbritt.com - Playing with Better Toys
 
P

Phlip

James said:
I'd venture to guess that if someone is looking is looking for help with
some tool or application or OS, using /. script-kiddie slang, such as
"Windoze", or beginning a request for help by knocking the subject matter,
is probably not the best way to encourage those who may know the answer to
pitch in.

So "you asked a stupid question, so you deserve to get flamed". Okay.

(For those curious about the actual topics, 0444 and 0644 started working,
so I don't know why historically they did not for me. And CreateProcess()
and fork() are sufficiently different that one should not be expected to
emulate the other...)
 
O

ogilthorpe

James said:
So "you asked a stupid question, so you deserve to get flamed". Okay.

(For those curious about the actual topics, 0444 and 0644 started worki= ng,
so I don't know why historically they did not for me. And CreateProcess= ()
and fork() are sufficiently different that one should not be expected t= o
emulate the other...)

But really though, thanks Daniel for your prompt, accurate (to the best o=
f
_my_ knowledge) and sincere answer to a question that is difficult to ask
correctly, nevermind answer.

Can we flesh this out just a little bit more though? The impression that
I've always gotten is that it isn't really possible to map across from th=
e
Unix permission mechanism to the one implemented on Windows. The bits
that you set when you chmod something don't really translate directly int=
o
some of the more complex permissions that you can set on Windows systems,
right?

So I don't think that Ruby (or anybody else) can hope to have a permissio=
n
handling aspect that is both cross-platform and correct. Am I wrong?
 
J

James Britt

Phlip said:
James Britt wrote:




So "you asked a stupid question, so you deserve to get flamed". Okay.

Well, the question itself was a good one.

I spend a lot of time working on Windows, and have picked up assorted
knowledge and tips, but I'm likely not going to be overly interested in
sharing this info with someone who is dismissive of the platform right
from the get-go. It suggests, perhaps incorrectly, that the questioner
really isn't serious, and hasn't bothered to do some basic groundwork
because the topic is beneath them.

For example, if I had a question about something on a Mac, and I asked
questions about Crapintosh or Hackintosh or Crapple computers, I'd
deserve to be ignored or flamed.

James


--

http://www.ruby-doc.org - The Ruby Documentation Site
http://www.rubyxml.com - News, Articles, and Listings for Ruby & XML
http://www.rubystuff.com - The Ruby Store for Ruby Stuff
http://www.jamesbritt.com - Playing with Better Toys
 
D

Daniel Berger

(e-mail address removed) wrote:

Can we flesh this out just a little bit more though? The impression that
I've always gotten is that it isn't really possible to map across from the
Unix permission mechanism to the one implemented on Windows. The bits
that you set when you chmod something don't really translate directly into
some of the more complex permissions that you can set on Windows systems,
right?

Correct. For whatever reason MS decided to support a limited form of
chmod where you could make a file read-only, which probably just calls
SetFileAttributes() behind the scenes. I'm not sure why they did this,
other than to try to be more *nix compatible. In the end I think it
just confuses people.
So I don't think that Ruby (or anybody else) can hope to have a permission
handling aspect that is both cross-platform and correct. Am I wrong?

No, you're not wrong.

Regards,

Dan
 
P

Phlip

James said:
For example, if I had a question about something on a Mac, and I asked
questions about Crapintosh or Hackintosh or Crapple computers, I'd deserve
to be ignored or flamed.

Mr Manners reminds the Gentle Poster that, given a choice between
undeservedly flaming MS or deservedly the topic of this newsgroup, the
original poster chose to make a joke of the dilemma...

Back on subject, MS didn't write File.chmod(). CygWin's chmod system
apparently covers this by leaping into the NTFS Access Control Lists. I'm
not claiming Ruby should bother; I just accidentally thought it was having
trouble with the read-only bit.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,183
Messages
2,570,968
Members
47,524
Latest member
ecomwebdesign

Latest Threads

Top