summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Support/Unix/PathV2.inc
diff options
context:
space:
mode:
authorMichael J. Spencer <bigcheesegs@gmail.com>2010-11-29 22:28:51 +0000
committerMichael J. Spencer <bigcheesegs@gmail.com>2010-11-29 22:28:51 +0000
commitebad2f9d363e2554da497cf9f76cc16bef46e62f (patch)
tree5ddd05ab0aa0f27c9449938055fefe1edf4f7ec6 /llvm/lib/Support/Unix/PathV2.inc
parent6d935a2e5c8c43d70ad9c787385a39eecbc4f6ff (diff)
downloadbcm5719-llvm-ebad2f9d363e2554da497cf9f76cc16bef46e62f.tar.gz
bcm5719-llvm-ebad2f9d363e2554da497cf9f76cc16bef46e62f.zip
Support: Add PathV2 implementation.
llvm-svn: 120329
Diffstat (limited to 'llvm/lib/Support/Unix/PathV2.inc')
-rw-r--r--llvm/lib/Support/Unix/PathV2.inc39
1 files changed, 39 insertions, 0 deletions
diff --git a/llvm/lib/Support/Unix/PathV2.inc b/llvm/lib/Support/Unix/PathV2.inc
new file mode 100644
index 00000000000..bcd93f046dd
--- /dev/null
+++ b/llvm/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
OpenPOWER on IntegriCloud