Fileクラス
ファイルアクセス用クラス
Method: absolute_path
absolute_path(file_name, dir_string=nil) -> String
file_nameで指定されたパスの絶対パスの文字列を返す。
dir_stringは起点となるフォルダで、nilが指定された場合はカレントフォルダを起点にする。
'~'は展開されない。
p File::absolute_path(Dir::pwd)
#=> "c:/Users/hisa/Programming/ruby"
p File::absolute_path(".")
#=> "c:/Users/hisa/Programming/ruby"
p File::absolute_path("..")
#=> "c:/Users/hisa/Programming/ruby/~/Canon"
p File::absolute_path("..", 'c:\home\hisa')
#=>"c:/home"
Method: atime
atime(filename) -> Time
最終アクセス時刻返却
p File::atime("..").to_s
#=> "2015-03-17 14:22:29 +0900"
p File::atime("File_atime.rb").to_s
#=> "2015-12-09 16:49:04 +0900"
0 件のコメント:
コメントを投稿