Class: Puppet::FileSystem::File19Windows
- Inherits:
-
File19
show all
- Defined in:
- lib/puppet/file_system/file19windows.rb
Constant Summary
Constants inherited
from File
Puppet::FileSystem::File::IMPL
Instance Attribute Summary
Attributes inherited from File
#path
Class Method Summary
collapse
Instance Method Summary
collapse
Methods inherited from File19
#binread
Methods inherited from File
#basename, #binread, #compare_stream, #dir, #each_line, #exclusive_open, #executable?, forget, #initialize, #mkpath, new, #open, overlay, #read, remember, #size, #to_s, #touch, #writable?
Class Method Details
.unlink(*file_names) ⇒ Object
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
|
# File 'lib/puppet/file_system/file19windows.rb', line 60
def self.unlink(*file_names)
if ! Puppet.features.manages_symlinks?
return ::File.unlink(*file_names)
end
file_names.each do |file_name|
file_name = file_name.to_s stat = Puppet::Util::Windows::File.stat(file_name) rescue nil
if stat && stat.ftype == 'directory'
if Puppet::Util::Windows::File.symlink?(file_name)
Dir.rmdir(file_name)
else
raise Errno::EPERM.new(file_name)
end
else
::File.unlink(file_name)
end
end
file_names.length
end
|
Instance Method Details
#exist? ⇒ Boolean
24
25
26
|
# File 'lib/puppet/file_system/file19windows.rb', line 24
def exist?
self.class.exist?(@path)
end
|
55
56
57
58
|
# File 'lib/puppet/file_system/file19windows.rb', line 55
def readlink
raise_if_symlinks_unsupported
Puppet::Util::Windows::File.readlink(@path)
end
|
#symlink(dest, options = {}) ⇒ Object
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
|
# File 'lib/puppet/file_system/file19windows.rb', line 28
def symlink(dest, options = {})
raise_if_symlinks_unsupported
dest_exists = self.class.exist?(dest) dest_stat = Puppet::Util::Windows::File.stat(dest) if dest_exists
dest_symlink = Puppet::Util::Windows::File.symlink?(dest)
return 0 if dest_exists && dest_stat.ftype == 'directory'
if dest_exists && dest_stat.ftype == 'file' && options[:force] != true
raise(Errno::EEXIST, "#{dest} already exists and the :force option was not specified")
end
if options[:noop] != true
::File.delete(dest) if dest_exists Puppet::Util::Windows::File.symlink(@path, dest)
end
0
end
|
84
85
86
|
# File 'lib/puppet/file_system/file19windows.rb', line 84
def unlink
self.class.unlink(@path)
end
|