void ReadDir(string dir_name, int index, int count) { if (index + count > m_count) { throw new InvalidFormatException(); } int index_offset = index * EntrySize; for (int i = 0; i < count; ++i, index_offset += EntrySize) { if (IsDir(index_offset)) { if (m_ignore_dirs) { continue; } int subdir_index = m_index.ToInt32(index_offset + DirIndexPos); if (subdir_index < index + count) { continue; } var subdir_name = ReadName(index_offset); int subdir_count = m_index.ToInt32(index_offset + DirCountPos); ReadDir(Path.Combine(dir_name, subdir_name), subdir_index, subdir_count); } else { var name = ReadName(index_offset); name = Path.Combine(dir_name, name); var entry = m_saf.Create <PackedEntry> (name); entry.Offset = (long)m_index.ToUInt32(index_offset + OffsetPos) << 11; entry.Size = m_index.ToUInt32(index_offset + SizePos); entry.UnpackedSize = m_index.ToUInt32(index_offset + UnpackedPos); entry.IsPacked = entry.UnpackedSize != 0; m_dir.Add(entry); } } }
void CreateWorker(object sender, DoWorkEventArgs e) { m_pending_error = null; try { using (var tmp_file = new GARbro.Shell.TemporaryFile(Path.GetDirectoryName(m_arc_name), Path.GetRandomFileName())) { m_total = m_file_list.Count() + 1; using (var file = File.Create(tmp_file.Name)) { m_format.Create(file, m_file_list, m_options, CreateEntryCallback); } if (!GARbro.Shell.File.Rename(tmp_file.Name, m_arc_name)) { throw new Win32Exception(GARbro.Shell.File.GetLastError()); } } } catch (Exception X) { m_pending_error = X; } }