How to use the scandir.Win32DirEntryPython function in scandir

To help you get started, we’ve selected a few scandir examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github benhoyt / scandir / View on Github external
error = ctypes.GetLastError()
                if error == ERROR_FILE_NOT_FOUND:
                    # No files, don't yield anything
                raise win_error(error, path)

            # Call FindNextFile in a loop, stopping when no more files
                while True:
                    # Skip '.' and '..' (current and parent directory), but
                    # otherwise yield (filename, stat_result) tuple
                    name = data.cFileName
                    if name not in ('.', '..'):
                        if is_bytes:
                            name = name.encode('mbcs', 'replace')
                        yield Win32DirEntryPython(path, name, data)

                    data = wintypes.WIN32_FIND_DATAW()
                    data_p = ctypes.byref(data)
                    success = FindNextFile(handle, data_p)
                    if not success:
                        error = ctypes.GetLastError()
                        if error == ERROR_NO_MORE_FILES:
                        raise win_error(error, path)
                if not FindClose(handle):
                    raise win_error(ctypes.GetLastError(), path)
github bleachbit / bleachbit / bleachbit / View on Github external
import win32file
    import bleachbit.Windows
    os_path_islink = os.path.islink
    os.path.islink = lambda path: os_path_islink(path) or bleachbit.Windows.is_junction(path)

if 'posix' ==
    from bleachbit.General import WindowsError
    pywinerror = WindowsError

    from scandir import walk
    if 'nt' ==
        import scandir
        import bleachbit.Windows

        class _Win32DirEntryPython(scandir.Win32DirEntryPython):
            def is_symlink(self):
                return super(_Win32DirEntryPython, self).is_symlink() or bleachbit.Windows.is_junction(self.path)

        scandir.scandir = scandir.scandir_python
        scandir.DirEntry = scandir.Win32DirEntryPython = _Win32DirEntryPython
except ImportError:
        'scandir is not available, so falling back to slower os.walk()')
    from os import walk

def open_files_linux():
    return glob.iglob("/proc/*/fd/*")

def open_files_lsof(run_lsof=None):