Skip to content

Instantly share code, notes, and snippets.

@genki
Created December 16, 2024 17:28
Show Gist options
  • Save genki/52467caec8e59fadab579fe9cad7878e to your computer and use it in GitHub Desktop.
Save genki/52467caec8e59fadab579fe9cad7878e to your computer and use it in GitHub Desktop.
./distの中身を./dist.dataにまとめる
#!/usr/bin/env ruby
# ./distの中身を./dist.dataにまとめる
DIST_DIR = './dist'
OUT_PATH = "./dist.data"
paths = []
Dir["#{DIST_DIR}/**/*"].each do |path|
next if File.directory?(path)
pathO = path.gsub("#{DIST_DIR}", '')
paths << [path, pathO]
end
open(OUT_PATH, 'wb') do |f|
f.write [paths.size].pack('N')
paths.each do |path, out|
f.write [out.size].pack('N')
f.write out
fsize = File.size(path)
f.write [fsize].pack('N')
f.write File.read(path)
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment