def _list_files(root):
dir_patterns, file_patterns = _gitignore(root)<EOL>paths = []<EOL>prefix = os.path.abspath(root) + os.sep<EOL>for base, dirs, files in os.walk(root):<EOL><INDENT>for d in dirs:<EOL><INDENT>for dir_pattern in dir_patterns:<EOL><INDENT>if fnmatch(d, dir_pattern):<EOL><INDENT>dirs.remove(d)<EOL>break<EOL><DEDENT><DEDENT><DEDENT>for f in files:<EOL><INDENT>skip = False<EOL>for file_pattern in file_patterns:<EOL><INDENT>if fnmatch(f, file_pattern):<EOL><INDENT>skip = True<EOL>break<EOL><DEDENT><DEDENT>if skip:<EOL><INDENT>continue<EOL><DEDENT>full_path = os.path.join(base, f)<EOL>if full_path[:len(prefix)] == prefix:<EOL><INDENT>full_path = full_path[len(prefix):]<EOL><DEDENT>paths.append(full_path)<EOL><DEDENT><DEDENT>return sorted(paths)<EOL>
Lists all of the files in a directory, taking into account any .gitignore
file that is present

:param root:
    A unicode filesystem path

:return:
    A list of unicode strings, containing paths of all files not ignored
    by .gitignore with root, using relative paths