# File lib/puppet/util/filetype.rb, line 17
17:     def self.newfiletype(name, &block)
18:         @filetypes ||= {}
19: 
20:         klass = genclass(name,
21:             :block => block,
22:             :prefix => "FileType",
23:             :hash => @filetypes
24:         )
25: 
26:         # Rename the read and write methods, so that we're sure they
27:         # maintain the stats.
28:         klass.class_eval do
29:             # Rename the read method
30:             define_method(:real_read, instance_method(:read))
31:             define_method(:read) do
32:                 begin
33:                     val = real_read()
34:                     @loaded = Time.now
35:                     if val
36:                         return val.gsub(/# HEADER.*\n/,'')
37:                     else
38:                         return ""
39:                     end
40:                 rescue Puppet::Error => detail
41:                     raise
42:                 rescue => detail
43:                     if Puppet[:trace]
44:                         puts detail.backtrace
45:                     end
46:                     raise Puppet::Error, "%s could not read %s: %s" %
47:                         [self.class, @path, detail]
48:                 end
49:             end
50: 
51:             # And then the write method
52:             define_method(:real_write, instance_method(:write))
53:             define_method(:write) do |text|
54:                 begin
55:                     val = real_write(text)
56:                     @synced = Time.now
57:                     return val
58:                 rescue Puppet::Error => detail
59:                     raise
60:                 rescue => detail
61:                     if Puppet[:debug]
62:                         puts detail.backtrace
63:                     end
64:                     raise Puppet::Error, "%s could not write %s: %s" %
65:                         [self.class, @path, detail]
66:                 end
67:             end
68:         end
69:     end