Author: Omar Emara Date: 2021-07-26T11:05:10-07:00 New Revision: a98f394e81f4dd70dc2a4a3a6640b10a6144cc3f
URL: https://github.com/llvm/llvm-project/commit/a98f394e81f4dd70dc2a4a3a6640b10a6144cc3f DIFF: https://github.com/llvm/llvm-project/commit/a98f394e81f4dd70dc2a4a3a6640b10a6144cc3f.diff LOG: [LLDB][GUI] Resolve paths in file/directory fields This patch resolves the paths in the file/directory fields before performing checks. Those checks are applied on the file system if m_need_to_exist is true, so remote files can set this to false to avoid performing host-side file system checks. Additionally, methods to get a resolved and a direct file specs were added to be used by client code. Reviewed By: clayborg Differential Revision: https://reviews.llvm.org/D106553 Added: Modified: lldb/source/Core/IOHandlerCursesGUI.cpp Removed: ################################################################################ diff --git a/lldb/source/Core/IOHandlerCursesGUI.cpp b/lldb/source/Core/IOHandlerCursesGUI.cpp index 4105bcc497871..b54511d2cebb5 100644 --- a/lldb/source/Core/IOHandlerCursesGUI.cpp +++ b/lldb/source/Core/IOHandlerCursesGUI.cpp @@ -1300,8 +1300,11 @@ class FileFieldDelegate : public TextFieldDelegate { if (!IsSpecified()) return; - FileSpec file(GetPath()); - if (m_need_to_exist && !FileSystem::Instance().Exists(file)) { + if (!m_need_to_exist) + return; + + FileSpec file = GetResolvedFileSpec(); + if (!FileSystem::Instance().Exists(file)) { SetError("File doesn't exist!"); return; } @@ -1311,7 +1314,17 @@ class FileFieldDelegate : public TextFieldDelegate { } } - // Returns the path of the file. + FileSpec GetFileSpec() { + FileSpec file_spec(GetPath()); + return file_spec; + } + + FileSpec GetResolvedFileSpec() { + FileSpec file_spec(GetPath()); + FileSystem::Instance().Resolve(file_spec); + return file_spec; + } + const std::string &GetPath() { return m_content; } protected: @@ -1330,8 +1343,11 @@ class DirectoryFieldDelegate : public TextFieldDelegate { if (!IsSpecified()) return; - FileSpec file(GetPath()); - if (m_need_to_exist && !FileSystem::Instance().Exists(file)) { + if (!m_need_to_exist) + return; + + FileSpec file = GetResolvedFileSpec(); + if (!FileSystem::Instance().Exists(file)) { SetError("Directory doesn't exist!"); return; } @@ -1341,7 +1357,17 @@ class DirectoryFieldDelegate : public TextFieldDelegate { } } - // Returns the path of the file. + FileSpec GetFileSpec() { + FileSpec file_spec(GetPath()); + return file_spec; + } + + FileSpec GetResolvedFileSpec() { + FileSpec file_spec(GetPath()); + FileSystem::Instance().Resolve(file_spec); + return file_spec; + } + const std::string &GetPath() { return m_content; } protected: _______________________________________________ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits