Skip to content

Commit 5d5874e

Browse files
author
Martin D. Weinberg
committed
Added directory file listing to Gadget and Tipsy readers
1 parent d2492be commit 5d5874e

1 file changed

Lines changed: 39 additions & 2 deletions

File tree

exputil/ParticleReader.cc

Lines changed: 39 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,18 @@ namespace PR {
4040
_files = files; // Copy file list (bunch)
4141
_verbose = verbose;
4242

43+
// Do we have a directory of snapshot files?
44+
//
45+
if (_files.size()==1) {
46+
std::vector<std::string> fscan = scanDirectory(_files[0]);
47+
48+
// Did we find files?
49+
//
50+
if (fscan.size() != 0) {
51+
_files = fscan;
52+
}
53+
}
54+
4355
ptype = 1; // Default is halo particles
4456

4557
getNumbers(); // Get the number of particles in all
@@ -310,6 +322,18 @@ namespace PR {
310322
_files = files;
311323
_verbose = verbose;
312324

325+
// Do we have a directory of snapshot files?
326+
//
327+
if (_files.size()==1) {
328+
std::vector<std::string> fscan = scanDirectory(_files[0]);
329+
330+
// Did we find files?
331+
//
332+
if (fscan.size() != 0) {
333+
_files = fscan;
334+
}
335+
}
336+
313337
ptype = 1; // Default is halo particles
314338

315339
totalCount = 0; // Initialization of particles read
@@ -318,7 +342,7 @@ namespace PR {
318342
curfile = _files.begin();
319343

320344
if (not nextFile()) {
321-
std::cerr << "GadgetNative: no files found" << std::endl;
345+
std::cerr << "GadgetHDF5: no files found" << std::endl;
322346
}
323347
}
324348

@@ -2115,8 +2139,21 @@ namespace PR {
21152139
Tipsy::Tipsy(const std::vector<std::string>& filelist, TipsyType Type,
21162140
bool verbose)
21172141
{
2118-
ttype = Type;
21192142
files = filelist;
2143+
2144+
// Do we have a directory of snapshot files?
2145+
//
2146+
if (files.size()==1) {
2147+
std::vector<std::string> fscan = scanDirectory(files[0]);
2148+
2149+
// Did we find files?
2150+
//
2151+
if (fscan.size() != 0) {
2152+
files = fscan;
2153+
}
2154+
}
2155+
2156+
ttype = Type;
21202157
getNumbers();
21212158
curfile = files.begin();
21222159
if (not nextFile()) {

0 commit comments

Comments
 (0)