file(COPY_FILE): Add option to retry on Windows if input access fails

On Windows, a file may be inaccessible for a short time after it is
created.  This occurs for various reasons, including indexing, antivirus
tools, and NTFS's asynchronous semantics.  Add an `INPUT_MAY_BE_RECENT`
option to tell CMake that the input file may have been recently created
so that we can retry a few times to read it.
This commit is contained in:
Brad King
2022-11-17 13:27:21 -05:00
parent fa518188d8
commit efa9eec040
6 changed files with 52 additions and 3 deletions

View File

@@ -149,6 +149,11 @@ public:
Always,
OnlyIfDifferent,
};
enum class CopyInputRecent
{
No,
Yes,
};
enum class CopyResult
{
Success,
@@ -179,6 +184,7 @@ public:
/** Copy a file. */
static CopyResult CopySingleFile(std::string const& oldname,
std::string const& newname, CopyWhen when,
CopyInputRecent inputRecent,
std::string* err = nullptr);
enum class Replace