NASA Logo
Ocean Color Science Software

ocssw V2022
readFileList.cpp
Go to the documentation of this file.
1 #include <genutils.h>
2 #include <fstream>
3 #include <algorithm>
4 #include <vector>
5 #include <cctype>
6 #include <netcdf>
7 using namespace netCDF;
8 
9 std::vector<std::string> readFileList(std::string fileName) {
10 
11  //Declare vector
12  std::vector<std::string> fileList;
13 
14  //Read file
15  std::ifstream file(fileName);
16 
17  if (!file) {
18  std::cerr << "Error: The file" << fileName << "could not be read." << std::endl;
19  exit(EXIT_FAILURE);
20  }
21 
22  char buffer[1024];
23  file.read(buffer, sizeof(buffer));
24 
25  for (int i=0; i<file.gcount(); i++) {
26 
27  //If file is not ASCII
28  if (!(isprint(buffer[i]) || isspace(buffer[i]))) {
29  fileList.push_back(fileName);
30  return fileList;
31  }
32  }
33 
34  // reset file
35  file.close();
36  file.open(fileName);
37 
38  //Check that each file listed in ifile exists
39  if (file.is_open()) {
41 
42  while (std::getline(file, line)) {
43 
44  //remove comment after # sign
45  size_t pos = line.find("#");
46  if (pos != std::string::npos)
47  line.erase(pos, std::string::npos);
48 
49  //remove any whitespace
50  line.erase(std::remove_if(line.begin(), line.end(), ::isspace),line.end());
51 
52  // ignore empty line
53  if (line.empty())
54  continue;
55 
56  //check if each file in ifile exists
57  std::ifstream file_exists(line);
58  if (file_exists.good())
59  fileList.push_back(line);
60  else {
61  std::cerr << "Error: The file" << line << "could not be found." << std::endl;
62  exit(EXIT_FAILURE);
63  }
64 
65  }
66  file.close();
67  }
68  return fileList;
69 }
float32 * pos
Definition: l1_czcs_hdf.c:35
@ string
no change in intended resolving MODur00064 Corrected handling of bad ephemeris attitude resolving resolving GSFcd00179 Corrected handling of fill values for[Sensor|Solar][Zenith|Azimuth] resolving MODxl01751 Changed to validate LUT version against a value retrieved from the resolving MODxl02056 Changed to calculate Solar Diffuser angles without adjustment for estimated post launch changes in the MODIS orientation relative to incidentally resolving defects MODxl01766 Also resolves MODxl01947 Changed to ignore fill values in SCI_ABNORM and SCI_STATE rather than treating them as resolving MODxl01780 Changed to use spacecraft ancillary data to recognise when the mirror encoder data is being set by side A or side B and to change calculations accordingly This removes the need for seperate LUTs for Side A and Side B data it makes the new LUTs incompatible with older versions of the and vice versa Also resolves MODxl01685 A more robust GRing algorithm is being which will create a non default GRing anytime there s even a single geolocated pixel in a granule Removed obsolete messages from seed file
Definition: HISTORY.txt:413
#define isspace(c)
std::vector< std::string > readFileList(std::string fileName)
Definition: readFileList.cpp:9
int i
Definition: decode_rs.h:71