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@23: // This program is free software: you can redistribute it and/or modify tomwalters@23: // it under the terms of the GNU General Public License as published by tomwalters@23: // the Free Software Foundation, either version 3 of the License, or tomwalters@23: // (at your option) any later version. tomwalters@23: // tomwalters@23: // This program is distributed in the hope that it will be useful, tomwalters@23: // but WITHOUT ANY WARRANTY; without even the implied warranty of tomwalters@23: // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the tomwalters@23: // GNU General Public License for more details. tomwalters@23: // tomwalters@23: // You should have received a copy of the GNU General Public License tomwalters@23: // along with this program. If not, see . 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@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@23: LOG_ERROR(_T("Couldn't open file '%s' for reading."), filename.c_str()); tomwalters@23: return file_list; tomwalters@23: } 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@23: 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@23: } tomwalters@23: fclose(file_handle); tomwalters@23: return file_list; tomwalters@23: } tomwalters@23: } // namespace aimc