Add extension to files that come into the clipboard without one.

This commit is contained in:
Tomeu Vizoso
2007-06-21 13:07:11 +02:00
parent 3ebb8f1291
commit 427e9a00d7
3 changed files with 29 additions and 5 deletions
+6
View File
@@ -22,6 +22,7 @@ import hippo
import gtk
from sugar import util
from sugar.objects import mime
from view.clipboardicon import ClipboardIcon
from sugar.clipboard import clipboardservice
@@ -104,6 +105,11 @@ class ClipboardBox(hippo.CanvasBox):
uri = urlparse.urlparse(uris[0])
path, file_name = os.path.split(uri.path)
root, ext = os.path.splitext(file_name)
if not ext or ext == '.':
mime_type = mime.get_for_file(uri.path)
file_name = root + '.' + mime.get_primary_extension(mime_type)
# Copy the file, as it will be deleted when the dnd operation finishes.
new_file_path = os.path.join(path, 'cb' + file_name)
shutil.copyfile(uri.path, new_file_path)