Rev 3515: A bit more reorganizing. in http://bzr.arbash-meinel.com/branches/bzr/1.6-dev/win32_find_files

John Arbash Meinel john at arbash-meinel.com
Thu Jul 17 05:35:56 BST 2008


At http://bzr.arbash-meinel.com/branches/bzr/1.6-dev/win32_find_files

------------------------------------------------------------
revno: 3515
revision-id: john at arbash-meinel.com-20080717043518-c1ncnoygo3ppew2f
parent: john at arbash-meinel.com-20080717042644-rt8ofayxp8849t3s
committer: John Arbash Meinel <john at arbash-meinel.com>
branch nick: win32_find_files
timestamp: Wed 2008-07-16 23:35:18 -0500
message:
  A bit more reorganizing.
-------------- next part --------------
=== modified file 'bzrlib/_walkdirs_win32.pyx'
--- a/bzrlib/_walkdirs_win32.pyx	2008-07-17 04:26:44 +0000
+++ b/bzrlib/_walkdirs_win32.pyx	2008-07-17 04:35:18 +0000
@@ -96,6 +96,12 @@
                      self.st_mtime, self.st_ctime))
 
 
+cdef object _get_name(WIN32_FIND_DATAW *data):
+    """Extract the Unicode name for this file/dir."""
+    return PyUnicode_FromUnicode(data.cFileName,
+                                 wcslen(data.cFileName))
+
+
 cdef int _get_mode_bits(WIN32_FIND_DATAW *data):
     cdef int mode_bits
 
@@ -134,6 +140,17 @@
     return (val * 1.0e-7) - 11644473600.0
 
 
+cdef int _should_skip(WIN32_FIND_DATAW *data):
+    """Is this '.' or '..' so we should skip it?"""
+    if (data.cFileName[0] != c'.'):
+        return 0
+    if data.cFileName[1] == c'\0':
+        return 1
+    if data.cFileName[1] == c'.' and data.cFileName[2] == c'\0':
+        return 1
+    return 0
+
+
 cdef class Win32Finder:
     """A class which encapsulates the search of files in a given directory"""
 
@@ -159,12 +176,6 @@
     def __iter__(self):
         return self
 
-    cdef object _get_name(self, WIN32_FIND_DATAW *data):
-        """Extract the Unicode name for this file/dir."""
-        name_unicode = PyUnicode_FromUnicode(data.cFileName,
-                                             wcslen(data.cFileName))
-        return name_unicode
-
     cdef _Win32Stat _get_stat_value(self, WIN32_FIND_DATAW *data):
         """Get the filename and the stat information."""
         cdef _Win32Stat statvalue
@@ -184,16 +195,6 @@
             return self._directory_kind
         return self._file_kind
 
-    cdef int _should_skip(self, WIN32_FIND_DATAW *data):
-        """Is this '.' or '..' so we should skip it?"""
-        if (data.cFileName[0] != c'.'):
-            return False
-        if data.cFileName[1] == c'\0':
-            return True
-        if data.cFileName[1] == c'.' and data.cFileName[2] == c'\0':
-            return True
-        return False
-
     def _get_files_in(self, directory, relprefix):
         cdef WIN32_FIND_DATAW search_data
         cdef HANDLE hFindFile
@@ -215,7 +216,7 @@
             result = 1
             while result:
                 # Skip '.' and '..'
-                if self._should_skip(&search_data):
+                if _should_skip(&search_data):
                     result = FindNextFileW(hFindFile, &search_data)
                     continue
                 name_unicode = self._get_name(&search_data)



More information about the bazaar-commits mailing list