public static Decode ( DeOps.Implementation.Protocol.G2Header root ) : |
||
root | DeOps.Implementation.Protocol.G2Header | |
Résultat |
public static VersionedFileHeader Decode(byte[] data) { G2Header root = new G2Header(data); if (!G2Protocol.ReadPacket(root)) { return(null); } if (root.Name != DataPacket.VersionedFile) { return(null); } return(VersionedFileHeader.Decode(root)); }
void Store_Local(DataReq store) { // getting published to - search results - patch SignedData signed = SignedData.Decode(store.Data); if (signed == null) { return; } G2Header embedded = new G2Header(signed.Data); // figure out data contained if (G2Protocol.ReadPacket(embedded)) { if (embedded.Name == DataPacket.VersionedFile) { Process_VersionedFile(store, signed, VersionedFileHeader.Decode(signed.Data)); } } }
public void LoadHeaders() { List <string> goodPaths = new List <string>(); try { goodPaths.Add(HeaderPath); if (!File.Exists(HeaderPath)) { return; } using (IVCryptoStream crypto = IVCryptoStream.Load(HeaderPath, LocalKey)) { PacketStream stream = new PacketStream(crypto, Network.Protocol, FileAccess.Read); G2Header root = null; while (stream.ReadPacket(ref root)) { if (root.Name == DataPacket.SignedData) { SignedData signed = SignedData.Decode(root); G2Header embedded = new G2Header(signed.Data); // figure out data contained if (G2Protocol.ReadPacket(embedded)) { if (embedded.Name == DataPacket.VersionedFile) { VersionedFileHeader header = VersionedFileHeader.Decode(embedded); if (header.FileHash != null) { goodPaths.Add(GetFilePath(header)); } Process_VersionedFile(null, signed, header); } } } } } // remove loose files foreach (string testPath in Directory.GetFiles(CachePath)) { if (!goodPaths.Contains(testPath)) { try { File.Delete(testPath); } catch { } } } } catch (Exception ex) { Core.Network.UpdateLog("VersionedFile", "Error loading data " + ex.Message); } }