File: rename.c

package info (click to toggle)
mlton 20100608-5
  • links: PTS
  • area: main
  • in suites: wheezy
  • size: 36,624 kB
  • sloc: ansic: 18,441; lisp: 2,879; makefile: 1,572; sh: 1,326; pascal: 256; asm: 97
file content (17 lines) | stat: -rw-r--r-- 516 bytes parent folder | download | duplicates (6)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
#include "platform.h"

C_Errno_t(C_Int_t) Posix_FileSys_rename (NullString8_t p1, NullString8_t p2) {
  C_Errno_t(C_Int_t) res;
  res = rename ((const char *) p1, (const char *) p2);
#ifdef __MINGW32__
  /* the MinGW rename() function does not remove the destination file 
   * if it exists; we emulate the Unix behavior here. 
   */
  if ((res != 0) && (errno == EEXIST)) {
    res = unlink ((const char *) p2);
    if (res == 0)
      res = rename((const char *) p1, (const char *) p2);
  }
#endif
  return res;
}