Ruby/File Directory/world readable

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

(Различия между версиями)
Перейти к: навигация, поиск

Версия 17:10, 26 мая 2010

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.