2 * ========================================================================
3 * Copyright 2013-2022 Eduardo Chappa
4 * Copyright 2006 University of Washington
6 * Licensed under the Apache License, Version 2.0 (the "License");
7 * you may not use this file except in compliance with the License.
8 * You may obtain a copy of the License at
10 * http://www.apache.org/licenses/LICENSE-2.0
12 * ========================================================================
17 #include "../charconv/utf8.h"
18 #include "../charconv/filesys.h"
22 /*----------------------------------------------------------------------
25 Args: tmpfname -- Old name of file
26 fname -- New name of file
28 Result: File is renamed. Returns 0 on success, else -1 on error
32 rename_file(char *tmpfname
, char *fname
)
35 return(our_rename(tmpfname
, fname
));
37 # if defined(_WINDOWS)
41 * DOS rename doesn't unlink destination for us...
43 if((ret
= our_unlink(fname
)) && (errno
== EPERM
)){
47 ret
= our_rename(tmpfname
, fname
);
57 if ((status
= link(tmpfname
, fname
)) != 0)