Blender V5.3
fileops_apple.mm
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: 2024 Blender Authors
2 *
3 * SPDX-License-Identifier: GPL-2.0-or-later */
4
10
11#import <Foundation/Foundation.h>
12
13#include "BLI_fileops.hh"
14#include "BLI_path_utils.hh"
15
16namespace blender {
17
18int BLI_delete_soft(const char *filepath, const char **r_error_message)
19{
20 BLI_assert(!BLI_path_is_rel(filepath));
21
22 @autoreleasepool {
23 NSString *pathString = [NSString stringWithUTF8String:filepath];
24 NSFileManager *fileManager = [NSFileManager defaultManager];
25 NSURL *targetURL = [NSURL fileURLWithPath:pathString];
26
27 BOOL deleteSuccessful = [fileManager trashItemAtURL:targetURL resultingItemURL:nil error:nil];
28
29 if (!deleteSuccessful) {
30 *r_error_message = "The Cocoa API call to delete file or directory failed";
31 }
32
33 return deleteSuccessful ? 0 : -1;
34 }
35}
36
37} // namespace blender
File and directory operations.
BMesh Iterators.
BLI_assert(slot->slot_subtype.map==BMO_OP_SLOT_SUBTYPE_MAP_FLT)
int BLI_delete_soft(const char *filepath, const char **r_error_message) ATTR_NONNULL()
bool BLI_path_is_rel(const char *path) ATTR_NONNULL(1) ATTR_WARN_UNUSED_RESULT