summaryrefslogtreecommitdiff
path: root/util/env_windows.cc
Commit message (Collapse)AuthorAgeFilesLines
* Merge pull request #965 from ShawnZhong:cpp20Victor Costan2022-01-081-2/+2
|\ | | | | | | PiperOrigin-RevId: 420504266
* | Fix typosDimitris Apostolou2022-01-051-1/+1
|/
* Add invariant checks to Limiter in Env implementations.Victor Costan2021-12-221-2/+22
| | | | PiperOrigin-RevId: 417853172
* Prevent handle used for LOG from being inherited by subprocessesDylan K. Taylor2021-10-091-1/+1
| | | | | | | | | | | | | | I recently encountered a problem with this because Windows doesn't allow files to be deleted when there's open handles to them. Other files opened by leveldb are not affected because by and large they are using CreateFileA, which does not allow inheritance when lpSecurityAttributes is null (ref: https://docs.microsoft.com/en-us/windows/win32/api/fileapi/nf-fileapi-createfilea) However, fopen() _does_ allow inheritance, and it needs to be expressly disabled. https://docs.microsoft.com/en-us/cpp/c-runtime-library/reference/fopen-wfopen?view=msvc-160
* Add Env::Remove{File,Dir} which obsolete Env::Delete{File,Dir}.Victor Costan2020-01-091-6/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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. PiperOrigin-RevId: 288710907
* Align EnvPosix and EnvWindows.Victor Costan2019-06-131-217/+306
| | | | | | Fixes #695. PiperOrigin-RevId: 252895299
* Correct class/structure declaration order.Chris Mumford2019-05-031-9/+7
| | | | | | | | | | | | | 1. Correct the class/struct declaration order to be IAW the Google C++ style guide[1]. 2. For non-copyable classes, switched from non-implemented private methods to explicitly deleted[2] methods. 3. Minor const and member initialization fixes. [1] https://google.github.io/styleguide/cppguide.html#Declaration_Order [2] http://eel.is/c++draft/dcl.fct.def.delete PiperOrigin-RevId: 246521844
* Format all files IAW the Google C++ Style Guide.Chris Mumford2019-05-021-5/+2
| | | | | | Use clang-format to correct formatting to be in agreement with the [Google C++ Style Guide](https://google.github.io/styleguide/cppguide.html). Doing this simplifies the process of accepting changes. Also fixed a few warnings flagged by clang-tidy. PiperOrigin-RevId: 246350737
* Two small fixes for the Windows implementation (#661)Felipe Oliveira Carvalho2019-03-211-0/+2
| | | | | | * Check if NOMIMMAX is defined before defining it * Pass char* for a %s format in a snprintf call
* Switch corruption_test to use InMemEnv.cmumford2019-03-201-20/+0
| | | | | | | | | | | | | This change switches corruption_test, which previously used direct file I/O to corrupt table files for open databases, to use InMemEnv. Using an Env eliminates some platform dependencies thus simplifying the tests. Also removed EnvWindowsTestHelper::RelaxFilePermissions(). This was only added because the Windows Env opens files for exclusive access. ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=239305329
* leveldb: Replace AtomicPointer with std::atomic.costan2019-03-111-32/+24
| | | | | | | | | | | | This CL removes AtomicPointer from leveldb's port interface. Its usage is replaced with std::atomic<> from the C++11 standard library. AtomicPointer was used to wrap flags, numbers, and pointers, so its instances are replaced with std::atomic<bool>, std::atomic<int>, std::atomic<size_t> and std::atomic<Node*>. This CL does not revise the memory ordering. AtomicPointer's methods are replaced mechanically with their std::atomic equivalents, even when the underlying usage is incorrect. (Example: DBImpl::has_imm_ is written using release stores, even though it is always read using relaxed ordering.) Revising the memory ordering is left for future CLs. ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=237865146
* Align windows_logger with posix_logger.costan2019-03-071-7/+7
| | | | | | | | | | Fixes GitHub issue #657. This CL also makes the Windows CI green. ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=237255887
* Added native support for Windows.cmumford2019-03-011-0/+742
This change adds a native Windows port (port_windows.h) and a Windows Env (WindowsEnv). Note1: "small" is defined when including <Windows.h> so some parameters were renamed to avoid conflict. Note2: leveldb::Env defines the method: "DeleteFile" which is also a constant defined when including <Windows.h>. The solution was to ensure this macro is defined in env.h which forces the function, when compiled, to be either DeleteFileA or DeleteFileW when building for MBCS or UNICODE respectively. This resolves #519 on GitHub. ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=236364778