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