annotate src/Support/FileList.cc @ 169:78cbca1cf218

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