bool CatalogImages::Impl::FileScan(Path path, int64 file_length, const CFileFind& find, int dir_visited, bool scanSubdirs) { if (break_) return false; bool generate_thumbnails= true; PhotoFactory::CreateFn fn= 0; int id= 0; if (!GetPhotoFactory().MatchPhotoType(path.GetExtension(), fn, id)) return true; const size_t size= scan_types_.size(); if (id >= size) { ASSERT(false); return true; } if (!scan_types_[id]) return true; files_.push_back(make_pair(path, cur_dir_)); // reserved_capacity_ keeps track of max amount of files in a given folder; real number // can be smaller when decoding fails and some images are not saved; cur_dir_->reserved_capacity_++; if (parentWnd_) ::PostMessage(parentWnd_, MESSAGE, files_.size(), DIR_SCANNING); return true; }
void CopyPhoto::Copy(const Path& file_path, const TCHAR* dest_folder, const TCHAR* rename_pattern) { DWORD start= ::GetTickCount(); CFile file(file_path.c_str(), CFile::modeRead | CFile::shareDenyWrite);// | CFile::osSequentialScan); const uint64 length= file.SeekToEnd(); if (length == 0) return; // do not create empty copies Progress(0, length); // call progress after opening file file.SeekToBegin(); auto_ptr<PhotoInfo> photo; PhotoFactory::CreateFn create= 0; int type_id= 0; if (GetPhotoFactory().MatchPhotoType(file_path.GetExtension(), create, type_id) && type_id != FT_CATALOG) photo.reset(create()); // if there is 'photo' object available try to decode EXIF block if (photo.get()) { // FileStream str; // VERIFY(str.Open(buffer)); ReadImage(photo.get(), file_path, length, 0); } // create destination name Path dest= CreateDestPath(file_path, length, photo.get()); // copy source file to the destination const size_t CHUNK= 0x10000; // 64 KB vector<uint8> buffer(CHUNK, 0); size_t block= static_cast<size_t>(min<uint64>(CHUNK, length)); if (file.Read(&buffer.front(), block) != block) throw 11111; }