public void SaveToDir(String DirName) { V8File f = First; DirectoryInfo di = new DirectoryInfo(DirName); di.Create(); if (!DirName.EndsWith("\\")) { DirName += '\\'; } while (f != null) { if (f.IsCatalog()) { f.GetCatalog().SaveToDir(DirName + f.Name); } else { f.SaveToFile(DirName + f.Name); } f.Close(); f = f.Next; } }
public bool is_modified; // признак модифицированности /// <summary> /// Инициализация объекта /// </summary> public void Initialize() { is_destructed = false; Catalog_Header _ch = new Catalog_Header(); int _temp = 0; string _name = ""; FAT_Item _fi; //char* _temp_buf; //byte[] _temp_buf = new byte[32]; MemoryStream _file_header = new MemoryStream(); Stream _fat = null; V8File _prev = null; V8File _file = null; V8File f = null; int _countfiles = 0; Data.Seek(0, SeekOrigin.Begin); _ch = ReadFromData(Data); // т.к. читаем не с помощью метода чтения потока Data, позицию необходимо менять вручную //Data.Seek(16, SeekOrigin.Begin); start_empty = _ch.Start_Empty; page_size = _ch.Page_Size; version = _ch.Version; First = null; _prev = null; try { if (Data.Length > 16) { int rlen = 0; _fat = Read_Block(Data, 16, ref rlen); _fat.Seek(0, SeekOrigin.Begin); //_countfiles = (int)_fat.Length / 12; _countfiles = rlen / 12; //_countfiles = ((MemoryStream)_fat).Capacity / 0x100 / 12; //_countfiles = (int)_fat.Length / 12; for (int i = 0; i < _countfiles; i++) { //_fi = ReadFatItemFromData(Data); _fi = ReadFatItemFromData(_fat); Read_Block(Data, _fi.Header_Start, ref rlen, _file_header); _file_header.Seek(0, SeekOrigin.Begin); byte[] _temp_buf = new byte[_file_header.Length]; //_file_header->Read(_temp_buf, _file_header->Size); _file_header.Read(_temp_buf, 0, (int)_file_header.Length); // TODO: Надо пристально проверять что здесь происходит // _name = (wchar_t*)(_temp_buf + 20); - это ГУИД из 36 символов //_name = GetString(_temp_buf)[20].ToString(); byte[] _tmp_uid = new byte[72]; Array.Copy(_temp_buf, 20, _tmp_uid, 0, 72); _name = GetString(_tmp_uid); if (_name.IndexOf("root") != -1) { _name = "root"; } if (_name.IndexOf("version") != -1) { if (_name.IndexOf("versions") != -1) { _name = "versions"; } else { _name = "version"; } } // TODO: Надо пристально проверять что здесь происходит //_file = new v8file(this, _name, _prev, _fi.data_start, _fi.header_start, (__int64*)_temp_buf, (__int64*)(_temp_buf + 8)); _file = new V8File(this, _name, _prev, _fi.Data_Start, _fi.Header_Start, new DateTime(), new DateTime()); if (_prev == null) { First = _file; } _prev = _file; } //_file_header.Close(); //_fat.Close(); } } catch (Exception) { f = First; while (f != null) { f.Close(); f = f.Next; } while (First != null) { First.Close(); } iscatalog = false; iscatalogdefined = true; First = null; Last = null; start_empty = 0; page_size = 0; version = 0; zipped = false; } Last = _prev; is_fatmodified = false; is_emptymodified = false; is_modified = false; is_destructed = false; flushed = false; leave_data = false; }