Sha256: 58316a95c70adf5376546739710592dd2260d9db5df6e963b9efc6762fd96357
Contents?: true
Size: 941 Bytes
Versions: 1
Compression:
Stored size: 941 Bytes
Contents
class File class << self # write and create dir def write_p file, data path = file.split('/').reverse.drop(1).reverse.join('/') FileUtils.mkdir_p(path) unless File.exist?(path) self.write file, data data end def append path, content File.open(path, 'a') do |f| f.flock File::LOCK_EX f.puts content end end def ext name out = name.to_s.split('.').last.to_s.downcase [3,4].include?(out.length) ? out : nil end def delete? path if File.exist?(path) File.delete path true else false end end # exit if File.is_locked?('tmp/test.lock') def is_locked? lock_file lock_fd = File.open(lock_file, File::RDWR|File::CREAT, 0644) Timeout::timeout(0.1) do lock_fd.flock(File::LOCK_EX) return false end rescue Timeout::Error return true end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
lux-fw-0.6.2 | ./lib/overload/file.rb |