Add game specific actions for shogi.
[kaya.git] / lib / filewriter.rb
blobf2c750bce9900a417ff705419bcdfc3c94a2e418
1 module FileWriter
2   def write_file(url, text)
3     return nil if url.is_empty
4     if url.is_local_file
5       File.open(url.path, 'w') do |f|
6         f.puts text
7       end
8     else
9       tmp_file = KDE::TemporaryFile.new
10       begin
11         return nil unless tmp_file.open
12         File.open(tmp_file.file_name, 'w') do |f|
13           f.puts text
14         end
15         return nil unless KIO::NetAccess.upload(tmp_file.file_name, url, self)
16       ensure
17         tmp_file.close
18       end
19     end
20     url
21   end
22 end