aboutsummaryrefslogtreecommitdiff
path: root/lib/Support/Windows/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/Windows/PathV2.inc
parenta50b98c517cc90e6c8929b721049c9a589682e6d (diff)
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/Windows/PathV2.inc')
-rw-r--r--lib/Support/Windows/PathV2.inc19
1 files changed, 19 insertions, 0 deletions
diff --git a/lib/Support/Windows/PathV2.inc b/lib/Support/Windows/PathV2.inc
index c97ba5df59..e98150713b 100644
--- a/lib/Support/Windows/PathV2.inc
+++ b/lib/Support/Windows/PathV2.inc
@@ -18,7 +18,10 @@
#include "Windows.h"
#include <WinCrypt.h>
+#include <fcntl.h>
#include <io.h>
+#include <sys/stat.h>
+#include <sys/types.h>
using namespace llvm;
@@ -290,6 +293,22 @@ 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;
+ SmallVector<wchar_t, 128> path_utf16;
+
+ if (error_code ec = UTF8ToUTF16(path.toStringRef(path_storage),
+ path_utf16))
+ return ec;
+
+ int fd = ::_wopen(path_utf16.begin(), O_BINARY, S_IREAD | S_IWRITE);
+ if (fd == -1)
+ return error_code(errno, generic_category());
+ errno_t error = ::_chsize_s(fd, size);
+ ::close(fd);
+ return error_code(error, generic_category());
+}
+
error_code exists(const Twine &path, bool &result) {
SmallString<128> path_storage;
SmallVector<wchar_t, 128> path_utf16;