/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

Viewing changes to bzrlib/_walkdirs_win32.pyx

  • Committer: Martin von Gagern
  • Date: 2010-04-20 08:47:38 UTC
  • mfrom: (5167 +trunk)
  • mto: This revision was merged to the branch mainline in revision 5195.
  • Revision ID: martin.vgagern@gmx.net-20100420084738-ygymnqmdllzrhpfn
merge trunk

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2008 Canonical Ltd
 
1
# Copyright (C) 2008, 2009, 2010 Canonical Ltd
2
2
#
3
3
# This program is free software; you can redistribute it and/or modify
4
4
# it under the terms of the GNU General Public License as published by
12
12
#
13
13
# You should have received a copy of the GNU General Public License
14
14
# along with this program; if not, write to the Free Software
15
 
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 
15
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
16
16
 
17
17
"""Helper functions for Walkdirs on win32."""
18
18
 
81
81
    cdef readonly double st_ctime
82
82
    cdef readonly double st_mtime
83
83
    cdef readonly double st_atime
84
 
    cdef readonly __int64 st_size
 
84
    # We can't just declare this as 'readonly' because python2.4 doesn't define
 
85
    # T_LONGLONG as a structure member. So instead we just use a property that
 
86
    # will convert it correctly anyway.
 
87
    cdef __int64 _st_size
 
88
 
 
89
    property st_size:
 
90
        def __get__(self):
 
91
            return self._st_size
85
92
 
86
93
    # os.stat always returns 0, so we hard code it here
87
94
    cdef readonly int st_dev
102
109
                                 wcslen(data.cFileName))
103
110
 
104
111
 
105
 
cdef int _get_mode_bits(WIN32_FIND_DATAW *data):
 
112
cdef int _get_mode_bits(WIN32_FIND_DATAW *data): # cannot_raise
106
113
    cdef int mode_bits
107
114
 
108
115
    mode_bits = 0100666 # writeable file, the most common
114
121
    return mode_bits
115
122
 
116
123
 
117
 
cdef __int64 _get_size(WIN32_FIND_DATAW *data):
 
124
cdef __int64 _get_size(WIN32_FIND_DATAW *data): # cannot_raise
118
125
    # Pyrex casts a DWORD into a PyLong anyway, so it is safe to do << 32
119
126
    # on a DWORD
120
127
    return ((<__int64>data.nFileSizeHigh) << 32) + data.nFileSizeLow
121
128
 
122
129
 
123
 
cdef double _ftime_to_timestamp(FILETIME *ft):
 
130
cdef double _ftime_to_timestamp(FILETIME *ft): # cannot_raise
124
131
    """Convert from a FILETIME struct into a floating point timestamp.
125
132
 
126
133
    The fields of a FILETIME structure are the hi and lo part
140
147
    return (val * 1.0e-7) - 11644473600.0
141
148
 
142
149
 
143
 
cdef int _should_skip(WIN32_FIND_DATAW *data):
 
150
cdef int _should_skip(WIN32_FIND_DATAW *data): # cannot_raise
144
151
    """Is this '.' or '..' so we should skip it?"""
145
152
    if (data.cFileName[0] != c'.'):
146
153
        return 0
180
187
        statvalue.st_ctime = _ftime_to_timestamp(&data.ftCreationTime)
181
188
        statvalue.st_mtime = _ftime_to_timestamp(&data.ftLastWriteTime)
182
189
        statvalue.st_atime = _ftime_to_timestamp(&data.ftLastAccessTime)
183
 
        statvalue.st_size = _get_size(data)
 
190
        statvalue._st_size = _get_size(data)
184
191
        statvalue.st_ino = 0
185
192
        statvalue.st_dev = 0
186
193
        return statvalue