diff options
author | Kenneth Heafield <github@kheafield.com> | 2014-03-19 22:32:51 +0400 |
---|---|---|
committer | Kenneth Heafield <github@kheafield.com> | 2014-03-19 22:32:51 +0400 |
commit | 5991f7af5a3f28987bb81d72b41dcc457daa54d7 (patch) | |
tree | 7df5a83c383a4f6a3bd6f3fe74d4505fa7942bbb | |
parent | 83c8a6bf107449d38e96206d1b3c016f5ba88852 (diff) |
StringPiece arguments to MakeTemp
-rw-r--r-- | util/file.cc | 6 | ||||
-rw-r--r-- | util/file.hh | 5 |
2 files changed, 6 insertions, 5 deletions
diff --git a/util/file.cc b/util/file.cc index a702ae1..47d3cf1 100644 --- a/util/file.cc +++ b/util/file.cc @@ -444,8 +444,8 @@ void NormalizeTempPrefix(std::string &base) { ) base += '/'; } -int MakeTemp(const std::string &base) { - std::string name(base); +int MakeTemp(const StringPiece &base) { + std::string name(base.data(), base.size()); name += "XXXXXX"; name.push_back(0); int ret; @@ -453,7 +453,7 @@ int MakeTemp(const std::string &base) { return ret; } -std::FILE *FMakeTemp(const std::string &base) { +std::FILE *FMakeTemp(const StringPiece &base) { util::scoped_fd file(MakeTemp(base)); return FDOpenOrThrow(file); } diff --git a/util/file.hh b/util/file.hh index 813972a..170a7c7 100644 --- a/util/file.hh +++ b/util/file.hh @@ -2,6 +2,7 @@ #define UTIL_FILE_H #include "util/exception.hh" +#include "util/string_piece.hh" #include <cstddef> #include <cstdio> @@ -125,8 +126,8 @@ std::FILE *FDOpenReadOrThrow(scoped_fd &file); // Temporary files // Append a / if base is a directory. void NormalizeTempPrefix(std::string &base); -int MakeTemp(const std::string &prefix); -std::FILE *FMakeTemp(const std::string &prefix); +int MakeTemp(const StringPiece &prefix); +std::FILE *FMakeTemp(const StringPiece &prefix); // dup an fd. int DupOrThrow(int fd); |