From 474bb2ce3058553bc2c0ff45e394e98e50d80034 Mon Sep 17 00:00:00 2001 From: KockaAdmiralac <1405223@gmail.com> Date: Fri, 3 Aug 2018 02:37:47 +0200 Subject: [PATCH] Fix .desktop file creation --- binding-mri/binding-util.h | 5 +++++ scripts/Script.rb | 43 ++++++++++++++++++++------------------ 2 files changed, 28 insertions(+), 20 deletions(-) diff --git a/binding-mri/binding-util.h b/binding-mri/binding-util.h index 2a7ab56..1b758be 100644 --- a/binding-mri/binding-util.h +++ b/binding-mri/binding-util.h @@ -90,7 +90,12 @@ raiseRbExc(const Exception &exc); template static VALUE classAllocate(VALUE klass) { +/* 2.3 has changed the name of this function */ +#if RUBY_API_VERSION_MAJOR >= 2 && RUBY_API_VERSION_MINOR >= 3 return rb_data_typed_object_wrap(klass, 0, rbType); +#else + return rb_data_typed_object_alloc(klass, 0, rbType); +#endif } template diff --git a/scripts/Script.rb b/scripts/Script.rb index bf6845b..1426470 100644 --- a/scripts/Script.rb +++ b/scripts/Script.rb @@ -375,20 +375,14 @@ module Script end def self.copy_journal + # If the required directories don't exist, create them Dir.mkdir(Oneshot::GAME_PATH) unless File.exists?(Oneshot::GAME_PATH) Dir.mkdir(Oneshot::GAME_PATH + "/Oneshot") unless File.exists?(Oneshot::GAME_PATH + "/Oneshot") - begin - if File.file?(Oneshot::JOURNAL) - File.open(Oneshot::JOURNAL, "rb") do |input| - File.open(Oneshot::GAME_PATH + "/Oneshot/" + Oneshot::JOURNAL, "wb") do |output| - while buff = input.read(4096) - output.write(buff) - end - end - end - else + begin + # If we're on a supported Linux DE, make a .desktop file + # so the clover icon can be properly shown if Oneshot::OS == "linux" and SUPPORTED_DE.include? Oneshot::DE - path = Oneshot::GAME_PATH + "/Oneshot/" + Oneshot::JOURNAL + ".desktop" + path = "#{Oneshot::GAME_PATH}/Oneshot/#{Oneshot::JOURNAL}.desktop" File.open(path, "wb") do |output| output.write("[Desktop Entry]\n") output.write("Comment=...\n") @@ -398,17 +392,26 @@ module Script output.write("Type=Application\n") output.write("Icon=#{Dir.pwd}/images/icon.png\n") end - FileUtils.chmod 0777 path + File.chmod(0777, path) + # If the journal is a file, copy it to Documents + elsif File.file?(Oneshot::JOURNAL) + File.open(Oneshot::JOURNAL, "rb") do |input| + File.open("#{Oneshot::GAME_PATH}/Oneshot/#{Oneshot::JOURNAL}", "wb") do |output| + while buff = input.read(4096) + output.write(buff) + end + end + end + # If the journal isn't a file, symlink it else - File.symlink Dir.pwd + "/" + Oneshot::JOURNAL, Oneshot::GAME_PATH + "/Oneshot/" + Oneshot::JOURNAL + File.symlink "#{Dir.pwd}/#{Oneshot::JOURNAL}", "#{Oneshot::GAME_PATH}/Oneshot/#{Oneshot::JOURNAL}" end + rescue Errno::EACCES => e + # this probably means the clover.exe already exists and is running, so no need to create it again + rescue Errno::EEXIST => e + # this means that the journal file already exists, so no need to create it again end - rescue Errno::EACCES => e - #this probably means the clover.exe already exists and is running, so no need to create it again - rescue Errno::EEXIST => e - #this means that the journal file already exists, so no need to create it again - end - if File.exists?("README.txt") + if File.exists?("README.txt") File.open("README.txt", "rb") do |input| File.open(Oneshot::GAME_PATH + "/Oneshot/README.txt","wb") do |output| while buff = input.read(4096) @@ -416,7 +419,7 @@ module Script end end end - end + end end def self.create_boxes