From f72cd54eac7515519ebc14b1b0b0b96758c065d8 Mon Sep 17 00:00:00 2001 From: RH Date: Thu, 3 Jun 2021 04:34:02 +1000 Subject: [PATCH] Fix to allow the correct saving of images on iOS when using a virtual file system (#369) * Fix to allow the correct saving of images on iOS when using a virtual file system * Add missing import for FileUtils --- cocos/platform/ios/CCImage-ios.mm | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/cocos/platform/ios/CCImage-ios.mm b/cocos/platform/ios/CCImage-ios.mm index 453f444479..7af8f39c1d 100644 --- a/cocos/platform/ios/CCImage-ios.mm +++ b/cocos/platform/ios/CCImage-ios.mm @@ -25,6 +25,7 @@ THE SOFTWARE. ****************************************************************************/ #import "platform/CCImage.h" #import "platform/CCCommon.h" +#import "platform/CCFileUtils.h" #import #import @@ -111,7 +112,9 @@ bool cocos2d::Image::saveToFile(const std::string& filename, bool isToRGB) } else { data = UIImageJPEGRepresentation(image, 1.0f); } - [data writeToFile:[NSString stringWithUTF8String:filename.c_str()] atomically:YES]; + + auto outStream = FileUtils::getInstance()->openFileStream(filename, FileStream::Mode::WRITE); + outStream->write(data.bytes, data.length); } [image release];