Fix .desktop file creation

This commit is contained in:
KockaAdmiralac 2018-08-03 02:37:47 +02:00
parent 5e47258600
commit 474bb2ce30
No known key found for this signature in database
GPG key ID: A6007A5107D8CFBD
2 changed files with 28 additions and 20 deletions

View file

@ -90,7 +90,12 @@ raiseRbExc(const Exception &exc);
template<rb_data_type_t *rbType>
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<class C>

View file

@ -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