Esempio n. 1
0
        public void ExecuteRestore(UnlockParameters FileDescriptor, string sourceFile, string destination)
        {
            string     TargetFileName = string.Format("{0}{1}", destination, FileDescriptor.FileName);
            FileStream WriteFile      = new FileStream(TargetFileName, FileMode.Create, FileAccess.Write);
            FileStream ReadSTF        = new FileStream(sourceFile, FileMode.Open, FileAccess.Read);

            ReadSTF.Position = FileDescriptor.FileStartAddress;
            WriteContents(WriteFile, ReadSTF, FileDescriptor.FileEndAddress);
            WriteFile.Close();
            ReadSTF.Close();
        }
Esempio n. 2
0
        public UnlockParameters ExtractContents(string filepath)
        {
            FileStream ReadSTF    = new FileStream(filepath, FileMode.Open, FileAccess.Read);
            long       headerCode = Read64bits(ReadSTF); //Reading header code

            ReadSTF.ReadByte();                          //Omitting isFolder flag
            long   FileNameLength = Read64bits(ReadSTF);
            string FileName       = GetFileName(ReadSTF, FileNameLength);
            long   StartAddress   = Read64bits(ReadSTF);
            long   EndAddress     = Read64bits(ReadSTF);

            ReadSTF.Position = ReadSTF.Length - 8;
            long FooterCode = Read64bits(ReadSTF);

            ReadSTF.Close();
            UnlockParameters unlockParams = new UnlockParameters();

            unlockParams.HeaderCode       = headerCode;
            unlockParams.FooterCode       = FooterCode;
            unlockParams.FileName         = FileName;
            unlockParams.FileStartAddress = StartAddress;
            unlockParams.FileEndAddress   = EndAddress;
            return(unlockParams);
        }