From 7d86ee5ab0ca98edff2f07c373967f34227c960e Mon Sep 17 00:00:00 2001 From: Zachary Turner Date: Wed, 8 Mar 2017 17:56:08 +0000 Subject: Resubmit FileSystem changes. This was originall reverted due to some test failures in ModuleCache and TestCompDirSymlink. These issues have all been resolved and the code now passes all tests. Differential Revision: https://reviews.llvm.org/D30698 llvm-svn: 297300 --- lldb/source/Core/FileSpecList.cpp | 44 ++++++++++++++++----------------------- 1 file changed, 18 insertions(+), 26 deletions(-) (limited to 'lldb/source/Core/FileSpecList.cpp') diff --git a/lldb/source/Core/FileSpecList.cpp b/lldb/source/Core/FileSpecList.cpp index 2f2713af336..0f790279897 100644 --- a/lldb/source/Core/FileSpecList.cpp +++ b/lldb/source/Core/FileSpecList.cpp @@ -16,6 +16,7 @@ // Other libraries and framework includes // Project includes #include "lldb/Utility/Stream.h" +#include "llvm/Support/FileSystem.h" using namespace lldb_private; using namespace std; @@ -150,32 +151,23 @@ size_t FileSpecList::GetFilesMatchingPartialPath(const char *path, FileSpecList &matches) { #if 0 // FIXME: Just sketching... matches.Clear(); - FileSpec path_spec = FileSpec (path); - if (path_spec.Exists ()) - { - FileSpec::FileType type = path_spec.GetFileType(); - if (type == FileSpec::eFileTypeSymbolicLink) - // Shouldn't there be a Resolve on a file spec that real-path's it? - { - } - - if (type == FileSpec::eFileTypeRegular - || (type == FileSpec::eFileTypeDirectory && dir_okay)) - { - matches.Append (path_spec); - return 1; - } - else if (type == FileSpec::eFileTypeDirectory) - { - // Fill the match list with all the files in the directory: - } - else - { - return 0; - } - } - else - { + using namespace llvm::sys::fs; + file_status stats; + if (status(path, stats, false)) + return 0; + if (exists(stats)) { + if (is_symlink_file(stats)) { + // Shouldn't there be a method that realpath's a file? + } + if (is_regular_file(stats) || (is_directory(stats) && dir_okay)) { + matches.Append(FileSpec(path)); + return 1; + } else if (is_directory(stats)) { + // Fill the match list with all the files in the directory: + } else { + return 0; + } + } else { ConstString dir_name = path_spec.GetDirectory(); ConstString file_name = GetFilename(); if (dir_name == nullptr) -- cgit v1.2.3