/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: Canonical.com Patch Queue Manager
  • Date: 2008-10-01 07:56:03 UTC
  • mfrom: (3224.5.40 faster-startup)
  • Revision ID: pqm@pqm.ubuntu.com-20081001075603-s9nynw8y85fmrprj
Reduce startup time by a small amount. (Andrew Bennetts)

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2008, 2009, 2010 Canonical Ltd
 
1
# Copyright (C) 2008 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
 
15
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  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
 
    # 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
 
84
    cdef readonly __int64 st_size
92
85
 
93
86
    # os.stat always returns 0, so we hard code it here
94
87
    cdef readonly int st_dev
109
102
                                 wcslen(data.cFileName))
110
103
 
111
104
 
112
 
cdef int _get_mode_bits(WIN32_FIND_DATAW *data): # cannot_raise
 
105
cdef int _get_mode_bits(WIN32_FIND_DATAW *data):
113
106
    cdef int mode_bits
114
107
 
115
108
    mode_bits = 0100666 # writeable file, the most common
121
114
    return mode_bits
122
115
 
123
116
 
124
 
cdef __int64 _get_size(WIN32_FIND_DATAW *data): # cannot_raise
 
117
cdef __int64 _get_size(WIN32_FIND_DATAW *data):
125
118
    # Pyrex casts a DWORD into a PyLong anyway, so it is safe to do << 32
126
119
    # on a DWORD
127
120
    return ((<__int64>data.nFileSizeHigh) << 32) + data.nFileSizeLow
128
121
 
129
122
 
130
 
cdef double _ftime_to_timestamp(FILETIME *ft): # cannot_raise
 
123
cdef double _ftime_to_timestamp(FILETIME *ft):
131
124
    """Convert from a FILETIME struct into a floating point timestamp.
132
125
 
133
126
    The fields of a FILETIME structure are the hi and lo part
147
140
    return (val * 1.0e-7) - 11644473600.0
148
141
 
149
142
 
150
 
cdef int _should_skip(WIN32_FIND_DATAW *data): # cannot_raise
 
143
cdef int _should_skip(WIN32_FIND_DATAW *data):
151
144
    """Is this '.' or '..' so we should skip it?"""
152
145
    if (data.cFileName[0] != c'.'):
153
146
        return 0
187
180
        statvalue.st_ctime = _ftime_to_timestamp(&data.ftCreationTime)
188
181
        statvalue.st_mtime = _ftime_to_timestamp(&data.ftLastWriteTime)
189
182
        statvalue.st_atime = _ftime_to_timestamp(&data.ftLastAccessTime)
190
 
        statvalue._st_size = _get_size(data)
 
183
        statvalue.st_size = _get_size(data)
191
184
        statvalue.st_ino = 0
192
185
        statvalue.st_dev = 0
193
186
        return statvalue