diff options
author | Michael J. Spencer <bigcheesegs@gmail.com> | 2010-12-03 17:53:43 +0000 |
---|---|---|
committer | Michael J. Spencer <bigcheesegs@gmail.com> | 2010-12-03 17:53:43 +0000 |
commit | 6e74e11c85cb75b0bad6fd39153bc4200358701d (patch) | |
tree | 05701140d83419074584978f6c0f616ff11db3eb /llvm/lib/Support/Windows | |
parent | 772caff53295309683e0badc493fcfd22beedc59 (diff) | |
download | bcm5719-llvm-6e74e11c85cb75b0bad6fd39153bc4200358701d.tar.gz bcm5719-llvm-6e74e11c85cb75b0bad6fd39153bc4200358701d.zip |
Support/FileSystem: Add remove implementation.
llvm-svn: 120817
Diffstat (limited to 'llvm/lib/Support/Windows')
-rw-r--r-- | llvm/lib/Support/Windows/PathV2.inc | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/llvm/lib/Support/Windows/PathV2.inc b/llvm/lib/Support/Windows/PathV2.inc index 98db5fdf388..c86c24e811e 100644 --- a/llvm/lib/Support/Windows/PathV2.inc +++ b/llvm/lib/Support/Windows/PathV2.inc @@ -252,6 +252,25 @@ error_code create_symlink(const Twine &to, const Twine &from) { return make_error_code(errc::success); } +error_code remove(const Twine &path, bool &existed) { + SmallString<128> path_storage; + SmallVector<wchar_t, 128> path_utf16; + + if (error_code ec = UTF8ToUTF16(path.toStringRef(path_storage), + path_utf16)) + return ec; + + if (!::DeleteFileW(path_utf16.begin())) { + error_code ec = make_error_code(windows_error(::GetLastError())); + if (ec != make_error_code(windows_error::file_not_found)) + return ec; + existed = false; + } else + existed = true; + + return make_error_code(errc::success); +} + error_code exists(const Twine &path, bool &result) { SmallString<128> path_storage; SmallVector<wchar_t, 128> path_utf16; |