use ustring more; handle embedding of "paired" files as per mantis #1362
[ardour.git] / libs / ardour / import.cc
index 0d0a73c7a0f9a8b5687a0c507f3dbdc611266433..015b34c1b46aa0aa303a3d70d73706081c2f04aa 100644 (file)
@@ -73,22 +73,22 @@ Session::import_audiofile (import_status& status)
        
        status.new_regions.clear ();
 
-       if ((in = sf_open (status.pathname.c_str(), SFM_READ, &info)) == 0) {
-               error << string_compose(_("Import: cannot open input sound file \"%1\""), status.pathname) << endmsg;
+       if ((in = sf_open (status.paths.front().c_str(), SFM_READ, &info)) == 0) {
+               error << string_compose(_("Import: cannot open input sound file \"%1\""), status.paths.front()) << endmsg;
                return -1;
        } else {
                if ((uint32_t) info.samplerate != frame_rate()) {
                        sf_close(in);
                        status.doing_what = _("resampling audio");
                        // resample to session frame_rate
-                       if (sample_rate_convert(status, status.pathname, tmp_convert_file)) {
+                       if (sample_rate_convert(status, status.paths.front(), tmp_convert_file)) {
                                if ((in = sf_open (tmp_convert_file.c_str(), SFM_READ, &info)) == 0) {
                                        error << string_compose(_("Import: cannot open converted sound file \"%1\""), tmp_convert_file) << endmsg;
                                        return -1;
                                }
                        } else if (!status.cancel){
                                // error
-                               error << string_compose(_("Import: error while resampling sound file \"%1\""), status.pathname) << endmsg;
+                               error << string_compose(_("Import: error while resampling sound file \"%1\""), status.paths.front()) << endmsg;
                                return -1;
                        } else {
                                // canceled
@@ -102,7 +102,7 @@ Session::import_audiofile (import_status& status)
        }
 
        sounds_dir = discover_best_sound_dir ();
-       basepath = PBD::basename_nosuffix (status.pathname);
+       basepath = PBD::basename_nosuffix (status.paths.front());
 
        for (n = 0; n < info.channels; ++n) {
 
@@ -215,7 +215,7 @@ Session::import_audiofile (import_status& status)
                        sources.push_back(newfiles[n]);
                }
 
-               boost::shared_ptr<AudioRegion> r (boost::dynamic_pointer_cast<AudioRegion> (RegionFactory::create (sources, 0, newfiles[0]->length(), region_name_from_path (Glib::path_get_basename (basepath)),
+               boost::shared_ptr<AudioRegion> r (boost::dynamic_pointer_cast<AudioRegion> (RegionFactory::create (sources, 0, newfiles[0]->length(), region_name_from_path (basepath, true),
                                                                                                                   0, AudioRegion::Flag (AudioRegion::DefaultFlags | AudioRegion::WholeFile))));
                
                status.new_regions.push_back (r);
@@ -233,7 +233,7 @@ Session::import_audiofile (import_status& status)
                
                        status.new_regions.push_back (boost::dynamic_pointer_cast<AudioRegion> 
                                                      (RegionFactory::create (boost::static_pointer_cast<Source> (newfiles[n]), 0, newfiles[n]->length(), 
-                                                                             region_name_from_path (Glib::path_get_basename (newfiles[n]->name())),
+                                                                             region_name_from_path (newfiles[n]->name(), true),
                                                                              0, AudioRegion::Flag (AudioRegion::DefaultFlags | AudioRegion::WholeFile | AudioRegion::Import))));
                }
        }