Ruby/サンプル/ディレクトリ・ファイルの有無確認
の編集
Top
/
Ruby
/
サンプル
/
ディレクトリ・ファイルの有無確認
[
トップ
] [
編集
|
差分
|
バックアップ
|
添付
|
リロード
] [
新規
|
一覧
|
検索
|
最終更新
|
ヘルプ
]
-- 雛形とするページ --
(no template pages)
#navi(../) * ディレクトリ・ファイルの有無確認方法 [#p91bf36f] ファイルまたはディレクトリが存在するかしないかを確認するサンプルコードを以下に記します。~ 有無確認は以下の構文で簡単に調べることができます。 File.exist?(ファイル名orディレクトリ名) #contents #htmlinsertpcsp(ll-top.html,ll-sp.html) ** サンプルコード [#bba027a0] 以下にサンプルコードを記します。 #ref(file_exist.rb) # check directory p File.exist?("/tmp") p File.exist?("/hoge") # check file p File.exist?("/etc/hosts") p File.exist?("/etc/hoge") ** 実行結果 [#f5f8234d] $ ruby file_exist.rb true false true false 存在する場合はtrue、しない場合はfalseが返却されます。 #htmlinsertpcsp(ll-btm.html,ll-sp.html)
タイムスタンプを変更しない
#navi(../) * ディレクトリ・ファイルの有無確認方法 [#p91bf36f] ファイルまたはディレクトリが存在するかしないかを確認するサンプルコードを以下に記します。~ 有無確認は以下の構文で簡単に調べることができます。 File.exist?(ファイル名orディレクトリ名) #contents #htmlinsertpcsp(ll-top.html,ll-sp.html) ** サンプルコード [#bba027a0] 以下にサンプルコードを記します。 #ref(file_exist.rb) # check directory p File.exist?("/tmp") p File.exist?("/hoge") # check file p File.exist?("/etc/hosts") p File.exist?("/etc/hoge") ** 実行結果 [#f5f8234d] $ ruby file_exist.rb true false true false 存在する場合はtrue、しない場合はfalseが返却されます。 #htmlinsertpcsp(ll-btm.html,ll-sp.html)
テキスト整形のルールを表示する
添付ファイル:
file_exist.rb
494件
[
詳細
]