diff options
author | Jason Molenda <jmolenda@apple.com> | 2013-04-29 09:46:43 +0000 |
---|---|---|
committer | Jason Molenda <jmolenda@apple.com> | 2013-04-29 09:46:43 +0000 |
commit | a7ae4673c718bb67c1a1fd7dc55e805be6571f49 (patch) | |
tree | 5c0957196ce3770a58d97d0ac32d5aefd5da3dd2 /lldb/source/Host/common/FileSpec.cpp | |
parent | 639ba01fc38ddc9dade14c5427aec29cf9020150 (diff) | |
download | bcm5719-llvm-a7ae4673c718bb67c1a1fd7dc55e805be6571f49.tar.gz bcm5719-llvm-a7ae4673c718bb67c1a1fd7dc55e805be6571f49.zip |
Add a few new methods to FileSpec to make it a little easier to work
with directories, without increasing the size of the FileSpec object.
GetPath() returns a std::string of the full pathname of the file.
IsDirectory(), IsPipe(), IsRegularFile(), IsSocket(), and IsSymbolicLink()
can be used instead of getting the FileType() and comparing it to an enum.
Update PlatformDarwinKernel to use these new methods.
llvm-svn: 180704
Diffstat (limited to 'lldb/source/Host/common/FileSpec.cpp')
-rw-r--r-- | lldb/source/Host/common/FileSpec.cpp | 29 |
1 files changed, 27 insertions, 2 deletions
diff --git a/lldb/source/Host/common/FileSpec.cpp b/lldb/source/Host/common/FileSpec.cpp index 5edec81a7d9..4764169a618 100644 --- a/lldb/source/Host/common/FileSpec.cpp +++ b/lldb/source/Host/common/FileSpec.cpp @@ -702,6 +702,33 @@ FileSpec::GetPath(char *path, size_t path_max_len) const return 0; } +void +FileSpec::GetPath (std::string &path) const +{ + const char *dirname = m_directory.GetCString(); + const char *filename = m_filename.GetCString(); + path.clear(); + if (dirname) + { + path.append (dirname); + if (filename) + path.append ("/"); + } + if (filename) + { + path.append (filename); + } +} + + +std::string& +FileSpec::GetPath (void) const +{ + std::string path; + GetPath (path); + return path; +} + ConstString FileSpec::GetFileNameExtension () const { @@ -1032,5 +1059,3 @@ FileSpec::IsRelativeToCurrentWorkingDirectory () const } return false; } - - |