| 350 | } |
| 351 | |
| 352 | void copySomeFiles() |
| 353 | { |
| 354 | auto part = *Storage::findPartition(Storage::Partition::SubType::Data::fwfs); |
| 355 | if(!part) { |
| 356 | return; |
| 357 | } |
| 358 | auto fs = IFS::createFirmwareFilesystem(part); |
| 359 | if(fs == nullptr) { |
| 360 | return; |
| 361 | } |
| 362 | fs->mount(); |
| 363 | |
| 364 | IFS::Directory dir(fs); |
| 365 | if(!dir.open()) { |
| 366 | return; |
| 367 | } |
| 368 | |
| 369 | while(dir.next()) { |
| 370 | auto& stat = dir.stat(); |
| 371 | if(stat.isDir()) { |
| 372 | continue; |
| 373 | } |
| 374 | IFS::File src(fs); |
| 375 | auto filename = stat.name.c_str(); |
| 376 | if(src.open(filename)) { |
| 377 | File dst; |
| 378 | if(dst.open(filename, File::CreateNewAlways | File::WriteOnly)) { |
| 379 | auto len = |
| 380 | src.readContent([&dst](const char* buffer, size_t size) -> int { return dst.write(buffer, size); }); |
| 381 | (void)len; |
| 382 | debug_w("Wrote '%s', %d bytes", filename, len); |
| 383 | |
| 384 | // Copy metadata |
| 385 | auto callback = [&](IFS::AttributeEnum& e) -> bool { |
| 386 | if(!dst.setAttribute(e.tag, e.buffer, e.size)) { |
| 387 | m_printf(_F("setAttribute(%s) failed: %s"), toString(e.tag).c_str(), |
| 388 | dst.getLastErrorString().c_str()); |
| 389 | } |
| 390 | return true; |
| 391 | }; |
| 392 | char buffer[1024]; |
| 393 | src.enumAttributes(callback, buffer, sizeof(buffer)); |
| 394 | } else { |
| 395 | debug_w("%s", dst.getLastErrorString().c_str()); |
| 396 | } |
| 397 | } |
| 398 | } |
| 399 | } |
| 400 | |
| 401 | bool isVolumeEmpty() |
| 402 | { |