From a282681d0c7201cf008f0bf92d78eaf1f45944dd Mon Sep 17 00:00:00 2001 From: shinokaro Date: Tue, 11 Jun 2024 03:57:52 +0900 Subject: [PATCH] Add write_path method to StubBuilder to unify path string writing --- lib/ocran/stub_builder.rb | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/lib/ocran/stub_builder.rb b/lib/ocran/stub_builder.rb index fa4829c..1bb2444 100644 --- a/lib/ocran/stub_builder.rb +++ b/lib/ocran/stub_builder.rb @@ -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) @@ -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 @@ -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