git » abk » commit 62ac1bb

Embed bz2 in copy_file_reg().

author
2005-03-02 17:22:40 UTC
committer
2005-03-02 17:22:40 UTC
parent 38a7f39b7590fabafad39096d679939284e03fcc

Embed bz2 in copy_file_reg().

abk +16 -2

diff --git a/abk b/abk
index f7dcd2e..49f9c11 100644
--- a/abk
+++ b/abk
@@ -96,7 +96,8 @@ class file_info:
 	def __ne__(self, other):
 		return not (self == other)
 
-	def copy_file_reg(self, dst):
+
+	def UNUSED_copy_file_reg(self, dst):
 		"Copy a regular file."
 		sfile = open(self.name, 'r')
 		dfile = open(dst, 'w')
@@ -110,6 +111,19 @@ class file_info:
 		sfile.close()
 		dfile.close()
 
+	def copy_file_reg(self, dst):
+		"Copy a regular file, destination is bz2 compressed."
+		sfile = open(self.name)
+		dfile = open(dst, 'w')
+
+		bcomp = bz2.BZ2Compressor()
+		data = sfile.read(PSIZE)
+		while data:
+			dfile.write(bcomp.compress(data))
+			data = sfile.read(PSIZE)
+		dfile.write(bcomp.flush())
+		sfile.close()
+		dfile.close()
 
 	def copy_file_link(self, dst):
 		"Copy a symbolic link."
@@ -222,7 +236,7 @@ class index_file:
 				self.put_file(name)
 
 
-def bz2_file(src, dst = None):
+def UNUSED_bz2_file(src, dst = None):
 	"Compress a file using bz2."
 	if not dst:
 		dst = src + '.bz2'