mirror of
https://projects.blender.org/blender/blender.git
synced 2025-01-22 15:32:15 -05:00
050d48edfc
This commit aim at making the behaviors of `BLI_rename` and `BLI_rename_overwrite` more consistent and coherent across all supported platforms. * `BLI_rename` now only succeeds in case the target `to` path does not exists (similar to Windows `rename` behavior). * `BLI_rename_overwrite` allows to replace an existing target `to` file or (empty) directory (similar to Unix `rename` behavior). NOTE: In case the target is open by some process on the system, trying to overwrite it will still fail on Windows, while it should succeed on Unix-like systems. The main change for Windows is the usage of `MoveFileExW` instead of `_wrename`, which allows for 'native support' of file overwrite (using the `MOVEFILE_REPLACE_EXISTING` flag). Directories still need to be explicitly removed though. The main change for *nix systems is the use of `renamex_np` (OSX) or `renameat2` (most Linux systems) to allow forbidding renaming to an already existing target in an 'atomic' way. NOTE: While this commit aims at avoiding the TOC/TOU problem as much as possible by using available system's primitives for most common cases, there are some situations where race conditions (filesystem changes between checks on FS state, and actual rename operation) remain possible. Pull Request: https://projects.blender.org/blender/blender/pulls/115096
31 lines
780 B
C++
31 lines
780 B
C++
/* SPDX-FileCopyrightText: 2012 Blender Authors
|
|
*
|
|
* SPDX-License-Identifier: GPL-2.0-or-later */
|
|
|
|
/** \file
|
|
* \ingroup intern_utf_conv
|
|
*/
|
|
|
|
#ifndef __UTF_WINFUNC_H__
|
|
#define __UTF_WINFUNC_H__
|
|
|
|
#ifndef WIN32
|
|
# error "This file can only compile on windows"
|
|
#endif
|
|
|
|
#include <stdio.h>
|
|
|
|
FILE *ufopen(const char *filename, const char *mode);
|
|
int uopen(const char *filename, int oflag, int pmode);
|
|
int uaccess(const char *filename, int mode);
|
|
int urename(const char *oldname, const char *newname, const bool do_replace);
|
|
|
|
char *u_alloc_getenv(const char *varname);
|
|
void u_free_getenv(char *val);
|
|
|
|
int uput_getenv(const char *varname, char *value, size_t buffsize);
|
|
int uputenv(const char *name, const char *value);
|
|
|
|
int umkdir(const char *pathname);
|
|
|
|
#endif /* __UTF_WINFUNC_H__ */
|