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