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