[Lldb-commits] [PATCH] D149663: [lldb] Remove FileSpec::GetLastPathComponent
Alex Langford via Phabricator via lldb-commits
lldb-commits at lists.llvm.org
Tue May 2 11:19:29 PDT 2023
bulbazord added a comment.
In D149663#4313112 <https://reviews.llvm.org/D149663#4313112>, @mib wrote:
> @bulbazord What if the FileSpec is pointing to a directory instead of a file ? What would `GetFilename` return in that case compared to `GetLastPathComponent` ?
FileSpec chops everything up into a directory and a filename, even if it's pointing to a directory. For example:
fspec = lldb.SBFileSpec("/foo/bar/baz/")
print(fspec.GetDirectory())
print(fspec.GetFilename())
This will print "/foo/bar" followed by "baz". baz is clearly a directory, but FileSpec will treat it as the filename. `GetLastPathComponent` uses `llvm::sys::path::filename` to get the last element of the path, which is the exact same mechanism we use when constructing FileSpec's internal `m_directory` and `m_filename` in the first place.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D149663/new/
https://reviews.llvm.org/D149663
More information about the lldb-commits
mailing list