From 1d5855b1078569ba49682010fc9be5ec32fef5ea Mon Sep 17 00:00:00 2001 From: Pavel Labath Date: Mon, 23 Jan 2017 15:56:45 +0000 Subject: Replace getcwd with the llvm equivalent Summary: getcwd() is not available (well.. um.. deprecated?) on windows, and the way PosixApi.h is providing it causes strange compile errors when it's included in the wrong order. The best way to avoid that is to just not use chdir. This replaces all uses of getcwd in generic code. There are still a couple of more uses, but these are in platform-specific code. chdir() is causing a similar problem, but for that there is no llvm equivalent for that (yet). Reviewers: zturner Subscribers: lldb-commits Differential Revision: https://reviews.llvm.org/D28858 llvm-svn: 292795 --- lldb/source/Target/Platform.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'lldb/source/Target/Platform.cpp') diff --git a/lldb/source/Target/Platform.cpp b/lldb/source/Target/Platform.cpp index d8db53663f1..4f285e09807 100644 --- a/lldb/source/Target/Platform.cpp +++ b/lldb/source/Target/Platform.cpp @@ -523,11 +523,11 @@ void Platform::AddClangModuleCompilationOptions( FileSpec Platform::GetWorkingDirectory() { if (IsHost()) { - char cwd[PATH_MAX]; - if (getcwd(cwd, sizeof(cwd))) - return FileSpec{cwd, true}; - else + llvm::SmallString<64> cwd; + if (llvm::sys::fs::current_path(cwd)) return FileSpec{}; + else + return FileSpec(cwd, true); } else { if (!m_working_dir) m_working_dir = GetRemoteWorkingDirectory(); -- cgit v1.2.3