Ruby/File Directory/world readable

Материал из Wiki.crossplatform.ru

Перейти к: навигация, поиск

File permissions. Use File.chmod to set permissions (system dependent).

f = "/usr/bin/ruby"      # A filename for the examples below
File.readable?(f)        # Can we read the file?
File.writable?(f)        # Can we write the file? No "e" in "writable"
File.executable?(f)      # Can we execute the file?
File.world_readable?(f)  # Can everybody read it? Ruby 1.9.
File.world_writable?(f)  # Can everybody write it? Ruby 1.9.