summaryrefslogtreecommitdiff
path: root/db/filename.cc
diff options
context:
space:
mode:
authorVictor Costan <pwnall@chromium.org>2019-11-30 14:44:18 -0800
committerVictor Costan <pwnall@chromium.org>2019-12-02 14:29:59 -0800
commit77c27645e49ec13967a7b5a271c666ddf0342f45 (patch)
treeea09d3d10f0af321c61af8a99a858f0f4f04f7cc /db/filename.cc
parent58a89bbcb28d02d5704c5fff7aeb6e72f7ca2431 (diff)
downloadleveldb-env_rename.tar.gz
Add Env::Remove{File,Dir} which obsolete Env::Delete{File,Dir}.env_rename
The "DeleteFile" method name causes pain for Windows developers, because <windows.h> #defines a DeleteFile macro to DeleteFileW or DeleteFileA. Current code uses workarounds, like #undefining DeleteFile everywhere an Env is declared, implemented, or used. This CL removes the need for workarounds by renaming Env::DeleteFile to Env::RemoveFile. For consistency, Env::DeleteDir is also renamed to Env::RemoveDir. A few internal methods are also renamed for consistency. Software that supports Windows is expected to migrate any Env implementations and usage to Remove{File,Dir}, and never use the name Env::Delete{File,Dir} in its code. The renaming is done in a backwards-compatible way, at the risk of making it slightly more difficult to build a new correct Env implementation. The backwards compatibility is achieved using the following hacks: 1) Env::Remove{File,Dir} methods are added, with a default implementation that calls into Env::Delete{File,Dir}. This makes old Env implementations compatible with code that calls into the updated API. 2) The Env::Delete{File,Dir} methods are no longer pure virtuals. Instead, they gain a default implementation that calls into Env::Remove{File,Dir}. This makes updated Env implementations compatible with code that calls into the old API. The cost of this approach is that it's possible to write an Env without overriding either Rename{File,Dir} or Delete{File,Dir}, without getting a compiler warning. However, attempting to run the test suite will immediately fail with an infinite call stack ending in {Remove,Delete}{File,Dir}, making developers aware of the problem.
Diffstat (limited to 'db/filename.cc')
-rw-r--r--db/filename.cc2
1 files changed, 1 insertions, 1 deletions
diff --git a/db/filename.cc b/db/filename.cc
index 85de45c..9b451fc 100644
--- a/db/filename.cc
+++ b/db/filename.cc
@@ -133,7 +133,7 @@ Status SetCurrentFile(Env* env, const std::string& dbname,
s = env->RenameFile(tmp, CurrentFileName(dbname));
}
if (!s.ok()) {
- env->DeleteFile(tmp);
+ env->RemoveFile(tmp);
}
return s;
}