1258882Semaste//===-- SBPlatform.cpp ------------------------------------------*- C++ -*-===// 2258882Semaste// 3258882Semaste// The LLVM Compiler Infrastructure 4258882Semaste// 5258882Semaste// This file is distributed under the University of Illinois Open Source 6258882Semaste// License. See LICENSE.TXT for details. 7258882Semaste// 8258882Semaste//===----------------------------------------------------------------------===// 9258882Semaste 10258882Semaste#include "lldb/API/SBPlatform.h" 11258882Semaste#include "lldb/API/SBError.h" 12258882Semaste#include "lldb/API/SBFileSpec.h" 13258882Semaste#include "lldb/Core/ArchSpec.h" 14258882Semaste#include "lldb/Core/Error.h" 15258882Semaste#include "lldb/Host/File.h" 16258882Semaste#include "lldb/Interpreter/Args.h" 17258882Semaste#include "lldb/Target/Target.h" 18258882Semaste#include "lldb/Target/Platform.h" 19258882Semaste 20258882Semasteusing namespace lldb; 21258882Semasteusing namespace lldb_private; 22258882Semaste 23258882Semaste//---------------------------------------------------------------------- 24258882Semaste// PlatformConnectOptions 25258882Semaste//---------------------------------------------------------------------- 26258882Semastestruct PlatformConnectOptions { 27258882Semaste PlatformConnectOptions(const char *url = NULL) : 28258882Semaste m_url(), 29258882Semaste m_rsync_options(), 30258882Semaste m_rsync_remote_path_prefix(), 31258882Semaste m_rsync_enabled(false), 32258882Semaste m_rsync_omit_hostname_from_remote_path(false), 33258882Semaste m_local_cache_directory () 34258882Semaste { 35258882Semaste if (url && url[0]) 36258882Semaste m_url = url; 37258882Semaste } 38258882Semaste 39258882Semaste ~PlatformConnectOptions() 40258882Semaste { 41258882Semaste } 42258882Semaste 43258882Semaste std::string m_url; 44258882Semaste std::string m_rsync_options; 45258882Semaste std::string m_rsync_remote_path_prefix; 46258882Semaste bool m_rsync_enabled; 47258882Semaste bool m_rsync_omit_hostname_from_remote_path; 48258882Semaste ConstString m_local_cache_directory; 49258882Semaste}; 50258882Semaste 51258882Semaste//---------------------------------------------------------------------- 52258882Semaste// PlatformShellCommand 53258882Semaste//---------------------------------------------------------------------- 54258882Semastestruct PlatformShellCommand { 55258882Semaste PlatformShellCommand(const char *shell_command = NULL) : 56258882Semaste m_command(), 57258882Semaste m_working_dir(), 58258882Semaste m_status(0), 59258882Semaste m_signo(0), 60258882Semaste m_timeout_sec(UINT32_MAX) 61258882Semaste { 62258882Semaste if (shell_command && shell_command[0]) 63258882Semaste m_command = shell_command; 64258882Semaste } 65258882Semaste 66258882Semaste ~PlatformShellCommand() 67258882Semaste { 68258882Semaste } 69258882Semaste 70258882Semaste std::string m_command; 71258882Semaste std::string m_working_dir; 72258882Semaste std::string m_output; 73258882Semaste int m_status; 74258882Semaste int m_signo; 75258882Semaste uint32_t m_timeout_sec; 76258882Semaste}; 77258882Semaste//---------------------------------------------------------------------- 78258882Semaste// SBPlatformConnectOptions 79258882Semaste//---------------------------------------------------------------------- 80258882SemasteSBPlatformConnectOptions::SBPlatformConnectOptions (const char *url) : 81258882Semaste m_opaque_ptr(new PlatformConnectOptions(url)) 82258882Semaste{ 83258882Semaste 84258882Semaste} 85258882Semaste 86258882SemasteSBPlatformConnectOptions::SBPlatformConnectOptions(const SBPlatformConnectOptions &rhs) : 87258882Semaste m_opaque_ptr(new PlatformConnectOptions()) 88258882Semaste{ 89258882Semaste *m_opaque_ptr = *rhs.m_opaque_ptr; 90258882Semaste} 91258882Semaste 92258882SemasteSBPlatformConnectOptions::~SBPlatformConnectOptions () 93258882Semaste{ 94258882Semaste delete m_opaque_ptr; 95258882Semaste} 96258882Semaste 97258882Semastevoid 98258882SemasteSBPlatformConnectOptions::operator=(const SBPlatformConnectOptions &rhs) 99258882Semaste{ 100258882Semaste *m_opaque_ptr = *rhs.m_opaque_ptr; 101258882Semaste} 102258882Semaste 103258882Semasteconst char * 104258882SemasteSBPlatformConnectOptions::GetURL() 105258882Semaste{ 106258882Semaste if (m_opaque_ptr->m_url.empty()) 107258882Semaste return NULL; 108258882Semaste return m_opaque_ptr->m_url.c_str(); 109258882Semaste} 110258882Semaste 111258882Semastevoid 112258882SemasteSBPlatformConnectOptions::SetURL(const char *url) 113258882Semaste{ 114258882Semaste if (url && url[0]) 115258882Semaste m_opaque_ptr->m_url = url; 116258882Semaste else 117258882Semaste m_opaque_ptr->m_url.clear(); 118258882Semaste} 119258882Semaste 120258882Semastebool 121258882SemasteSBPlatformConnectOptions::GetRsyncEnabled() 122258882Semaste{ 123258882Semaste return m_opaque_ptr->m_rsync_enabled; 124258882Semaste} 125258882Semaste 126258882Semastevoid 127258882SemasteSBPlatformConnectOptions::EnableRsync (const char *options, 128258882Semaste const char *remote_path_prefix, 129258882Semaste bool omit_hostname_from_remote_path) 130258882Semaste{ 131258882Semaste m_opaque_ptr->m_rsync_enabled = true; 132258882Semaste m_opaque_ptr->m_rsync_omit_hostname_from_remote_path = omit_hostname_from_remote_path; 133258882Semaste if (remote_path_prefix && remote_path_prefix[0]) 134258882Semaste m_opaque_ptr->m_rsync_remote_path_prefix = remote_path_prefix; 135258882Semaste else 136258882Semaste m_opaque_ptr->m_rsync_remote_path_prefix.clear(); 137258882Semaste 138258882Semaste if (options && options[0]) 139258882Semaste m_opaque_ptr->m_rsync_options = options; 140258882Semaste else 141258882Semaste m_opaque_ptr->m_rsync_options.clear(); 142258882Semaste 143258882Semaste} 144258882Semaste 145258882Semastevoid 146258882SemasteSBPlatformConnectOptions::DisableRsync () 147258882Semaste{ 148258882Semaste m_opaque_ptr->m_rsync_enabled = false; 149258882Semaste} 150258882Semaste 151258882Semasteconst char * 152258882SemasteSBPlatformConnectOptions::GetLocalCacheDirectory() 153258882Semaste{ 154258882Semaste return m_opaque_ptr->m_local_cache_directory.GetCString(); 155258882Semaste} 156258882Semaste 157258882Semastevoid 158258882SemasteSBPlatformConnectOptions::SetLocalCacheDirectory(const char *path) 159258882Semaste{ 160258882Semaste if (path && path[0]) 161258882Semaste m_opaque_ptr->m_local_cache_directory.SetCString(path); 162258882Semaste else 163258882Semaste m_opaque_ptr->m_local_cache_directory = ConstString(); 164258882Semaste} 165258882Semaste 166258882Semaste//---------------------------------------------------------------------- 167258882Semaste// SBPlatformShellCommand 168258882Semaste//---------------------------------------------------------------------- 169258882SemasteSBPlatformShellCommand::SBPlatformShellCommand (const char *shell_command) : 170258882Semaste m_opaque_ptr(new PlatformShellCommand(shell_command)) 171258882Semaste{ 172258882Semaste} 173258882Semaste 174258882SemasteSBPlatformShellCommand::SBPlatformShellCommand (const SBPlatformShellCommand &rhs) : 175258882Semaste m_opaque_ptr(new PlatformShellCommand()) 176258882Semaste{ 177258882Semaste *m_opaque_ptr = *rhs.m_opaque_ptr; 178258882Semaste} 179258882Semaste 180258882SemasteSBPlatformShellCommand::~SBPlatformShellCommand() 181258882Semaste{ 182258882Semaste delete m_opaque_ptr; 183258882Semaste} 184258882Semaste 185258882Semastevoid 186258882SemasteSBPlatformShellCommand::Clear() 187258882Semaste{ 188258882Semaste m_opaque_ptr->m_output = std::move(std::string()); 189258882Semaste m_opaque_ptr->m_status = 0; 190258882Semaste m_opaque_ptr->m_signo = 0; 191258882Semaste} 192258882Semaste 193258882Semasteconst char * 194258882SemasteSBPlatformShellCommand::GetCommand() 195258882Semaste{ 196258882Semaste if (m_opaque_ptr->m_command.empty()) 197258882Semaste return NULL; 198258882Semaste return m_opaque_ptr->m_command.c_str(); 199258882Semaste} 200258882Semaste 201258882Semastevoid 202258882SemasteSBPlatformShellCommand::SetCommand(const char *shell_command) 203258882Semaste{ 204258882Semaste if (shell_command && shell_command[0]) 205258882Semaste m_opaque_ptr->m_command = shell_command; 206258882Semaste else 207258882Semaste m_opaque_ptr->m_command.clear(); 208258882Semaste} 209258882Semaste 210258882Semasteconst char * 211258882SemasteSBPlatformShellCommand::GetWorkingDirectory () 212258882Semaste{ 213258882Semaste if (m_opaque_ptr->m_working_dir.empty()) 214258882Semaste return NULL; 215258882Semaste return m_opaque_ptr->m_working_dir.c_str(); 216258882Semaste} 217258882Semaste 218258882Semastevoid 219258882SemasteSBPlatformShellCommand::SetWorkingDirectory (const char *path) 220258882Semaste{ 221258882Semaste if (path && path[0]) 222258882Semaste m_opaque_ptr->m_working_dir = path; 223258882Semaste else 224258882Semaste m_opaque_ptr->m_working_dir.clear(); 225258882Semaste} 226258882Semaste 227258882Semasteuint32_t 228258882SemasteSBPlatformShellCommand::GetTimeoutSeconds () 229258882Semaste{ 230258882Semaste return m_opaque_ptr->m_timeout_sec; 231258882Semaste} 232258882Semaste 233258882Semastevoid 234258882SemasteSBPlatformShellCommand::SetTimeoutSeconds (uint32_t sec) 235258882Semaste{ 236258882Semaste m_opaque_ptr->m_timeout_sec = sec; 237258882Semaste} 238258882Semaste 239258882Semasteint 240258882SemasteSBPlatformShellCommand::GetSignal () 241258882Semaste{ 242258882Semaste return m_opaque_ptr->m_signo; 243258882Semaste} 244258882Semaste 245258882Semasteint 246258882SemasteSBPlatformShellCommand::GetStatus () 247258882Semaste{ 248258882Semaste return m_opaque_ptr->m_status; 249258882Semaste} 250258882Semaste 251258882Semasteconst char * 252258882SemasteSBPlatformShellCommand::GetOutput () 253258882Semaste{ 254258882Semaste if (m_opaque_ptr->m_output.empty()) 255258882Semaste return NULL; 256258882Semaste return m_opaque_ptr->m_output.c_str(); 257258882Semaste} 258258882Semaste 259258882Semaste//---------------------------------------------------------------------- 260258882Semaste// SBPlatform 261258882Semaste//---------------------------------------------------------------------- 262258882SemasteSBPlatform::SBPlatform () : 263258882Semaste m_opaque_sp () 264258882Semaste{ 265258882Semaste 266258882Semaste} 267258882Semaste 268258882SemasteSBPlatform::SBPlatform (const char *platform_name) : 269258882Semaste m_opaque_sp () 270258882Semaste{ 271258882Semaste Error error; 272258882Semaste m_opaque_sp = Platform::Create (platform_name, error); 273258882Semaste} 274258882Semaste 275258882SemasteSBPlatform::~SBPlatform() 276258882Semaste{ 277258882Semaste} 278258882Semaste 279258882Semastebool 280258882SemasteSBPlatform::IsValid () const 281258882Semaste{ 282258882Semaste return m_opaque_sp.get() != NULL; 283258882Semaste} 284258882Semaste 285258882Semastevoid 286258882SemasteSBPlatform::Clear () 287258882Semaste{ 288258882Semaste m_opaque_sp.reset(); 289258882Semaste} 290258882Semaste 291258882Semasteconst char * 292258882SemasteSBPlatform::GetName () 293258882Semaste{ 294258882Semaste PlatformSP platform_sp(GetSP()); 295258882Semaste if (platform_sp) 296258882Semaste return platform_sp->GetName().GetCString(); 297258882Semaste return NULL; 298258882Semaste} 299258882Semaste 300258882Semastelldb::PlatformSP 301258882SemasteSBPlatform::GetSP () const 302258882Semaste{ 303258882Semaste return m_opaque_sp; 304258882Semaste} 305258882Semaste 306258882Semastevoid 307258882SemasteSBPlatform::SetSP (const lldb::PlatformSP& platform_sp) 308258882Semaste{ 309258882Semaste m_opaque_sp = platform_sp; 310258882Semaste} 311258882Semaste 312258882Semasteconst char * 313258882SemasteSBPlatform::GetWorkingDirectory() 314258882Semaste{ 315258882Semaste PlatformSP platform_sp(GetSP()); 316258882Semaste if (platform_sp) 317258882Semaste return platform_sp->GetWorkingDirectory().GetCString(); 318258882Semaste return NULL; 319258882Semaste} 320258882Semaste 321258882Semastebool 322258882SemasteSBPlatform::SetWorkingDirectory(const char *path) 323258882Semaste{ 324258882Semaste PlatformSP platform_sp(GetSP()); 325258882Semaste if (platform_sp) 326258882Semaste { 327258882Semaste if (path) 328258882Semaste platform_sp->SetWorkingDirectory(ConstString(path)); 329258882Semaste else 330258882Semaste platform_sp->SetWorkingDirectory(ConstString()); 331258882Semaste return true; 332258882Semaste } 333258882Semaste return false; 334258882Semaste} 335258882Semaste 336258882SemasteSBError 337258882SemasteSBPlatform::ConnectRemote (SBPlatformConnectOptions &connect_options) 338258882Semaste{ 339258882Semaste SBError sb_error; 340258882Semaste PlatformSP platform_sp(GetSP()); 341258882Semaste if (platform_sp && connect_options.GetURL()) 342258882Semaste { 343258882Semaste Args args; 344258882Semaste args.AppendArgument(connect_options.GetURL()); 345258882Semaste sb_error.ref() = platform_sp->ConnectRemote(args); 346258882Semaste } 347258882Semaste else 348258882Semaste { 349258882Semaste sb_error.SetErrorString("invalid platform"); 350258882Semaste } 351258882Semaste return sb_error; 352258882Semaste} 353258882Semaste 354258882Semastevoid 355258882SemasteSBPlatform::DisconnectRemote () 356258882Semaste{ 357258882Semaste PlatformSP platform_sp(GetSP()); 358258882Semaste if (platform_sp) 359258882Semaste platform_sp->DisconnectRemote(); 360258882Semaste} 361258882Semaste 362258882Semastebool 363258882SemasteSBPlatform::IsConnected() 364258882Semaste{ 365258882Semaste PlatformSP platform_sp(GetSP()); 366258882Semaste if (platform_sp) 367258882Semaste platform_sp->IsConnected(); 368258882Semaste return false; 369258882Semaste} 370258882Semaste 371258882Semasteconst char * 372258882SemasteSBPlatform::GetTriple() 373258882Semaste{ 374258882Semaste PlatformSP platform_sp(GetSP()); 375258882Semaste if (platform_sp) 376258882Semaste { 377258882Semaste ArchSpec arch(platform_sp->GetRemoteSystemArchitecture()); 378258882Semaste if (arch.IsValid()) 379258882Semaste { 380258882Semaste // Const-ify the string so we don't need to worry about the lifetime of the string 381258882Semaste return ConstString(arch.GetTriple().getTriple().c_str()).GetCString(); 382258882Semaste } 383258882Semaste } 384258882Semaste return NULL; 385258882Semaste} 386258882Semaste 387258882Semasteconst char * 388258882SemasteSBPlatform::GetOSBuild() 389258882Semaste{ 390258882Semaste PlatformSP platform_sp(GetSP()); 391258882Semaste if (platform_sp) 392258882Semaste { 393258882Semaste std::string s; 394258882Semaste if (platform_sp->GetOSBuildString(s)) 395258882Semaste { 396258882Semaste if (!s.empty()) 397258882Semaste { 398258882Semaste // Const-ify the string so we don't need to worry about the lifetime of the string 399258882Semaste return ConstString(s.c_str()).GetCString(); 400258882Semaste } 401258882Semaste } 402258882Semaste } 403258882Semaste return NULL; 404258882Semaste} 405258882Semaste 406258882Semasteconst char * 407258882SemasteSBPlatform::GetOSDescription() 408258882Semaste{ 409258882Semaste PlatformSP platform_sp(GetSP()); 410258882Semaste if (platform_sp) 411258882Semaste { 412258882Semaste std::string s; 413258882Semaste if (platform_sp->GetOSKernelDescription(s)) 414258882Semaste { 415258882Semaste if (!s.empty()) 416258882Semaste { 417258882Semaste // Const-ify the string so we don't need to worry about the lifetime of the string 418258882Semaste return ConstString(s.c_str()).GetCString(); 419258882Semaste } 420258882Semaste } 421258882Semaste } 422258882Semaste return NULL; 423258882Semaste} 424258882Semaste 425258882Semasteconst char * 426258882SemasteSBPlatform::GetHostname () 427258882Semaste{ 428258882Semaste PlatformSP platform_sp(GetSP()); 429258882Semaste if (platform_sp) 430258882Semaste return platform_sp->GetHostname(); 431258882Semaste return NULL; 432258882Semaste} 433258882Semaste 434258882Semasteuint32_t 435258882SemasteSBPlatform::GetOSMajorVersion () 436258882Semaste{ 437258882Semaste uint32_t major, minor, update; 438258882Semaste PlatformSP platform_sp(GetSP()); 439258882Semaste if (platform_sp && platform_sp->GetOSVersion(major, minor, update)) 440258882Semaste return major; 441258882Semaste return UINT32_MAX; 442258882Semaste 443258882Semaste} 444258882Semaste 445258882Semasteuint32_t 446258882SemasteSBPlatform::GetOSMinorVersion () 447258882Semaste{ 448258882Semaste uint32_t major, minor, update; 449258882Semaste PlatformSP platform_sp(GetSP()); 450258882Semaste if (platform_sp && platform_sp->GetOSVersion(major, minor, update)) 451258882Semaste return minor; 452258882Semaste return UINT32_MAX; 453258882Semaste} 454258882Semaste 455258882Semasteuint32_t 456258882SemasteSBPlatform::GetOSUpdateVersion () 457258882Semaste{ 458258882Semaste uint32_t major, minor, update; 459258882Semaste PlatformSP platform_sp(GetSP()); 460258882Semaste if (platform_sp && platform_sp->GetOSVersion(major, minor, update)) 461258882Semaste return update; 462258882Semaste return UINT32_MAX; 463258882Semaste} 464258882Semaste 465258882SemasteSBError 466258882SemasteSBPlatform::Get (SBFileSpec &src, 467258882Semaste SBFileSpec &dst) 468258882Semaste{ 469258882Semaste SBError sb_error; 470258882Semaste PlatformSP platform_sp(GetSP()); 471258882Semaste if (platform_sp) 472258882Semaste { 473258882Semaste sb_error.ref() = platform_sp->GetFile(src.ref(), dst.ref()); 474258882Semaste } 475258882Semaste else 476258882Semaste { 477258882Semaste sb_error.SetErrorString("invalid platform"); 478258882Semaste } 479258882Semaste return sb_error; 480258882Semaste} 481258882Semaste 482258882SemasteSBError 483258882SemasteSBPlatform::Put (SBFileSpec &src, 484258882Semaste SBFileSpec &dst) 485258882Semaste{ 486258882Semaste SBError sb_error; 487258882Semaste 488258882Semaste PlatformSP platform_sp(GetSP()); 489258882Semaste if (platform_sp) 490258882Semaste { 491258882Semaste if (src.Exists()) 492258882Semaste { 493258882Semaste uint32_t permissions = src.ref().GetPermissions(); 494258882Semaste if (permissions == 0) 495258882Semaste { 496258882Semaste if (src.ref().GetFileType() == FileSpec::eFileTypeDirectory) 497258882Semaste permissions = eFilePermissionsDirectoryDefault; 498258882Semaste else 499258882Semaste permissions = eFilePermissionsFileDefault; 500258882Semaste } 501258882Semaste 502258882Semaste sb_error.ref() = platform_sp->PutFile(src.ref(), 503258882Semaste dst.ref(), 504258882Semaste permissions); 505258882Semaste } 506258882Semaste else 507258882Semaste { 508258882Semaste sb_error.ref().SetErrorStringWithFormat("'src' argument doesn't exist: '%s'", src.ref().GetPath().c_str()); 509258882Semaste } 510258882Semaste } 511258882Semaste else 512258882Semaste { 513258882Semaste sb_error.SetErrorString("invalid platform"); 514258882Semaste } 515258882Semaste return sb_error; 516258882Semaste} 517258882Semaste 518258882SemasteSBError 519258882SemasteSBPlatform::Install (SBFileSpec &src, 520258882Semaste SBFileSpec &dst) 521258882Semaste{ 522258882Semaste SBError sb_error; 523258882Semaste PlatformSP platform_sp(GetSP()); 524258882Semaste if (platform_sp) 525258882Semaste { 526258882Semaste if (src.Exists()) 527258882Semaste { 528258882Semaste sb_error.ref() = platform_sp->Install(src.ref(), dst.ref()); 529258882Semaste } 530258882Semaste else 531258882Semaste { 532258882Semaste sb_error.ref().SetErrorStringWithFormat("'src' argument doesn't exist: '%s'", src.ref().GetPath().c_str()); 533258882Semaste } 534258882Semaste } 535258882Semaste else 536258882Semaste { 537258882Semaste sb_error.SetErrorString("invalid platform"); 538258882Semaste } 539258882Semaste return sb_error; 540258882Semaste} 541258882Semaste 542258882Semaste 543258882SemasteSBError 544258882SemasteSBPlatform::Run (SBPlatformShellCommand &shell_command) 545258882Semaste{ 546258882Semaste SBError sb_error; 547258882Semaste PlatformSP platform_sp(GetSP()); 548258882Semaste if (platform_sp) 549258882Semaste { 550258882Semaste if (platform_sp->IsConnected()) 551258882Semaste { 552258882Semaste const char *command = shell_command.GetCommand(); 553258882Semaste if (command) 554258882Semaste { 555258882Semaste const char *working_dir = shell_command.GetWorkingDirectory(); 556258882Semaste if (working_dir == NULL) 557258882Semaste { 558258882Semaste working_dir = platform_sp->GetWorkingDirectory().GetCString(); 559258882Semaste if (working_dir) 560258882Semaste shell_command.SetWorkingDirectory(working_dir); 561258882Semaste } 562258882Semaste sb_error.ref() = platform_sp->RunShellCommand(command, 563258882Semaste working_dir, 564258882Semaste &shell_command.m_opaque_ptr->m_status, 565258882Semaste &shell_command.m_opaque_ptr->m_signo, 566258882Semaste &shell_command.m_opaque_ptr->m_output, 567258882Semaste shell_command.m_opaque_ptr->m_timeout_sec); 568258882Semaste } 569258882Semaste else 570258882Semaste { 571258882Semaste sb_error.SetErrorString("invalid shell command (empty)"); 572258882Semaste } 573258882Semaste } 574258882Semaste else 575258882Semaste { 576258882Semaste sb_error.SetErrorString("not connected"); 577258882Semaste } 578258882Semaste } 579258882Semaste else 580258882Semaste { 581258882Semaste sb_error.SetErrorString("invalid platform"); 582258882Semaste } 583258882Semaste return sb_error; 584258882Semaste} 585258882Semaste 586258882SemasteSBError 587258882SemasteSBPlatform::MakeDirectory (const char *path, uint32_t file_permissions) 588258882Semaste{ 589258882Semaste SBError sb_error; 590258882Semaste PlatformSP platform_sp(GetSP()); 591258882Semaste if (platform_sp) 592258882Semaste { 593258882Semaste sb_error.ref() = platform_sp->MakeDirectory(path, file_permissions); 594258882Semaste } 595258882Semaste else 596258882Semaste { 597258882Semaste sb_error.SetErrorString("invalid platform"); 598258882Semaste } 599258882Semaste return sb_error; 600258882Semaste} 601258882Semaste 602258882Semasteuint32_t 603258882SemasteSBPlatform::GetFilePermissions (const char *path) 604258882Semaste{ 605258882Semaste PlatformSP platform_sp(GetSP()); 606258882Semaste if (platform_sp) 607258882Semaste { 608258882Semaste uint32_t file_permissions = 0; 609258882Semaste platform_sp->GetFilePermissions(path, file_permissions); 610258882Semaste return file_permissions; 611258882Semaste } 612258882Semaste return 0; 613258882Semaste 614258882Semaste} 615258882Semaste 616258882SemasteSBError 617258882SemasteSBPlatform::SetFilePermissions (const char *path, uint32_t file_permissions) 618258882Semaste{ 619258882Semaste SBError sb_error; 620258882Semaste PlatformSP platform_sp(GetSP()); 621258882Semaste if (platform_sp) 622258882Semaste { 623258882Semaste sb_error.ref() = platform_sp->SetFilePermissions(path, file_permissions); 624258882Semaste } 625258882Semaste else 626258882Semaste { 627258882Semaste sb_error.SetErrorString("invalid platform"); 628258882Semaste } 629258882Semaste return sb_error; 630258882Semaste 631258882Semaste} 632258882Semaste 633