The following function counts the total number of objects in the indicated pool.
int count(const char *pathname) { REF(any) ref; int count; // Open a scan over the pool given by `pathname.' PoolScan scan(pathname); // Make sure the scan was successfully opened. if(scan != RCOK){ cout << "Error scanning pool " << pathname << ": " << rc << endl; return 0; } // Scan until end-of-scan or an error is encountered. for(count = 0; scan.next(ref) == RCOK; ++count); // Check for errors if(scan.rc().err_num() != OC_EndOfScan){ cout << "Error scanning pool " << pathname << ": " << rc << endl; return 0; } cout << path << " has " << count << " objects." << endl; // The destructor will close the scan object. return count; }