You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
56 lines
1.5 KiB
Plaintext
56 lines
1.5 KiB
Plaintext
package file_dialog
|
|
|
|
// Save file dialog function
|
|
show_save_file_dialog :: proc(
|
|
title: string = "Save File",
|
|
filters: []File_Filter = {},
|
|
default_filename: string = "",
|
|
default_directory: string = ""
|
|
) -> Result {
|
|
when ODIN_OS == .Windows {
|
|
return show_save_file_dialog_windows(title, filters, default_filename, default_directory)
|
|
} else when ODIN_OS == .Linux {
|
|
return show_save_file_dialog_linux(title, filters, default_filename, default_directory)
|
|
} else {
|
|
return {
|
|
success = false,
|
|
error_message = "Unsupported platform",
|
|
}
|
|
}
|
|
}
|
|
|
|
// Main cross-platform function
|
|
show_open_file_dialog :: proc(
|
|
title: string = "Open File",
|
|
filters: []File_Filter = {},
|
|
allow_multiple: bool = false
|
|
) -> Result {
|
|
when ODIN_OS == .Windows {
|
|
return show_open_file_dialog_windows(title, filters, allow_multiple)
|
|
} else when ODIN_OS == .Linux {
|
|
return show_open_file_dialog_linux(title, filters, allow_multiple)
|
|
} else {
|
|
return {
|
|
success = false,
|
|
error_message = "Unsupported platform",
|
|
}
|
|
}
|
|
}
|
|
|
|
// Convenience function to clean up results
|
|
destroy_result :: proc(result: ^Result) {
|
|
if result.file_path != "" {
|
|
delete(result.file_path)
|
|
}
|
|
if len(result.file_paths) > 0 {
|
|
for path in result.file_paths {
|
|
delete(path)
|
|
}
|
|
delete(result.file_paths)
|
|
}
|
|
if result.error_message != "" {
|
|
delete(result.error_message)
|
|
}
|
|
}
|
|
|