1//===-- SWIG Interface for SBFileSpec ---------------------------*- C++ -*-===// 2// 3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 4// See https://llvm.org/LICENSE.txt for license information. 5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6// 7//===----------------------------------------------------------------------===// 8 9namespace lldb { 10 11%feature("docstring", 12"Represents a file specification that divides the path into a directory and 13basename. The string values of the paths are put into uniqued string pools 14for fast comparisons and efficient memory usage. 15 16For example, the following code 17 18 lineEntry = context.GetLineEntry() 19 self.expect(lineEntry.GetFileSpec().GetDirectory(), 'The line entry should have the correct directory', 20 exe=False, 21 substrs = [self.mydir]) 22 self.expect(lineEntry.GetFileSpec().GetFilename(), 'The line entry should have the correct filename', 23 exe=False, 24 substrs = ['main.c']) 25 self.assertTrue(lineEntry.GetLine() == self.line, 26 'The line entry's line number should match ') 27 28gets the line entry from the symbol context when a thread is stopped. 29It gets the file spec corresponding to the line entry and checks that 30the filename and the directory matches what we expect.") SBFileSpec; 31class SBFileSpec 32{ 33public: 34 SBFileSpec (); 35 36 SBFileSpec (const lldb::SBFileSpec &rhs); 37 38 SBFileSpec (const char *path);// Deprecated, use SBFileSpec (const char *path, bool resolve) 39 40 SBFileSpec (const char *path, bool resolve); 41 42 ~SBFileSpec (); 43 44 bool operator==(const SBFileSpec &rhs) const; 45 46 bool operator!=(const SBFileSpec &rhs) const; 47 48 bool 49 IsValid() const; 50 51 explicit operator bool() const; 52 53 bool 54 Exists () const; 55 56 bool 57 ResolveExecutableLocation (); 58 59 const char * 60 GetFilename() const; 61 62 const char * 63 GetDirectory() const; 64 65 void 66 SetFilename(const char *filename); 67 68 void 69 SetDirectory(const char *directory); 70 71 uint32_t 72 GetPath (char *dst_path, size_t dst_len) const; 73 74 static int 75 ResolvePath (const char *src_path, char *dst_path, size_t dst_len); 76 77 bool 78 GetDescription (lldb::SBStream &description) const; 79 80 void 81 AppendPathComponent (const char *file_or_directory); 82 83 STRING_EXTENSION(SBFileSpec) 84 85#ifdef SWIGPYTHON 86 %pythoncode %{ 87 def __get_fullpath__(self): 88 spec_dir = self.GetDirectory() 89 spec_file = self.GetFilename() 90 if spec_dir and spec_file: 91 return '%s/%s' % (spec_dir, spec_file) 92 elif spec_dir: 93 return spec_dir 94 elif spec_file: 95 return spec_file 96 return None 97 98 fullpath = property(__get_fullpath__, None, doc='''A read only property that returns the fullpath as a python string.''') 99 basename = property(GetFilename, None, doc='''A read only property that returns the path basename as a python string.''') 100 dirname = property(GetDirectory, None, doc='''A read only property that returns the path directory name as a python string.''') 101 exists = property(Exists, None, doc='''A read only property that returns a boolean value that indicates if the file exists.''') 102 %} 103#endif 104 105}; 106 107} // namespace lldb 108