void CatalogImages::Impl::PrepareHeader(std::vector<uint8>& header, Path path, const String& title, const String& description, CatalogHeader::DirPtr dir, bool folder_scan) { header_.version_ = 1; header_.img_count_ = 0; FILETIME ft; ::GetSystemTimeAsFileTime(&ft); header_.creation_time_ = ft; // catalog creation time (UTC) header_.scan_types_ = scan_types_; // what types were scanned (FT_*) header_.title_ = String2WStr(title); header_.description_ = String2WStr(description); String root= path.GetRoot(); int drv_type= 0; for (;;) { drv_type = ::GetDriveType(path.c_str()); if (drv_type != DRIVE_NO_ROOT_DIR) break; if (path.length() > root.length()) path = path.GetDir(); else break; } header_.drive_type_ = drv_type; header_.drive_or_folder_ = folder_scan; TCHAR volume[MAX_PATH]= { 0 }; DWORD serial_no= 0; DWORD dummy= 0; DWORD vol_flags= 0; if (::GetVolumeInformation(path.c_str(), volume, MAX_PATH, &serial_no, &dummy, &vol_flags, 0, 0) == 0) { path += _T("\\"); if (::GetVolumeInformation(path.c_str(), volume, MAX_PATH, &serial_no, &dummy, &vol_flags, 0, 0) == 0) ::GetVolumeInformation(root.c_str(), volume, MAX_PATH, &serial_no, &dummy, &vol_flags, 0, 0); } header_.volume_name_ = String2WStr(volume); header_.volume_serial_no_ = serial_no; header_.volume_flags_ = vol_flags; header_.directory_ = dir; header_.Write(header); }
void CatalogImages::Impl::EnteringDir(const Path& path, int id) { //TRACE(L"===ENTERING: (%d) %s\n", id, path.c_str()); bool root= id == 1; // for a root use absolute path, for remaining folders use relative paths String name= root ? path.GetDir() : Path(path.GetDir()).GetFileNameAndExt(); DWORD attribs= ::GetFileAttributes(path.GetDir().c_str()); CatalogHeader::DirPtr dir= new CatalogHeader::Dir(String2WStr(name).c_str(), id, attribs); if (cur_dir_) { dir_stack_.push_back(cur_dir_); cur_dir_->subdirs_.push_back(dir); } cur_dir_ = dir; if (root) root_dir_ = cur_dir_; }