extension-file-save

Cross-platform file save dialog for OpenFL/hxcpp

To install, run:

haxelib install extension-file-save 0.3.8 

See using Haxelib in Haxelib documentation for more information.

README.md

extension-file-save

Build Haxelib License: MIT

A cross-platform OpenFL/Lime native extension for saving files via native OS file pickers. Supports desktop (direct path write) and mobile (copy-to-destination) workflows.

Platform Support

PlatformImplementation
macOSNSSavePanel (security-scoped URL)
WindowsLime FileDialog wrapper
LinuxLime FileDialog wrapper
iOSUIDocumentPickerViewController
AndroidACTION_CREATE_DOCUMENT Intent

Installation

haxelib dev extension-file-save path/to/extension-file-save

Add to project.xml:

<haxelib name="extension-file-save" />

API

Desktop — requestSavePath / releasePath

The user picks a save location; your code writes directly to that path. On macOS the extension holds a security-scoped bookmark until releasePath() is called.

// Ask the user where to save, then write directly to the returned path
FileSave.requestSavePath('animation.mp4', 'video/mp4', (path:String) -> {
    beginEncoding(path, () -> {
        FileSave.releasePath(); // Release security-scoped access (macOS sandbox)
    });
}, () -> {
    trace('User cancelled');
});

Mobile — saveFile

Copies an existing file to a user-chosen location via the native picker.

FileSave.saveFile('/tmp/output.mp4', 'animation.mp4', 'video/mp4', (success:Bool) -> {
    if (success) trace('Saved');
});

Building the Native Library

lime rebuild . <target> -release

Or directly via hxcpp:

haxelib run hxcpp project/Build.xml -D<platform> -DHXCPP_ARM64
Targetlime rebuildhxcpp flags
macOSlime rebuild . macos -release-Dmacos -DHXCPP_ARM64
iOSlime rebuild . ios -release-Diphoneos -DHXCPP_ARM64
AndroidBuilt automatically by Gradle

Windows and Linux use Lime's built-in FileDialog and do not require a native library build.

macOS Sandbox Note

requestSavePath calls NSSavePanel and retains a security-scoped URL for the chosen file. This keeps sandbox access open while your code writes to the path. Call releasePath() as soon as writing is complete to release the resource.

License

MIT

Contributors
AxGord
soccertutor
Version
0.3.8
Published
4 weeks ago
License
MIT

All libraries are free

Every month, more than a thousand developers use Haxelib to find, share, and reuse code — and assemble it in powerful new ways. Enjoy Haxe; It is great!

Explore Haxe

Haxe Manual

Haxe Code Cookbook

Haxe API documentation

You can try Haxe in the browser! try.haxe.org

Join us on GitHub!

Haxe is being developed on GitHub. Feel free to contribute or report issues to our projects.

Haxe on GitHub