# File lib/uuid.rb, line 151
151:   def self.state_file(mode = 0644)
152:     return @state_file unless @state_file.nil?
153: 
154:     @mode = mode
155: 
156:     begin
157:       require 'Win32API'
158: 
159:       csidl_common_appdata = 0x0023
160:       path = 0.chr * 260
161:       get_folder_path = Win32API.new('shell32', 'SHGetFolderPath', 'LLLLP', 'L')
162:       get_folder_path.call 0, csidl_common_appdata, 0, 1, path
163: 
164:       state_dir = File.join(path.strip)
165:     rescue LoadError
166:       state_dir = File.join('', 'var', 'tmp')
167:     end
168: 
169:     if File.writable?(state_dir) then
170:       @state_file = File.join(state_dir, 'ruby-uuid')
171:     else
172:       @state_file = File.expand_path(File.join('~', '.ruby-uuid'))
173:     end
174: 
175:     @state_file
176:   end