private void putToList() { Maker.Instance.Items.Clear(); foreach (Object obj in _listFiles.Items) { CListItem item = obj as CListItem; if(item == null) { continue; } ListFileType type = (ListFileType)((ComboBox)item.SubItems[0].Control).SelectedItem; String fileName = item.SubItems[1].Text; if(type == ListFileType.IGNORED) continue; ListFile file = new ListFile(); file.FileName = fileName; file.SourceDirectoryName = Path; file.DescriptionDirectoryName = MakeTo; file.FileType = type; Maker.Instance.Items.Add(file); } }
public void putToList() { foreach (object obj in _filesList.Items) { var file = new ListFile { FileName = obj.ToString(), SourceDirectoryName = SelectedPath, DescriptionDirectoryName = DescriptionPath }; _files.Add(file); } }
public void make() { if (_files.Count == 0) { _log.Info("Files == 0"); MessageBox.Show("Files is none", "Premaker", MessageBoxButtons.OK, MessageBoxIcon.Asterisk); return; } if (!Directory.Exists(DescriptionDirectory)) { Directory.CreateDirectory(DescriptionDirectory); } FileInfo listZIP = new FileInfo(DescriptionDirectory + "/list.zip"); ZipOutputStream zipListStream = new ZipOutputStream(listZIP.Create()); zipListStream.SetLevel(COMPRESS_LEVEL); //уровень компресии zipListStream.Password = PASSWORD; //пароль ZipEntry listEntry = new ZipEntry("list.lst"); listEntry.DateTime = DateTime.Now; zipListStream.PutNextEntry(listEntry); writeString(zipListStream, "#Revision:" + REVISION + "\n"); //пишем номер ревизии ChooseForm.Instance.FormAsGameFiles.onStart(); //прогресс бар включаем ChooseForm.Instance.FormAsGameFiles.disableItems(false); //отключаем что б не изменилось for (int i = 0; i < Items.Count; i++) //листаем { if (Break) { ChooseForm.Instance.FormAsGameFiles.setStatus("Break"); ChooseForm.Instance.FormAsGameFiles.setValue(0); return; } lock (zipListStream) { ListFile item = Items[i]; try { if (!item.Exists()) { _log.Info("WTF source file is deleted ??. File: " + item.SourceDirectoryName + item.FileName); continue; } if (item.FileType != ListFileType.DELETE) { item.validateDirectoryes(); FileStream sourceStream = item.CreateSource(); FileStream descriptionStream = item.CreateDescription(); if (sourceStream == null || descriptionStream == null) { _log.Info("WTF streams NULL???. File: " + item.FileName); } ChooseForm.Instance.FormAsGameFiles.setStatus("Compressing " + item.FileName); ZipOutputStream zipDescriptionStream = new ZipOutputStream(descriptionStream); //открываем стрим zipDescriptionStream.SetLevel(COMPRESS_LEVEL); zipDescriptionStream.Password = PASSWORD; ZipEntry entry = new ZipEntry(item.EntryName.Replace(".zip", "")); entry.DateTime = item.SourceTime(); zipDescriptionStream.PutNextEntry(entry); byte[] bytes = new byte[sourceStream.Length]; int readLen = sourceStream.Read(bytes, 0, bytes.Length); sourceStream.Close(); if (readLen != bytes.Length) { _log.Info("WTF source file is not compled read??. File: " + item.FileName); continue; } zipDescriptionStream.Write(bytes, 0, readLen); zipDescriptionStream.Finish(); zipDescriptionStream.Close(); } writeString(zipListStream, item.FileName + "\t" + item.FileType + "\t" + item.MD5 + "\n"); } catch (Exception e) { _log.Info("Exception: file - " + item.FileName, e); } finally { int p = ((100 * i) / Items.Count); if (p > 100) { p = 100; } ChooseForm.Instance.FormAsGameFiles.setValue(p); } } } zipListStream.Finish(); zipListStream.Close(); ChooseForm.Instance.FormAsGameFiles.setStatus("Done"); ChooseForm.Instance.FormAsGameFiles.disableItems(true); ChooseForm.Instance.FormAsGameFiles.onEnd(); }