From d56c38525cd50cf7fb8aec65f4e79d6e9ecdfc58 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Wed, 24 May 2023 16:29:22 +1000 Subject: [PATCH] Fix flipped check for file-copy failure on OBJ export The check for file-copy success was flipped, document the return value. Relocate move next to copy as they're related functions. --- source/blender/blenlib/BLI_fileops.h | 15 ++++++++++----- source/blender/io/common/intern/path_util.cc | 2 +- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/source/blender/blenlib/BLI_fileops.h b/source/blender/blenlib/BLI_fileops.h index fe8b9f3ecc7..1605b3386fc 100644 --- a/source/blender/blenlib/BLI_fileops.h +++ b/source/blender/blenlib/BLI_fileops.h @@ -38,7 +38,17 @@ extern "C" { * (most likely doesn't exist or no access). */ int BLI_exists(const char *path) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(); + +/** + * \return 0 on success. + */ int BLI_copy(const char *path_src, const char *path_dst) ATTR_NONNULL(); +/** + * When `path_src` points to a directory, moves all its contents into `path_dst`, + * else rename `path_src` itself to `path_dst`. + * \return 0 on success. + */ +int BLI_path_move(const char *path_src, const char *path_dst) ATTR_NONNULL(); /** * Rename a file or directory. @@ -76,11 +86,6 @@ int BLI_delete(const char *path, bool dir, bool recursive) ATTR_NONNULL(); * \return zero on success (matching 'remove' behavior). */ int BLI_delete_soft(const char *filepath, const char **error_message) ATTR_NONNULL(); -/** - * When `path_src` points to a directory, moves all its contents into `path_dst`, - * else rename `path_src` itself to `path_dst`. - */ -int BLI_path_move(const char *path_src, const char *path_dst) ATTR_NONNULL(); #if 0 /* Unused */ int BLI_create_symlink(const char *path, const char *path_dst) ATTR_NONNULL(); #endif diff --git a/source/blender/io/common/intern/path_util.cc b/source/blender/io/common/intern/path_util.cc index da5c21ae054..1dd9c25c17b 100644 --- a/source/blender/io/common/intern/path_util.cc +++ b/source/blender/io/common/intern/path_util.cc @@ -71,7 +71,7 @@ void path_reference_copy(const Set> ©_se fprintf(stderr, "Can't make directory for '%s', not copying\n", dst); continue; } - if (!BLI_copy(src, dst)) { + if (BLI_copy(src, dst) != 0) { fprintf(stderr, "Can't copy '%s' to '%s'\n", src, dst); continue; }