Ruby/File Directory/size

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

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

Содержание

find out if a file has a length of zero (0) with zero?:

system("touch chap.txt") # Create a zero-length file with a system command
File.zero?( "chap.txt" ) # => true



Get file size?

File.size?( "myFile.txt" ) # => 594
File.size( "myFile.txt" ) # => 594



Get its size in bytes with size? or size:

File.size?( "myFile.txt" ) # => 594
File.size( "myFile.txt" ) # => 594



Getting the Size of a File

puts File.size("text.txt")