Class: File
- Inherits:
-
Object
- Object
- File
- Defined in:
- lib/qdumpfs/util.rb
Class Method Summary collapse
- .anything_exist?(path) ⇒ Boolean
- .force_link(src, dest) ⇒ Object
- .force_symlink(src, dest) ⇒ Object
- .link(l, t) ⇒ Object
- .readable_file?(path) ⇒ Boolean
- .real_directory?(path) ⇒ Boolean
- .real_file?(path) ⇒ Boolean
- .split_all(path) ⇒ Object
- .utime(a, m, dir) ⇒ Object
- .utime_orig ⇒ Object
Class Method Details
.anything_exist?(path) ⇒ Boolean
25 26 27 |
# File 'lib/qdumpfs/util.rb', line 25 def self.anything_exist?(path) FileTest.exist?(path) or FileTest.symlink?(path) end |
.force_link(src, dest) ⇒ Object
41 42 43 44 |
# File 'lib/qdumpfs/util.rb', line 41 def self.force_link(src, dest) File.unlink(dest) if File.anything_exist?(dest) File.link(src, dest) end |
.force_symlink(src, dest) ⇒ Object
33 34 35 36 37 38 39 |
# File 'lib/qdumpfs/util.rb', line 33 def self.force_symlink(src, dest) begin File.unlink(dest) if File.anything_exist?(dest) File.symlink(src, dest) rescue end end |
.link(l, t) ⇒ Object
21 22 23 24 25 |
# File 'lib/qdumpfs/win32.rb', line 21 def File.link(l, t) result = CreateHardLinkA.call(t, l, 0) raise Errno::EACCES if result == 0 end |
.readable_file?(path) ⇒ Boolean
46 47 48 |
# File 'lib/qdumpfs/util.rb', line 46 def self.readable_file?(path) FileTest.file?(path) and FileTest.readable?(path) end |
.real_directory?(path) ⇒ Boolean
29 30 31 |
# File 'lib/qdumpfs/util.rb', line 29 def self.real_directory?(path) FileTest.directory?(path) and not FileTest.symlink?(path) end |
.real_file?(path) ⇒ Boolean
21 22 23 |
# File 'lib/qdumpfs/util.rb', line 21 def self.real_file?(path) FileTest.file?(path) and not FileTest.symlink?(path) end |
.split_all(path) ⇒ Object
50 51 52 53 54 55 56 57 58 59 |
# File 'lib/qdumpfs/util.rb', line 50 def self.split_all(path) parts = [] while true dirname, basename = File.split(path) break if path == dirname parts.unshift(basename) unless basename == "." path = dirname end return parts end |
.utime(a, m, dir) ⇒ Object
82 83 84 85 86 87 88 89 90 91 92 93 94 |
# File 'lib/qdumpfs/win32.rb', line 82 def File.utime(a, m, dir) File.utime_orig(a, m, dir) unless(File.directory?(dir)) atime = get_file_time(a.dup.utc) mtime = get_file_time(m.dup.utc) hDir = CreateFile.Call(dir.dup, GENERIC_WRITE, 0, 0, OPEN_EXISTING, FILE_FLAG_BACKUP_SEMANTICS, 0) SetFileTime.call(hDir, 0, atime, mtime) CloseHandle.Call(hDir) return 0 end |
.utime_orig ⇒ Object
75 |
# File 'lib/qdumpfs/win32.rb', line 75 alias_method(:utime_orig, :utime) |