From: Zachary Turner Date: Tue, 7 Mar 2017 03:43:17 +0000 (+0000) Subject: Use LLVM for all stat-related functionality. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=d9bfb7ba0cdbc0e8e82cfb08cec3059a82606cbf;p=llvm Use LLVM for all stat-related functionality. This deletes LLDB's FileType enumeration and replaces all users, and all calls to functions that check whether a file exists etc with corresponding calls to LLVM. Differential Revision: https://reviews.llvm.org/D30624 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@297116 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/include/llvm/Support/FileSystem.h b/include/llvm/Support/FileSystem.h index f2a17b6bf83..0fbec088a83 100644 --- a/include/llvm/Support/FileSystem.h +++ b/include/llvm/Support/FileSystem.h @@ -479,6 +479,12 @@ inline bool is_local(int FD) { return !is_local(FD, Result) && Result; } +/// @brief Does status represent a directory? +/// +/// @param status A file_status previously returned from status. +/// @returns status.type() == file_type::directory_file. +file_type get_file_type(const Twine &Path); + /// @brief Does status represent a directory? /// /// @param status A file_status previously returned from status. diff --git a/lib/Support/Path.cpp b/lib/Support/Path.cpp index 0709ec272f5..94ed1876bbd 100644 --- a/lib/Support/Path.cpp +++ b/lib/Support/Path.cpp @@ -953,6 +953,13 @@ bool status_known(file_status s) { return s.type() != file_type::status_error; } +file_type get_file_type(const Twine &Path) { + file_status st; + if (status(Path, st)) + return file_type::status_error; + return st.type(); +} + bool is_directory(file_status status) { return status.type() == file_type::directory_file; }