Pass a FD to resise_file and add a testcase.
[oota-llvm.git] / lib / Support / Unix / Path.inc
index 1e1b911b78b130d89bf8240ab3f9616f9f428466..75bcc03bbd329fa7e96f419c46a60428e177544b 100644 (file)
@@ -286,11 +286,8 @@ std::error_code rename(const Twine &from, const Twine &to) {
   return std::error_code();
 }
 
-std::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)
+std::error_code resize_file(int FD, uint64_t Size) {
+  if (::ftruncate(FD, Size) == -1)
     return std::error_code(errno, std::generic_category());
 
   return std::error_code();