blob: bcd93f046ddc179ccef25ef2838e99d67262042a [file] [log] [blame]
Michael J. Spencerdffde992010-11-29 22:28:51 +00001//===- llvm/Support/Unix/PathV2.cpp - Unix Path Implementation --*- C++ -*-===//
2//
3// The LLVM Compiler Infrastructure
4//
5// This file is distributed under the University of Illinois Open Source
6// License. See LICENSE.TXT for details.
7//
8//===----------------------------------------------------------------------===//
9//
10// This file implements the Unix specific implementation of the PathV2 API.
11//
12//===----------------------------------------------------------------------===//
13
14//===----------------------------------------------------------------------===//
15//=== WARNING: Implementation here must contain only generic UNIX code that
16//=== is guaranteed to work on *all* UNIX variants.
17//===----------------------------------------------------------------------===//
18
19#include "Unix.h"
20
21namespace llvm {
22namespace sys {
23namespace path {
24
25error_code current_path(SmallVectorImpl<char> &result) {
26 long size = ::pathconf(".", _PC_PATH_MAX);
27 result.reserve(size + 1);
28 result.set_size(size + 1);
29
30 if (::getcwd(result.data(), result.size()) == 0)
31 return error_code(errno, system_category());
32
33 result.set_size(strlen(result.data()));
34 return make_error_code(errc::success);
35}
36
37} // end namespace path
38} // end namespace sys
39} // end namespace llvm