Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/marian-nmt/sentencepiece.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTaku Kudo <taku910@users.noreply.github.com>2018-08-03 08:58:47 +0300
committerGitHub <noreply@github.com>2018-08-03 08:58:47 +0300
commitc93b4d15cdfe33dcab3e091d141882d9ce18deeb (patch)
tree9cd94115261e3927391561957315d194679be887 /src/testharness.cc
parenta0b734a4a2a2259e346f5b602ba807c5deef2f0b (diff)
parent1caa5fb76eb41c7ce8bf17a67a1db7024d82e788 (diff)
Merge pull request #150 from google/sr
Added JoinPath and StrCat
Diffstat (limited to 'src/testharness.cc')
-rw-r--r--src/testharness.cc20
1 files changed, 16 insertions, 4 deletions
diff --git a/src/testharness.cc b/src/testharness.cc
index afdfac3..35bf893 100644
--- a/src/testharness.cc
+++ b/src/testharness.cc
@@ -66,12 +66,24 @@ int RunAllTests() {
return 0;
}
-ScopedTempFile::ScopedTempFile(const std::string &filename) {
+ScopedTempFile::ScopedTempFile(absl::string_view filename) {
char pid[64];
- snprintf(pid, sizeof(pid), "%u", getpid());
- filename_ = "/tmp/.XXX.tmp." + filename + "." + pid;
+ snprintf(pid, sizeof(pid), "%u",
+#ifdef OS_WIN
+ static_cast<uint32>(::GetCurrentProcessId())
+#else
+ ::getpid()
+#endif
+ );
+ filename_ = string_util::StrCat(".XXX.tmp.", filename, ".", pid);
}
-ScopedTempFile::~ScopedTempFile() { ::unlink(filename_.c_str()); }
+ScopedTempFile::~ScopedTempFile() {
+#ifdef OS_WIN
+ ::DeleteFile(WPATH(filename_.c_str()));
+#else
+ ::unlink(filename_.c_str());
+#endif
+}
} // namespace test
} // namespace sentencepiece