1 #if !defined(lint) && !defined(DOS)
2 static char rcsid
[] = "$Id: rename.c 761 2007-10-23 22:35:18Z hubert@u.washington.edu $";
6 * ========================================================================
7 * Copyright 2013-2018 Eduardo Chappa
8 * Copyright 2006 University of Washington
10 * Licensed under the Apache License, Version 2.0 (the "License");
11 * you may not use this file except in compliance with the License.
12 * You may obtain a copy of the License at
14 * http://www.apache.org/licenses/LICENSE-2.0
16 * ========================================================================
21 #include "../charconv/utf8.h"
22 #include "../charconv/filesys.h"
26 /*----------------------------------------------------------------------
29 Args: tmpfname -- Old name of file
30 fname -- New name of file
32 Result: File is renamed. Returns 0 on success, else -1 on error
36 rename_file(char *tmpfname
, char *fname
)
39 return(our_rename(tmpfname
, fname
));
41 # if defined(_WINDOWS)
45 * DOS rename doesn't unlink destination for us...
47 if((ret
= our_unlink(fname
)) && (errno
== EPERM
)){
51 ret
= our_rename(tmpfname
, fname
);
61 if ((status
= link(tmpfname
, fname
)) != 0)