Skip to content

Commit

Permalink
fix weather file path in embedded file system
Browse files Browse the repository at this point in the history
- change __dir__ to Dir.pwd
- remove .each
  • Loading branch information
mdahlhausen committed Dec 13, 2024
1 parent 06efeea commit 719ef0a
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions lib/openstudio-standards/weather/information.rb
Original file line number Diff line number Diff line change
Expand Up @@ -202,23 +202,23 @@ def self.get_standards_weather_file_path(weather_file_name)
stat_string = load_resource_relative("../../../data/weather/#{weather_file_name.gsub('.epw', '.stat')}")

# extract to local weather dir
weather_dir = File.expand_path(File.join(__dir__, 'extracted_files/weather/'))
weather_dir = File.expand_path(File.join(Dir.pwd, 'extracted_files/weather/'))
OpenStudio.logFree(OpenStudio::Info, 'openstudio.standards.Weather.information', "Extracting weather files from OpenStudio CLI to #{weather_dir}")
FileUtils.mkdir_p(weather_dir)

path_length = "#{weather_dir}/#{weather_file_name}".length
if path_length > 260
OpenStudio.logFree(OpenStudio::Warn, 'openstudio.standards.Weather.information', "Weather file path length #{path_length} is >260 characters and may cause issues in Windows environments.")
end
File.open("#{weather_dir}/#{weather_file_name}", 'wb').each do |f|
File.open("#{weather_dir}/#{weather_file_name}", 'wb') do |f|
f << epw_string
f.flush
end
File.open("#{weather_dir}/#{weather_file_name.gsub('.epw', '.ddy')}", 'wb').each do |f|
File.open("#{weather_dir}/#{weather_file_name.gsub('.epw', '.ddy')}", 'wb') do |f|
f << ddy_string
f.flush
end
File.open("#{weather_dir}/#{weather_file_name.gsub('.epw', '.stat')}", 'wb').each do |f|
File.open("#{weather_dir}/#{weather_file_name.gsub('.epw', '.stat')}", 'wb') do |f|
f << stat_string
f.flush
end
Expand Down

0 comments on commit 719ef0a

Please sign in to comment.