| 339 | } |
| 340 | |
| 341 | void CPartFile::CreatePartFile(bool isImporting) |
| 342 | { |
| 343 | // use lowest free partfilenumber for free file (InterCeptor) |
| 344 | int i = 0; |
| 345 | do { |
| 346 | ++i; |
| 347 | m_partmetfilename = CPath(CFormat("%03i.part.met") % i); |
| 348 | m_fullname = thePrefs::GetTempDir().JoinPaths(m_partmetfilename); |
| 349 | } while (m_fullname.FileExists()); |
| 350 | |
| 351 | m_CorruptionBlackBox->SetPartFileInfo(GetFileName().GetPrintable(), m_partmetfilename.RemoveAllExt().GetPrintable()); |
| 352 | |
| 353 | m_gaplist.Init(GetFileSize(), true); // Init empty |
| 354 | |
| 355 | m_PartPath = m_fullname.RemoveExt(); |
| 356 | bool fileCreated; |
| 357 | if (thePrefs::GetAllocFullFile() || !thePrefs::CreateFilesSparse()) { |
| 358 | fileCreated = m_hpartfile.Create(m_PartPath, true); |
| 359 | m_hpartfile.Close(); |
| 360 | } else { |
| 361 | fileCreated = PlatformSpecific::CreateSparseFile(m_PartPath, GetFileSize()); |
| 362 | } |
| 363 | if (!fileCreated) { |
| 364 | AddLogLineN(_("ERROR: Failed to create partfile")); |
| 365 | SetStatus(PS_ERROR); |
| 366 | } |
| 367 | |
| 368 | SetFilePath(thePrefs::GetTempDir()); |
| 369 | |
| 370 | if (!isImporting && thePrefs::GetAllocFullFile()) { |
| 371 | SetStatus(PS_ALLOCATING); |
| 372 | CThreadScheduler::AddTask(new CAllocateFileTask(this, thePrefs::AddNewFilesPaused())); |
| 373 | } else { |
| 374 | AllocationFinished(); |
| 375 | } |
| 376 | |
| 377 | m_hashsetneeded = (GetED2KPartHashCount() > 0); |
| 378 | |
| 379 | SavePartFile(true); |
| 380 | SetActive(theApp->IsConnected()); |
| 381 | } |
| 382 | |
| 383 | |
| 384 | uint8 CPartFile::LoadPartFile(const CPath& in_directory, const CPath& filename, bool from_backup, bool getsizeonly) |
no test coverage detected