@target_name: the name of the target to tar
@retval: the path of the archived file
"""
+ file_list = []
if os.path.isdir(target_name):
target_dir = target_name
target_name = "."
+ for target_file in os.listdir(target_dir):
+ file_list.append(target_file)
else:
target_dir = os.path.dirname(target_name)
target_name = os.path.basename(target_name)
-
- cmdln = ["tar", "-S", "-C", target_dir, "-cf", archive_name, target_name]
-
-
+ file_list.append(target_name)
+ cmdln = ["tar", "-S", "-C", target_dir, "-cf", archive_name]
+ cmdln.extend(file_list)
_call_external(cmdln)
return archive_name
"""
if not target_dir:
target_dir = os.getcwd()
-
cmdln = ["tar", "-S", "-C", target_dir, "-xf", archive_name]
-
(returncode, stdout, stderr) = _call_external(cmdln)
if returncode != 0:
raise OSError, os.linesep.join([stdout, stderr])