Add umask and rename compatibility wrappers for Windows

umask() doesn't exist on Windows and is thus a no-op.

rename() only works if the destination doesn't already exist,
so we must unlink before renaming.
This commit is contained in:
Cyril Cleaud
2014-06-26 22:59:17 -07:00
committed by Andrew Ayer
parent dcea03f0d7
commit df2b472cd9
5 changed files with 32 additions and 6 deletions

View File

@@ -325,3 +325,16 @@ static void init_std_streams_platform ()
_setmode(_fileno(stdin), _O_BINARY);
_setmode(_fileno(stdout), _O_BINARY);
}
mode_t util_umask (mode_t mode)
{
// Not available in Windows and function not always defined in Win32 environments
return 0;
}
int util_rename (const char* from, const char* to)
{
// On Windows OS, it is necessary to ensure target file doesn't exist
unlink(to);
return rename(from, to);
}