Hitesh Jasani
hjasa****@everw*****
Sun Sep 28 13:40:02 JST 2003
Austin or anyone, How do you load a resource file after packaging it into the .exe using exerb? It's a string file that I named myfile.rb and included in the .rbc as 'script myfile.rb'. Exerb seemed to package it into the .exe just fine. Later when I run the .exe, my main Ruby script tries to open the resource file using File.open, but it just gave me an error saying the file wasn't found. Load also didn't work for me. The only thing that seemed to find the file was 'require myfile'. It found the file but then bombed because it tried to interpret it as a ruby script, which it isn't. It's an ascii resource file. Any thoughts? Thanks, Hitesh Austin Ziegler wrote: I can't answer your first question, but: > 2) can i pack icons and other data into the exe? You will need to encode the icons as Ruby data first. The following script should stringify the data: ARGV.each do |icon_file| data = File.open(icon_file, 'rb') { |f| f.read } out_name = icon_file.sub(/#{File.extname(icon_file)}$/, '').upcase out_file = icon_file.sub(/#{File.extname(icon_file)}$/, '.rb') File.open(out_file) { |f| f.puts "#{out_name} = #{bytes.inspect}" } end (I say should because I haven't tested this version. It's based on an earlier version that used constant values for icon_file, out_name, and out_file.)