[svn:parrot] r46190 - in trunk: runtime/parrot/library/Archive t/library

fperrad at svn.parrot.org fperrad at svn.parrot.org
Fri Apr 30 07:27:54 UTC 2010


Author: fperrad
Date: Fri Apr 30 07:27:54 2010
New Revision: 46190
URL: https://trac.parrot.org/parrot/changeset/46190

Log:
[TAR] add full_path() & rename()

Modified:
   trunk/runtime/parrot/library/Archive/TAR.pir
   trunk/t/library/archive_tar.t

Modified: trunk/runtime/parrot/library/Archive/TAR.pir
==============================================================================
--- trunk/runtime/parrot/library/Archive/TAR.pir	Fri Apr 30 07:14:08 2010	(r46189)
+++ trunk/runtime/parrot/library/Archive/TAR.pir	Fri Apr 30 07:27:54 2010	(r46190)
@@ -187,6 +187,38 @@
     .return ($S0, $S1)
 .end
 
+=item full_path
+
+=cut
+
+.sub 'full_path' :method
+    .local string prefix, name
+    $P0 = getattribute self, 'name'
+    name = $P0
+    $P0 = getattribute self, 'prefix'
+    prefix = $P0
+    unless prefix == '' goto L1
+    .return (name)
+  L1:
+    $S0 = prefix . '/'
+    $S0 .= name
+    .return ($S0)
+.end
+
+=item rename
+
+=cut
+
+.sub 'rename' :method
+    .param string path
+    .local string prefix, name
+    (prefix, name) = _prefix_and_file(path)
+    $P0 = box name
+    setattribute self, 'name', $P0
+    $P0 = box prefix
+    setattribute self, 'prefix', $P0
+.end
+
 =item _format_tar_entry
 
 =cut

Modified: trunk/t/library/archive_tar.t
==============================================================================
--- trunk/t/library/archive_tar.t	Fri Apr 30 07:14:08 2010	(r46189)
+++ trunk/t/library/archive_tar.t	Fri Apr 30 07:27:54 2010	(r46190)
@@ -21,7 +21,7 @@
 
     load_bytecode 'Archive/TAR.pir'
 
-    plan(11)
+    plan(12)
     test_new()
     test_tar()
 .end
@@ -39,12 +39,14 @@
     .local pmc archive, entry
     archive = new ['Archive';'TAR']
     $I0 = isa archive, ['Archive';'TAR']
-    ok($I0, "test_atf")
+    ok($I0, "test_tar")
     entry = archive.'add_data'('msg.txt', "some data")
     $I0 = isa entry, ['Archive';'TAR';'File']
     ok($I0, "entry is an ['Archive';'TAR';'File']")
     $S0 = entry.'data'()
     is($S0, "some data", "data")
+    $S0 = entry.'full_path'()
+    is($S0, 'msg.txt', "full_path")
     .local string header
     header = entry.'_format_tar_entry'()
     $I0 = length header


More information about the parrot-commits mailing list