Toggle navigation
Ocean Color Science Software
Jump to content
ocssw
V2022
web
ocssw
ocssw_src
src
l2bin
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
27
if
(
is_NCDF
(
filepath
)) {
28
filelist
.push_back(
filepath
);
29
}
else
{
30
string
line
;
31
ifstream
infile
(
filepath
);
32
if
(
infile
) {
33
while
(getline(
infile
,
line
)) {
34
if
(
is_NCDF
(
line
))
35
filelist
.push_back(
line
);
36
}
37
infile
.close();
38
}
39
}
40
41
return
(
filelist
);
42
}
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