From: Intransition Date: 2012-02-07T04:38:00+09:00 Subject: Make a file read-only? ------=_Part_793_13205034.1328557077962 Content-Type: multipart/alternative; boundary="----=_Part_794_8000646.1328557077962" ------=_Part_794_8000646.1328557077962 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit Hi, I can make a file writeable easy enough, mode = File.stat(file).mode File.chmod(mode | 0000200, file) But how do I make a file read-only? mode = File.stat(file).mode File.chmod(mode - 0000222, file) Subtraction doesn't work. And I've tried `&`, `|` and `^`. Do I have to do some sort compliments operation here? What's the trick to this? FYI, on the command line it's as easy as: $ chmod a-w file ------=_Part_794_8000646.1328557077962 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: 7bit Hi, I can make a file writeable easy enough,

    mode = File.stat(file).mode
    File.chmod(mode | 0000200, file)

But how do I make a file read-only?

    mode = File.stat(file).mode
    File.chmod(mode - 0000222, file)

Subtraction doesn't work. And I've tried `&`, `|` and `^`. Do I have to do some sort compliments operation here? What's the trick to this?

FYI, on the command line it's as easy as:

  $ chmod a-w file

------=_Part_794_8000646.1328557077962-- ------=_Part_793_13205034.1328557077962--