Skip to content
This repository has been archived by the owner on Feb 3, 2020. It is now read-only.

Commit

Permalink
use file to get archive mime-type
Browse files Browse the repository at this point in the history
  • Loading branch information
baverman committed Feb 11, 2012
1 parent 951f40a commit 6c85e80
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions fmd/filelist.py
Expand Up @@ -300,13 +300,18 @@ def set_uri_from_file_info(self, file_info, cfile):
else:
print ft, cfile.get_uri()

def process_archive(self, fi):
ct = fi.get_content_type()
def process_archive(self, cfile, fi):
from subprocess import Popen, PIPE

ct = Popen(["/usr/bin/env", "file", "-b", "--mime-type", cfile.get_path()],
stdout=PIPE).communicate()[0].strip()

if ct == 'application/x-rar':
cmd = ['unrar', 'x', '-y']
elif ct == 'application/zip':
cmd = ['unzip', '-o']
elif ct == 'application/x-7z-compressed':
cmd = ['7z', 'x', '-y']
else:
print ct
return False
Expand All @@ -330,7 +335,7 @@ def on_item_activated(self, view, path):
cfile = self.current_folder.get_child(fi.get_name())
ft = fi.get_file_type()
if ft == gio.FILE_TYPE_REGULAR:
if not self.process_archive(fi):
if not self.process_archive(cfile, fi):
app_info = gio.app_info_get_default_for_type(fi.get_content_type(), False)
if app_info:
os.chdir(self.current_folder.get_path())
Expand Down

0 comments on commit 6c85e80

Please sign in to comment.