From 53c2e47225f67b52d1c15df4814badaef50bcc3e Mon Sep 17 00:00:00 2001 From: Paul Davis Date: Wed, 29 Oct 2008 16:03:00 +0000 Subject: [PATCH] add missing .extensions to export files if not present, based on filetype selected (should probably do the opposite at some point, or at least point out the mismatch) git-svn-id: svn://localhost/ardour2/branches/2.0-ongoing@4029 d708f5d6-7413-0410-9779-e7cbd77b26cf --- gtk2_ardour/export_dialog.cc | 30 +++++++++++++++++++++++++++++- 1 file changed, 29 insertions(+), 1 deletion(-) diff --git a/gtk2_ardour/export_dialog.cc b/gtk2_ardour/export_dialog.cc index 5d46b06a07..e7c297e6ee 100644 --- a/gtk2_ardour/export_dialog.cc +++ b/gtk2_ardour/export_dialog.cc @@ -947,6 +947,34 @@ ExportDialog::do_export () msg.run (); return; } + + /* maybe add suffix */ + + int file_format = sndfile_header_format_from_string (header_format_combo.get_active_text ()); + + if ((file_format & SF_FORMAT_TYPEMASK) == SF_FORMAT_WAV) { + if (filepath.find (".wav") != filepath.length() - 4) { + filepath += ".wav"; + } + } else if ((file_format & SF_FORMAT_TYPEMASK) == SF_FORMAT_AIFF) { + if (filepath.find (".aiff") != filepath.length() - 5) { + filepath += ".aiff"; + } + } else if ((file_format & SF_FORMAT_TYPEMASK) == SF_FORMAT_W64) { + if (filepath.find (".w64") != filepath.length() - 5) { + filepath += ".w64"; + } + } else if ((file_format & SF_FORMAT_TYPEMASK) == SF_FORMAT_FLAC) { + if (filepath.find (".flac") != filepath.length() - 5) { + filepath += ".flac"; + } + } else if ((file_format & SF_FORMAT_TYPEMASK) == SF_FORMAT_CAF) { + if (filepath.find (".caf") != filepath.length() - 4) { + filepath += ".caf"; + } + } + + /* others ? */ if(!is_filepath_valid(filepath)){ return; @@ -1245,7 +1273,7 @@ ExportDialog::initSpec(string &filepath) spec.format |= sndfile_header_format_from_string (header_format_combo.get_active_text ()); if (!Profile->get_sae()) { - if ((spec.format & SF_FORMAT_WAV) == 0) { + if (((spec.format & SF_FORMAT_TYPEMASK) != SF_FORMAT_WAV)) { /* RIFF/WAV specifies endianess */ spec.format |= sndfile_endian_format_from_string (endian_format_combo.get_active_text ()); }