Class: Puppet::FileSystem::Windows
- Inherits:
-
Posix
show all
- Defined in:
- lib/puppet/file_system/windows.rb
Instance Method Summary
collapse
Methods inherited from Posix
#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, #path_string, #pathname, #read, #size, #touch, #writable?
Instance Method Details
#expand_path(path, dir_string = nil) ⇒ Object
#open(path, mode, options, &block) ⇒ Object
6
7
8
9
10
11
12
|
# File 'lib/puppet/file_system/windows.rb', line 6
def open(path, mode, options, &block)
raise TypeError.new('mode must be specified as an Integer') if mode && !mode.is_a?(Numeric)
::File.open(path, options, nil, &block)
end
|
#read_preserve_line_endings(path) ⇒ Object
109
110
111
112
113
114
115
|
# File 'lib/puppet/file_system/windows.rb', line 109
def read_preserve_line_endings(path)
contents = path.read( :mode => 'rb', :encoding => Encoding::UTF_8)
contents = path.read( :mode => 'rb', :encoding => Encoding::default_external) unless contents.valid_encoding?
contents = path.read unless contents.valid_encoding?
contents
end
|
#readlink(path) ⇒ Object
63
64
65
66
|
# File 'lib/puppet/file_system/windows.rb', line 63
def readlink(path)
raise_if_symlinks_unsupported
Puppet::Util::Windows::File.readlink(path)
end
|
#symlink(path, dest, options = {}) ⇒ Object
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
|
# File 'lib/puppet/file_system/windows.rb', line 37
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") % { dest: dest })
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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
|
# File 'lib/puppet/file_system/windows.rb', line 68
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
::File.unlink(file_name) rescue Dir.rmdir(file_name)
elsif 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
|