~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/export/zip_exporter.py

  • Committer: John Arbash Meinel
  • Date: 2006-09-23 19:05:44 UTC
  • mto: This revision was merged to the branch mainline in revision 2036.
  • Revision ID: john@arbash-meinel.com-20060923190544-c3f625a5bc5589ab
paths are always forward slashed for python zipfiles

Show diffs side-by-side

added added

removed removed

Lines of Context:
21
21
import stat
22
22
import zipfile
23
23
 
 
24
from bzrlib import (
 
25
    osutils,
 
26
    )
24
27
from bzrlib.trace import mutter
25
28
 
26
29
 
27
30
# Windows expects this bit to be set in the 'external_attr' section
28
31
# Or it won't consider the entry a directory
29
32
ZIP_DIRECTORY_BIT = (1 << 4)
30
 
_FILE_MODE = 0664
31
 
_DIR_MODE = 0775
32
33
 
33
 
_FILE_ATTR = stat.S_IFREG | _FILE_MODE
34
 
_DIR_ATTR = stat.S_IFDIR | _DIR_MODE | ZIP_DIRECTORY_BIT
 
34
_FILE_ATTR = stat.S_IFREG
 
35
_DIR_ATTR = stat.S_IFDIR | ZIP_DIRECTORY_BIT
35
36
 
36
37
 
37
38
def zip_exporter(tree, dest, root):
62
63
            file_id = ie.file_id
63
64
            mutter("  export {%s} kind %s to %s", file_id, ie.kind, dest)
64
65
 
65
 
            filename = os.path.join(root, dp).encode('utf8')
 
66
            # zipfile.ZipFile switches all paths to forward
 
67
            # slashes anyway, so just stick with that.
 
68
            filename = osutils.pathjoin(root, dp).encode('utf8')
66
69
            if ie.kind == "file":
67
70
                zinfo = zipfile.ZipInfo(
68
71
                            filename=filename,
75
78
                # to the zip routine that they are really directories and
76
79
                # not just empty files.
77
80
                zinfo = zipfile.ZipInfo(
78
 
                            filename=filename + os.sep,
 
81
                            filename=filename + '/',
79
82
                            date_time=now)
80
83
                zinfo.compress_type = compression
81
84
                zinfo.external_attr = _DIR_ATTR