Exemple #1
0
 public Stream GetInstallationStream(string moduleName, string installationFile)
 {
     var installationFilePath = GetInstallationFilePath(moduleName, installationFile);
     if (File.Exists(installationFilePath))
     {
         using (var fs = new FileStream(installationFilePath, FileMode.Open, FileAccess.Read, FileShare.Read))
         {
             return new MemoryStream(fs.ReadData());
         }
     }
     return null;
 }
        private static MetadataTableInfo readMetadataTableInfo(FileStream metadataStream, int offset)
        {
            MetadataTableInfo info = new MetadataTableInfo();

            info.identifier = metadataStream.ReadASCII(offset, IDENTIFIER_LENGTH);
            info.tableOffset = new Pointer(metadataStream.ReadData(offset + IDENTIFIER_LENGTH, 4));
            info.numEntries = metadataStream.ReadInt(offset + 4 + IDENTIFIER_LENGTH);
            info.totalLength = metadataStream.ReadInt(offset + 8 + IDENTIFIER_LENGTH);

            return info;
        }
        /*public byte[] getAt(int offset, int length)
        {
            //Returns [offset, offset+length)

        }
        public byte[] getDereferenceOf(int offset, int length)
        {
            //Returns [*offset, *offset+length)

        }*/
        private static Tuple<int, byte[]> readMetadataEntry(FileStream metadataStream, int offset)
        {
            //Returns [*(offset+4), *(offset+4)+*offset)
            return Tuple.Create(metadataStream.ReadInt(offset),
                metadataStream.ReadData(offset + 4, metadataStream.ReadInt(offset)));
        }