summaryrefslogtreecommitdiff
path: root/lib/Support/Unix/PathV2.inc
diff options
context:
space:
mode:
authorMichael J. Spencer <bigcheesegs@gmail.com>2010-12-03 17:54:07 +0000
committerMichael J. Spencer <bigcheesegs@gmail.com>2010-12-03 17:54:07 +0000
commit3920d3b4f4310c1132d81b8d7c74c95111378680 (patch)
tree198a502420832363abce448684191fae0289179e /lib/Support/Unix/PathV2.inc
parenta50b98c517cc90e6c8929b721049c9a589682e6d (diff)
downloadllvm-3920d3b4f4310c1132d81b8d7c74c95111378680.tar.gz
llvm-3920d3b4f4310c1132d81b8d7c74c95111378680.tar.bz2
llvm-3920d3b4f4310c1132d81b8d7c74c95111378680.tar.xz
Support/FileSystem: Add resize_file implementation.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@120819 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Support/Unix/PathV2.inc')
-rw-r--r--lib/Support/Unix/PathV2.inc10
1 files changed, 10 insertions, 0 deletions
diff --git a/lib/Support/Unix/PathV2.inc b/lib/Support/Unix/PathV2.inc
index 8ecf2a4222..75cfce822a 100644
--- a/lib/Support/Unix/PathV2.inc
+++ b/lib/Support/Unix/PathV2.inc
@@ -213,6 +213,16 @@ error_code rename(const Twine &from, const Twine &to) {
return make_error_code(errc::success);
}
+error_code resize_file(const Twine &path, uint64_t size) {
+ SmallString<128> path_storage;
+ StringRef p = path.toNullTerminatedStringRef(path_storage);
+
+ if (::truncate(p.begin(), size) == -1)
+ return error_code(errno, system_category());
+
+ return make_error_code(errc::success);
+}
+
error_code exists(const Twine &path, bool &result) {
SmallString<128> path_storage;
StringRef p = path.toNullTerminatedStringRef(path_storage);