Skip to content

Commit

Permalink
Add write_path method to StubBuilder to unify path string writing
Browse files Browse the repository at this point in the history
  • Loading branch information
shinokaro committed Jun 10, 2024
1 parent d351fac commit a282681
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions lib/ocran/stub_builder.rb
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ def mkdir(path)
Ocran.verbose_msg "m #{path}"

write_opcode(OP_CREATE_DIRECTORY)
write_string(convert_to_native(path))
write_path(path)
end

def copy_file(src, tgt)
Expand All @@ -122,7 +122,7 @@ def copy_file(src, tgt)

Ocran.verbose_msg "a #{tgt}"
write_opcode(OP_CREATE_FILE)
write_string(convert_to_native(tgt))
write_path(tgt)
write_file(src)
end

Expand Down Expand Up @@ -243,6 +243,10 @@ def write_file(src)
end
private :write_file

def write_path(path)
write_string(convert_to_native(path))
end

def convert_to_native(path)
path.to_s.tr(File::SEPARATOR, "\\")
end
Expand Down

0 comments on commit a282681

Please sign in to comment.