| Commit message (Collapse) | Author | Age | Files | Lines |
| |
|
|
|
| |
As suggested by clang-tidy
(cppcoreguidelines-prefer-member-initializer).
|
| | |
|
| |
|
|
|
| |
Using the FMT macro explicitly makes invalid format message
constructions compile-time errors instead of run-time errors.
|
| | |
|
| |
|
|
| |
This is the next step after a57f70eda32e99221de56f5499079b4f00dc2bc5.
|
| |
|
|
|
|
|
|
| |
Win32 functions like `CreateFile` return `ERROR_ACCESS_DENIED` when a
file is in the process of being deleted, which gets mapped to an errno
of `EACCES`. For the purposes of `Stat::stat` and `Stat::lstat`, it's
more useful to treat this as a missing file and mapping this to an errno
of `ENOENT`.
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
`stat()` as implemented in msvcrt.dll (used by mingw-w64) has a number
of flaws:
- `st_ino` is always 0
- other file attributes are queried from the parent directory instead of
the file itself, and so can be incorrect/stale, e.g. if a file is
modified via another hard link.
The implementation in the UCRT is slightly better -- it prefers to query
attributes from the file itself if possible, but it still doesn't
populate `st_ino` and can silently fall back to querying from the parent
directory and giving stale results.
I don't believe the msvcrt.dll source is available (you have to infer
its behaviour from e.g. Process Monitor) but the ucrtbase.dll source
code is available in the Windows 10 SDK.
Write an implementation of `stat`/`lstat` that sidesteps these issues by
using Win32 APIs to query file information. A few implementation notes:
- We do not fall back to querying the parent directory (as the UCRT
`stat()` implementation and [Python's `stat()`][1] do) if we can't get
a handle to the actual file. If we don't have `FILE_READ_ATTRIBUTES`
permissions, we fail with `EACCES` instead of returning
incomplete/stale results fetched from the parent directory.
- Windows-specific `Stat::file_attributes()` / `Stat::reparse_tag()`
added to provide the Win32 file attributes and file reparse tag.
- `lstat()` sets the `S_IFLNK` bit in `st_mode` for symlinks. On
Windows, there are other symlink-like things ("name surrogate reparse
points") such as directory junctions and mountpoints. To identify
these, the caller can check the reparse tag to identify a directory
junction/mountpoint.
- We use Python's mapping of Win32 error codes to C errno.
[1]: https://github.com/python/cpython/blob/6086ae7fd4aeb4089282189673f9bd0cc33abf9b/Modules/posixmodule.c#L1884
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
fmtlib can detect format string errors at compile time if (1) applying
FMT_STRING to the format string literal and (2) compiling for C++14 or
higher.
Requirement 1 is implemented by introducing a LOG macro which applies
FMT_STRING to the first argument and calls Logging::log (if logging is
enabled). Also added are a companion LOG_RAW macro (since C++11 requires
at least one argument for the “...” part in variadic macros) and a
BULK_LOG macro which calls Logging::bulk_log (if logging is enabled).
Requirement 2 is implemented by setting CMAKE_CXX_STANDARD to 14 for one
CI build with a known C++14-capable compiler. We can’t set it to 14 by
default since we still want the code to be buildable with C++11
compilers.
This will catch errors such as the one fixed by PR #691.
|
| | |
|
| | |
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
- Simplified and C++-ified logging code.
- Added Logging::log and Logging::bulk_log functions corresponding to
the old cc_log and cc_bulklog functions. The new functions pass their
arguments to fmt::format.
- Replacements:
* init_log → Logging::init
* cc_log → Logging::log
* cc_bulklog → Logging::bulk_log
* cc_log_argv → Logging::log plus Util::format_argv_for_logging
* cc_dump_debug_log_buffer -> Logging::dump_log
- A legacy cc_log implementation is still available so that logging can
be converted gradually to the new functionality.
|
| | |
|
| |
|
|
| |
This reduces code dependencies that hamper refactoring.
|
|
|
Introduced a Stat class that represents a “struct stat”. The class
replaces the utility functions x_lstat, x_stat, file_size_on_disk and
is_symlink, and it provides an easier to use interface than the macros
associated with stat structs.
|