| 349 | |
| 350 | |
| 351 | void TIndexKernel::createFile() |
| 352 | { |
| 353 | if (!m_usestdin && m_listfile.empty()) |
| 354 | m_files = Utils::glob(m_filespec); |
| 355 | else if (m_listfile.size()) |
| 356 | m_files = readFileList(m_listfile); |
| 357 | else |
| 358 | m_files = readSTDIN(); |
| 359 | |
| 360 | if (m_files.empty()) |
| 361 | { |
| 362 | std::ostringstream out; |
| 363 | out << "Couldn't find files to index: " << m_filespec << "."; |
| 364 | throw pdal_error(out.str()); |
| 365 | } |
| 366 | |
| 367 | //ABELL - Remove CPLGetBasename use. |
| 368 | const std::string filename = m_files.front(); |
| 369 | if (m_layerName.empty()) |
| 370 | m_layerName = CPLGetBasename(filename.c_str()); |
| 371 | |
| 372 | // Open or create the dataset. |
| 373 | if (!openDataset(m_idxFilename)) |
| 374 | if (!createDataset(m_idxFilename)) |
| 375 | { |
| 376 | std::ostringstream out; |
| 377 | out << "Couldn't open or create index dataset file '" << |
| 378 | m_idxFilename << "'."; |
| 379 | throw pdal_error(out.str()); |
| 380 | } |
| 381 | |
| 382 | // Open or create a layer |
| 383 | if (!openLayer(m_layerName)) |
| 384 | if (!createLayer(m_layerName)) |
| 385 | { |
| 386 | std::ostringstream out; |
| 387 | out << "Couldn't open or create layer '" << m_layerName << |
| 388 | "' in output file '" << m_idxFilename << "'."; |
| 389 | throw pdal_error(out.str()); |
| 390 | } |
| 391 | |
| 392 | std::vector<FileInfo> infos; |
| 393 | for (auto f : m_files) |
| 394 | { |
| 395 | FileInfo info; |
| 396 | info.m_filename = f; |
| 397 | info.m_isRemote = Utils::isRemote(f); |
| 398 | if (!info.m_isRemote) |
| 399 | FileUtils::fileTimes(info.m_filename, &info.m_ctime, &info.m_mtime); |
| 400 | infos.push_back(info); |
| 401 | } |
| 402 | |
| 403 | ThreadPool pool(m_threads); |
| 404 | |
| 405 | for (auto &info : infos) |
| 406 | { |
| 407 | pool.add([this, &info]() |
| 408 | { |
nothing calls this directly
no test coverage detected