summaryrefslogtreecommitdiff
path: root/src/TemporaryFile.cpp
Commit message (Collapse)AuthorAgeFilesLines
* fix: Make sure that temporary files always have .tmp. in the nameJoel Rosdahl2022-09-211-1/+7
| | | | | PrimaryStorage::clean_dir relies on being able to classify temporary files from the filename.
* refactor: Use FMT macro to format exception messagesJoel Rosdahl2022-08-241-1/+1
| | | | | Using the FMT macro explicitly makes invalid format message constructions compile-time errors instead of run-time errors.
* fix: Create temporary file with cpp extension instead of hard linkingJoel Rosdahl2022-06-071-5/+13
| | | | | | | | | | | | | | | [1] added a suitable file extension to the temporary file used for capturing the preprocessed output by creating a hard link. This fails when the temporary directory is on a file system that doesn't support hard links. Fix this by making it possible to pass a suffix to TemporaryFile and passing the proper cpp suffix for the tmp stdout file instead of creating a hard link as an alias. [1]: 4da9f2b474b7ee39cd54ab4261f90936f3c944ec Closes #1079.
* chore: Replace nonstd::string_view with std::string_viewJoel Rosdahl2022-05-231-3/+1
|
* refactor: Extract get_umask function to UtilJoel Rosdahl2022-02-191-21/+2
|
* Move exceptions.hpp to coreJoel Rosdahl2021-07-201-1/+3
|
* Adapt to the ccache code styleJoel Rosdahl2021-01-061-4/+5
|
* Improve TemporaryFile implementation for Windows (#736)Nicholas Hutchinson2020-12-281-0/+13
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | On Windows, multiple ccache process could race each other to create, rename and delete temporary files, because they would attempt to generate the same sequence of temporary file names (`tmp.cpp_stdout.iG2Kb7`, `tmp.cpp_stdout.P1kAlM`, `tmp.cpp_stdout.FzP5tM`, ...). This is because ccache used mingw-w64's [implementation of mkstemp][1], which uses `rand()` to generate temporary file names, and ccache was never seeding the thread-local PRNG used by `rand()`. Replace ccache's use of `mkstemp()` on Windows with an implementation based on OpenBSD. This allows us to sidestep mingw-w64's problematic implementation, and allows us to build using MSVC again. (MSVC's C standard library does not provide `mkstemp()`.) Example errors: - Some ccache process is in the process of deleting a temporary file: ccache: error: Failed to create temporary file for C:\Users\someuser/.ccache/tmp/tmp.cpp_stdout.FzP5tM: Access is denied. - Some ccache process has destination file open, so it can't be overwritten: ccache: error: failed to rename C:\Users\someuser/.ccache/tmp/tmp.cpp_stdout.iG2Kb7 to C:\Users\someuser/.ccache/tmp/tmp.cpp_stdout.iG2Kb7.ii: Access is denied. - Source file has been deleted by some other ccache process: ccache: error: failed to rename C:\Users\someuser/.ccache/tmp/tmp.cpp_stdout.P1kAlM to C:\Users\someuser/.ccache/tmp/tmp.cpp_stdout.P1kAlM.ii: The system cannot find the file specified. [1]: https://github.com/mirror/mingw-w64/blob/v8.0.0/mingw-w64-crt/misc/mkstemp.c
* Remove legacy “cheap and nasty” mkstemp replacementJoel Rosdahl2020-12-061-17/+0
| | | | | | | Hopefully mkstemp is available on all systems we want to support these days. As mentioned in #703.
* Simplify TemporaryFileJoel Rosdahl2020-09-081-16/+3
|
* Rename FatalError class to FatalJoel Rosdahl2020-08-221-3/+2
| | | | | This makes the naming more consistent with the other exception classes (Error and Failure).
* Retrieve non-const pointer to std::string data without castingJoel Rosdahl2020-08-041-1/+1
|
* Replace fatal function with throwing FatalError exception explicitlyJoel Rosdahl2020-08-031-2/+4
| | | | | I think that this improves code readability since it’s more clear what the code flow is.
* Remove now empty legacy_util.[hc]pp filesJoel Rosdahl2020-07-311-1/+0
|
* Move set_cloexec_flag to UtilJoel Rosdahl2020-07-311-1/+1
|
* Convert FATAL macro to a functionJoel Rosdahl2020-07-311-2/+2
|
* Convert fatal() function to macro that forwards to fmt::formatJoel Rosdahl2020-07-281-6/+2
|
* Introduce and use TemporaryFile classJoel Rosdahl2020-07-251-0/+92
In addition to improving code clarity, this fixes a bug where the fallback code for “-fdiagnostics-color” tried to operate on a closed file descriptor.