MCPcopy Create free account
hub / github.com/apple/coremltools / addItem

Method addItem

modelpackage/src/ModelPackage.cpp:409–424  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

407}
408
409std::string ModelPackageImpl::addItem(const std::filesystem::path& path, const std::string& name, const std::string& author, const std::string& description)
410{
411 if (findItem(name, author) != nullptr) {
412 throw std::runtime_error("The package already contains a file with name: " + name + " author: " + author);
413 }
414
415 auto filePath = getItemPath(name, author);
416 auto dstPath = m_packageDataDirPath / filePath;
417
418 create_directories(dstPath.parent_path());
419 std::filesystem::copy(path, dstPath);
420
421 auto identifier = generateIdentifier();
422 createItemInfoEntry(identifier, filePath.string(), name, author, description);
423 return identifier;
424}
425
426std::string ModelPackageImpl::setRootModel(const std::filesystem::path& path, const std::string& name, const std::string& author, const std::string& description)
427{

Calls 2

copyFunction · 0.50
stringMethod · 0.45