diff options
author | Michael J. Spencer <bigcheesegs@gmail.com> | 2010-11-29 22:28:51 +0000 |
---|---|---|
committer | Michael J. Spencer <bigcheesegs@gmail.com> | 2010-11-29 22:28:51 +0000 |
commit | dffde9964480f946d4308ce936b667b6c37b1059 (patch) | |
tree | 11cddd0a2725d0fd441afa52cf8e5c7c92e3ae01 /lib/Support/Unix | |
parent | 44c1bc14570e77630b5e6711ed42886aad848086 (diff) | |
download | external_llvm-dffde9964480f946d4308ce936b667b6c37b1059.zip external_llvm-dffde9964480f946d4308ce936b667b6c37b1059.tar.gz external_llvm-dffde9964480f946d4308ce936b667b6c37b1059.tar.bz2 |
Support: Add PathV2 implementation.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@120329 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Support/Unix')
-rw-r--r-- | lib/Support/Unix/PathV2.inc | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/lib/Support/Unix/PathV2.inc b/lib/Support/Unix/PathV2.inc new file mode 100644 index 0000000..bcd93f0 --- /dev/null +++ b/lib/Support/Unix/PathV2.inc @@ -0,0 +1,39 @@ +//===- llvm/Support/Unix/PathV2.cpp - Unix Path Implementation --*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// +// +// This file implements the Unix specific implementation of the PathV2 API. +// +//===----------------------------------------------------------------------===// + +//===----------------------------------------------------------------------===// +//=== WARNING: Implementation here must contain only generic UNIX code that +//=== is guaranteed to work on *all* UNIX variants. +//===----------------------------------------------------------------------===// + +#include "Unix.h" + +namespace llvm { +namespace sys { +namespace path { + +error_code current_path(SmallVectorImpl<char> &result) { + long size = ::pathconf(".", _PC_PATH_MAX); + result.reserve(size + 1); + result.set_size(size + 1); + + if (::getcwd(result.data(), result.size()) == 0) + return error_code(errno, system_category()); + + result.set_size(strlen(result.data())); + return make_error_code(errc::success); +} + +} // end namespace path +} // end namespace sys +} // end namespace llvm |