tomwalters@296: // Copyright 2010, Thomas Walters tomwalters@296: // tomwalters@296: // AIM-C: A C++ implementation of the Auditory Image Model tomwalters@296: // http://www.acousticscale.org/AIMC tomwalters@296: // tomwalters@318: // Licensed under the Apache License, Version 2.0 (the "License"); tomwalters@318: // you may not use this file except in compliance with the License. tomwalters@318: // You may obtain a copy of the License at tomwalters@296: // tomwalters@318: // http://www.apache.org/licenses/LICENSE-2.0 tomwalters@296: // tomwalters@318: // Unless required by applicable law or agreed to in writing, software tomwalters@318: // distributed under the License is distributed on an "AS IS" BASIS, tomwalters@318: // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. tomwalters@318: // See the License for the specific language governing permissions and tomwalters@318: // limitations under the License. tomwalters@296: tomwalters@296: /*! tomwalters@296: * \file tomwalters@296: * \brief Convert a file containing a list of pairs of tab-separated tomwalters@296: * items, one per line, and convert it to a vector > tomwalters@296: * tomwalters@296: * \author Thomas Walters tomwalters@296: * \date created 2010/02/23 tomwalters@296: * \version \$Id$ tomwalters@296: */ tomwalters@296: tomwalters@298: #include tomwalters@296: #include "Support/FileList.h" tomwalters@296: tomwalters@296: namespace aimc { tomwalters@296: vector > FileList::Load(string filename) { tomwalters@296: FILE* file_handle; tomwalters@296: vector > file_list; tomwalters@296: if ((file_handle = fopen(filename.c_str(), "r"))==NULL) { tomwalters@398: LOG_ERROR(_T("Couldn't open file '%s' for reading."), filename.c_str()); tomwalters@398: return file_list; tomwalters@398: } tomwalters@296: tomwalters@296: string out_1; tomwalters@296: string out_2; tomwalters@296: char n1[PATH_MAX]; tomwalters@296: char n2[PATH_MAX]; tomwalters@398: while (fscanf(file_handle, "%s\t%s", n1, n2) != EOF) { tomwalters@296: out_1 = n1; tomwalters@296: out_2 = n2; tomwalters@296: file_list.push_back(make_pair(out_1, out_2)); tomwalters@398: } tomwalters@296: fclose(file_handle); tomwalters@296: return file_list; tomwalters@296: } tomwalters@296: } // namespace aimc