Class: Puppet::FileSystem::File19Windows
- Inherits:
-
File19
show all
- Defined in:
- lib/puppet/file_system/file19windows.rb
Instance Method Summary
collapse
Methods inherited from File19
#binread, #compare_stream
Methods inherited from FileImpl
#assert_path, #basename, #binread, #children, #compare_stream, #dir, #directory?, #each_line, #exclusive_create, #exclusive_open, #executable?, #file?, #mkpath, #open, #path_string, #pathname, #read, #size, #touch, #writable?
Instance Method Details
#readlink(path) ⇒ Object
50
51
52
53
|
# File 'lib/puppet/file_system/file19windows.rb', line 50
def readlink(path)
raise_if_symlinks_unsupported
Puppet::Util::Windows::File.readlink(path)
end
|
#symlink(path, dest, options = {}) ⇒ Object
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
|
# File 'lib/puppet/file_system/file19windows.rb', line 24
def symlink(path, dest, options = {})
raise_if_symlinks_unsupported
dest_exists = exist?(dest) dest_stat = Puppet::Util::Windows::File.stat(dest) if dest_exists
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
|
#symlink?(path) ⇒ Boolean
#unlink(*file_names) ⇒ Object
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
|
# File 'lib/puppet/file_system/file19windows.rb', line 55
def 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
|