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

_______________________________________________
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits

Reply via email to