Toggle navigation
Ocean Color Science Software
Jump to content
ocssw
V2022
web
ocssw
ocssw_src
src
l1cgen
ncfileinfo.cpp
Go to the documentation of this file.
1
#include <iostream>
2
#include <fstream>
3
#include <string>
4
#include <vector>
5
#include <netcdf>
6
7
using namespace
std;
8
using namespace
netCDF;
9
using namespace
netCDF::exceptions;
10
11
bool
is_NCDF
(
const
string
filepath
) {
12
try
{
13
NcFile nc(
filepath
, NcFile::read);
14
nc.close();
15
return
true
;
16
}
catch
(NcException
const
& e) {
17
return
false
;
18
}
19
}
20
21
vector<string>
ncfiles
(
const
char
*
filepath
) {
22
/* Returns a string vector of NetCDF filenames, listed in filepath.
23
If filepath is a NetCDF file, vector will contain only that file.
24
*/
25
vector<string>
filelist
;
26
//cout<<"inside ncfiles..."<<filepath<<endl;
27
if
(
is_NCDF
(
filepath
)) {
28
filelist
.push_back(
filepath
);
29
// cout<<"if..."<<filepath<<endl;
30
}
else
{
31
// cout<<"else..."<<filepath<<endl;
32
string
line
;
33
ifstream
infile
(
filepath
);
34
if
(
infile
) {
35
while
(getline(
infile
,
line
)) {
36
if
(
is_NCDF
(
line
))
37
filelist
.push_back(
line
);
38
}
39
infile
.close();
40
}
41
}
42
43
return
(
filelist
);
44
}
ncfiles
vector< string > ncfiles(const char *filepath)
Definition:
ncfileinfo.cpp:21
is_NCDF
bool is_NCDF(const string filepath)
Definition:
ncfileinfo.cpp:11
check_polarwander.infile
infile
Definition:
check_polarwander.py:71
fix_mac_rpath.line
line
Definition:
fix_mac_rpath.py:55
color_dtdb.filepath
string filepath
Definition:
color_dtdb.py:207
obdaac_download.filelist
list filelist
Definition:
obdaac_download.py:87