71 string::size_type slash = pathname.rfind(
'/') + 1;
72 string directory = pathname.substr(0, slash);
73 string filename = pathname.substr(slash);
74 string basename = pathname.substr(slash, pathname.rfind(
'.') - slash);
76 DBG(cerr <<
"find ancillary file params: " << pathname <<
", " << ext
77 <<
", " << dir <<
", " << file << endl);
78 DBG(cerr <<
"find ancillary file comp: " << directory <<
", " << filename
79 <<
", " << basename << endl);
81 string dot_ext =
"." + ext;
83 string name = directory + basename + dot_ext;
84 if (access(name.c_str(), F_OK) == 0)
87 name = pathname + dot_ext;
88 if (access(name.c_str(), F_OK) == 0)
91 name = directory + ext;
92 if (access(name.c_str(), F_OK) == 0)
95 name = dir + basename + dot_ext;
96 if (access(name.c_str(), F_OK) == 0)
99 name = directory + file + dot_ext;
100 if (access(name.c_str(), F_OK) == 0)
103 name = dir + file + dot_ext;
104 if (access(name.c_str(), F_OK) == 0)
108 if (access(name.c_str(), F_OK) == 0)
140 string::size_type slash = name.find_last_of(
'/');
141 string dirname = name.substr(0, slash);
142 string filename = name.substr(slash + 1);
143 string rootname = filename.substr(0, filename.find_last_of(
'.'));
147 string::iterator rootname_iter = rootname.begin();
148 string::iterator rootname_end_iter = rootname.end();
149 if (isdigit(*rootname_iter)) {
150 while (rootname_iter != rootname_end_iter
151 && isdigit(*++rootname_iter))
156 string new_name = dirname;
157 new_name.append(
"/");
158 new_name.append(rootname_iter, rootname_end_iter);
159 new_name.append(ext);
160 DBG(cerr <<
"New Name (iter): " << new_name << endl);
161 if (access(new_name.c_str(), F_OK) == 0) {
166 string::reverse_iterator rootname_riter = rootname.rbegin();
167 string::reverse_iterator rootname_end_riter = rootname.rend();
168 if (isdigit(*rootname_riter)) {
169 while (rootname_riter != rootname_end_riter
170 && isdigit(*++rootname_riter))
172 string new_name = dirname;
173 new_name.append(
"/");
178 new_name.append(rootname_end_riter.base(), rootname_riter.base());
179 new_name.append(ext);
180 DBG(cerr <<
"New Name (riter): " << new_name << endl);
181 if (access(new_name.c_str(), F_OK) == 0) {
194 const string &pathname,
200 FILE *in = fopen( name.c_str(),
"r" ) ;
203 int res = fclose( in ) ;
205 DBG(cerr <<
"DODSFilter::read_ancillary_das - Failed to close file " << (
void *)in << endl) ;
211 const string &pathname,
217 FILE *in = fopen( name.c_str(),
"r" ) ;
220 int res = fclose( in ) ;
222 DBG(cerr <<
"DODSFilter::read_ancillary_das - Failed to close file " << (
void *)in << endl) ;
static string find_group_ancillary_file(const string &pathname, const string &ext)
static string find_ancillary_file(const string &pathname, const string &ext, const string &dir, const string &file)
Find a file with ancillary data.
static void read_ancillary_das(DAS &das, const string &pathname, const string &dir="", const string &file="")
void parse(string fname)
Parse a DDS from a file with the given name.
static void read_ancillary_dds(DDS &dds, const string &pathname, const string &dir="", const string &file="")
virtual void parse(string fname)
Reads a DAS from the named file.
Hold attribute data for a DAP2 dataset.