検索結果
先頭5件
-
FileUtils
. # chmod(mode , list , options = {}) -> Array (18138.0) -
ファイル list のパーミッションを mode に変更します。
...s.chmod(0644, %w(my.rb your.rb his.rb her.rb))
FileUtils.chmod(0755, 'somecommand')
FileUtils.chmod(0755, '/usr/bin/ruby', verbose: true)
# Symbolic mode
require 'fileutils'
FileUtils.chmod("u=wr,go=rr", %w(my.rb your.rb his.rb her.rb))
FileUtils.chmod("u=wrx,go=rx", 'somecommand')
FileUtils.chmod("... -
FileUtils
. # chmod _ R(mode , list , options = {}) -> Array (6114.0) -
ファイル list のパーミッションを再帰的に mode へ変更します。
...変更します。
@param mode パーミッションを8進数(absolute mode)か文字列(symbolic
mode)で指定します(FileUtils.#chmod 参照)。
@param list ファイルのリストを指定します。対象のファイルが一つの場合は文字列でも指定可能です。......二つ以上指定する場合は配列で指定します。
@param options :noop と :verbose が指定可能です。
c:FileUtils#options
@return list を配列として返します。
//emlist[][ruby]{
require 'fileutils'
FileUtils.chmod_R(0700, '/tmp/removing')
//}... -
FileTest
. # sticky?(file) -> bool (29.0) -
ファイルの sticky ビット(chmod(2) 参照)が 立っている時に真を返します。そうでない場合、ファイルが存在しない場合、あるいはシステムコールに失敗した場合などには false を返します。
...ファイルの sticky ビット(chmod(2) 参照)が
立っている時に真を返します。そうでない場合、ファイルが存在しない場合、あるいはシステムコールに失敗した場合などには false を返します。
@param file ファイル名を表す文字列か......IO オブジェクトを指定します。
//emlist[例][ruby]{
require 'fileutils'
IO.write("testfile", "")
FileUtils.chmod("o+t", "testfile")
FileTest.sticky?("testfile") # => true
FileUtils.chmod("o-t", "testfile")
FileTest.sticky?("testfile") # => false
//}... -
FileTest
. # executable _ real?(file) -> bool (13.0) -
ファイルがカレントプロセスの実ユーザか実グループで実行できる時に真を返します。そうでない場合、ファイルが存在しない場合、あるいはシステムコールに失敗した場合などには false を返します。
...ます。
@param file ファイル名を表す文字列を指定します。
//emlist[例][ruby]{
IO.write("empty.txt", "")
File.chmod(0744, "empty.txt")
FileTest.executable_real?("empty.txt") # => true
File.chmod(0644, "empty.txt")
FileTest.executable_real?("empty.txt") # => false
//}... -
FileTest
. # readable?(file) -> bool (13.0) -
ファイルがカレントプロセスにより読み込み可能な時に真を返します。そうでない場合、ファイルが存在しない場合、あるいはシステムコールに失敗した場合などには false を返します。
...は false を返します。
@param file ファイル名を表す文字列を指定します。
//emlist[例][ruby]{
IO.write("testfile", "")
File.chmod(0644, "testfile")
FileTest.readable?("testfile") # => true
File.chmod(0200, "testfile")
FileTest.readable?("testfile") # => false
//}... -
FileTest
. # setgid?(file) -> bool (13.0) -
ファイルが setgid(2) されている時に真を返 します。そうでない場合、ファイルが存在しない場合、あるいはシステムコールに失敗した場合などには false を返します。
...名を表す文字列か IO オブジェクトを指定します。
//emlist[例][ruby]{
require 'fileutils'
IO.write("testfile", "")
FileUtils.chmod("g+s", "testfile")
FileTest.setgid?("testfile") # => true
FileUtils.chmod("g-s", "testfile")
FileTest.setgid?("testfile") # => false
//}... -
FileTest
. # setuid?(file) -> bool (13.0) -
ファイルが setuid(2) されている時に真を返 します。そうでない場合、ファイルが存在しない場合、あるいはシステムコールに失敗した場合などには false を返します。
...ト file が既に close されていた場合に発生します。
//emlist[例][ruby]{
require 'fileutils'
IO.write("testfile", "")
FileUtils.chmod("u+s", "testfile")
FileTest.setuid?("testfile") # => true
FileUtils.chmod("u-s", "testfile")
FileTest.setuid?("testfile") # => false
//}... -
FileTest
. # writable?(file) -> bool (13.0) -
ファイルがカレントプロセスにより書き込み可能である時に真を返します。そうでない場合、ファイルが存在しない場合、あるいはシステムコールに失敗した場合などには false を返します。
...false を返します。
@param file ファイル名を表す文字列を指定します。
//emlist[例][ruby]{
IO.write("testfile", "test")
File.chmod(0600, "testfile")
FileTest.writable?("testfile") # => true
File.chmod(0400, "testfile")
FileTest.writable?("testfile") # => false
//}... -
Timeout
. # timeout(sec , exception _ class = nil) {|i| . . . } -> object (7.0) -
ブロックを sec 秒の期限付きで実行します。 ブロックの実行時間が制限を過ぎたときは例外 Timeout::Error が発生します。
...;$x^2+$y^2 < 1.0" | bc)
echo $x $y $c
if [ $c -eq 1 ]
then
let m1++
else
let m2++
fi
done
SHELL_EOT
}
File.chmod(0755, "loop.sh")
t = 10 # 10 秒でタイムアウト
begin
pid = nil
com = nil
Timeout.timeout(t) {
# system だととま... -
Timeout
. # timeout(sec , exception _ class , message) {|i| . . . } -> object (7.0) -
ブロックを sec 秒の期限付きで実行します。 ブロックの実行時間が制限を過ぎたときは例外 Timeout::Error が発生します。
...;$x^2+$y^2 < 1.0" | bc)
echo $x $y $c
if [ $c -eq 1 ]
then
let m1++
else
let m2++
fi
done
SHELL_EOT
}
File.chmod(0755, "loop.sh")
t = 10 # 10 秒でタイムアウト
begin
pid = nil
com = nil
Timeout.timeout(t) {
# system だととま...