Created
December 16, 2024 17:28
-
-
Save genki/52467caec8e59fadab579fe9cad7878e to your computer and use it in GitHub Desktop.
./distの中身を./dist.dataにまとめる
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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