74 string::size_type slash = pathname.rfind(
'/') + 1;
75 string directory = pathname.substr(0, slash);
76 string filename = pathname.substr(slash);
77 string basename = pathname.substr(slash, pathname.rfind(
'.') - slash);
79 DBG(cerr <<
"find ancillary file params: " << pathname <<
", " << ext
80 <<
", " << dir <<
", " << file << endl);
81 DBG(cerr <<
"find ancillary file comp: " << directory <<
", " << filename
82 <<
", " << basename << endl);
84 string dot_ext =
"." + ext;
86 string name = directory + basename + dot_ext;
87 if (access(name.c_str(), F_OK) == 0)
90 name = pathname + dot_ext;
91 if (access(name.c_str(), F_OK) == 0)
94 name = directory + ext;
95 if (access(name.c_str(), F_OK) == 0)
98 name = dir + basename + dot_ext;
99 if (access(name.c_str(), F_OK) == 0)
102 name = directory + file + dot_ext;
103 if (access(name.c_str(), F_OK) == 0)
106 name = dir + file + dot_ext;
107 if (access(name.c_str(), F_OK) == 0)
111 if (access(name.c_str(), F_OK) == 0)
143 string::size_type slash = name.find_last_of(
'/');
144 string dirname = name.substr(0, slash);
145 string filename = name.substr(slash + 1);
146 string rootname = filename.substr(0, filename.find_last_of(
'.'));
150 string::iterator rootname_iter = rootname.begin();
151 string::iterator rootname_end_iter = rootname.end();
152 if (isdigit(*rootname_iter)) {
153 while (rootname_iter != rootname_end_iter
154 && isdigit(*++rootname_iter))
159 string new_name = dirname;
160 new_name.append(
"/");
161 new_name.append(rootname_iter, rootname_end_iter);
162 new_name.append(ext);
163 DBG(cerr <<
"New Name (iter): " << new_name << endl);
164 if (access(new_name.c_str(), F_OK) == 0) {
169 string::reverse_iterator rootname_riter = rootname.rbegin();
170 string::reverse_iterator rootname_end_riter = rootname.rend();
171 if (isdigit(*rootname_riter)) {
172 while (rootname_riter != rootname_end_riter
173 && isdigit(*++rootname_riter))
175 string new_name = dirname;
176 new_name.append(
"/");
181 new_name.append(rootname_end_riter.base(), rootname_riter.base());
182 new_name.append(ext);
183 DBG(cerr <<
"New Name (riter): " << new_name << endl);
184 if (access(new_name.c_str(), F_OK) == 0) {
196Ancillary::read_ancillary_das(
DAS &das,
197 const string &pathname,
203 DBG(cerr <<
"In Ancillary::read_ancillary_dds: name:" << name << endl);
205 FILE *in = fopen( name.c_str(),
"r" ) ;
213Ancillary::read_ancillary_dds( DDS &dds,
214 const string &pathname,
220 DBG(cerr <<
"In Ancillary::read_ancillary_dds: name:" << name << endl);
222 FILE *in = fopen( name.c_str(),
"r" ) ;
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.
Hold attribute data for a DAP2 dataset.
virtual void parse(string fname)
Reads a DAS from the named file.
top level DAP object to house generic methods