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,
) {
  final result_ = CopyFileW_Wrapper(
    lpExistingFileName,
    lpNewFileName,
    bFailIfExists ? TRUE : FALSE,
  );
  return .new(value: result_.value.i32 != FALSE, error: result_.error);
}