CopyFile function kernel32

Win32Result<bool> CopyFile(
  1. PCWSTR lpExistingFileName,
  2. PCWSTR lpNewFileName,
  3. bool bFailIfExists
)

Copies an existing file to a new file.

To learn more, see learn.microsoft.com/windows/win32/api/winbase/nf-winbase-copyfilew.

Implementation

Win32Result<bool> CopyFile(
  PCWSTR lpExistingFileName,
  PCWSTR lpNewFileName,
  bool bFailIfExists,
) {
  resolveGetLastError();
  final result_ = _CopyFile(
    lpExistingFileName,
    lpNewFileName,
    bFailIfExists ? TRUE : FALSE,
  );
  return .new(value: result_ != FALSE, error: GetLastError());
}