annotate trunk/src/Support/FileList.cc @ 706:f8e90b5d85fd tip

Delete CARFAC code from this repository. It has been moved to https://github.com/google/carfac Please email me with your github username to get access. I've also created a new mailing list to discuss CARFAC development: https://groups.google.com/forum/#!forum/carfac-dev
author ronw@google.com
date Thu, 18 Jul 2013 20:56:51 +0000
parents 3ee03a6b95a0
children
rev   line source
tomwalters@296 1 // Copyright 2010, Thomas Walters
tomwalters@296 2 //
tomwalters@296 3 // AIM-C: A C++ implementation of the Auditory Image Model
tomwalters@296 4 // http://www.acousticscale.org/AIMC
tomwalters@296 5 //
tomwalters@318 6 // Licensed under the Apache License, Version 2.0 (the "License");
tomwalters@318 7 // you may not use this file except in compliance with the License.
tomwalters@318 8 // You may obtain a copy of the License at
tomwalters@296 9 //
tomwalters@318 10 // http://www.apache.org/licenses/LICENSE-2.0
tomwalters@296 11 //
tomwalters@318 12 // Unless required by applicable law or agreed to in writing, software
tomwalters@318 13 // distributed under the License is distributed on an "AS IS" BASIS,
tomwalters@318 14 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
tomwalters@318 15 // See the License for the specific language governing permissions and
tomwalters@318 16 // limitations under the License.
tomwalters@296 17
tomwalters@296 18 /*!
tomwalters@296 19 * \file
tomwalters@296 20 * \brief Convert a file containing a list of pairs of tab-separated
tomwalters@296 21 * items, one per line, and convert it to a vector<pair<string, string> >
tomwalters@296 22 *
tomwalters@296 23 * \author Thomas Walters <tom@acousticscale.org>
tomwalters@296 24 * \date created 2010/02/23
tomwalters@296 25 * \version \$Id$
tomwalters@296 26 */
tomwalters@296 27
tomwalters@298 28 #include <limits.h>
tomwalters@296 29 #include "Support/FileList.h"
tomwalters@296 30
tomwalters@296 31 namespace aimc {
tomwalters@296 32 vector<pair<string, string> > FileList::Load(string filename) {
tomwalters@296 33 FILE* file_handle;
tomwalters@296 34 vector<pair<string, string> > file_list;
tomwalters@296 35 if ((file_handle = fopen(filename.c_str(), "r"))==NULL) {
tomwalters@398 36 LOG_ERROR(_T("Couldn't open file '%s' for reading."), filename.c_str());
tomwalters@398 37 return file_list;
tomwalters@398 38 }
tomwalters@296 39
tomwalters@296 40 string out_1;
tomwalters@296 41 string out_2;
tomwalters@296 42 char n1[PATH_MAX];
tomwalters@296 43 char n2[PATH_MAX];
tomwalters@398 44 while (fscanf(file_handle, "%s\t%s", n1, n2) != EOF) {
tomwalters@296 45 out_1 = n1;
tomwalters@296 46 out_2 = n2;
tomwalters@296 47 file_list.push_back(make_pair(out_1, out_2));
tomwalters@398 48 }
tomwalters@296 49 fclose(file_handle);
tomwalters@296 50 return file_list;
tomwalters@296 51 }
tomwalters@296 52 } // namespace aimc