示例#1
0
        private void writeToFileStream(RecEmasterHdr rec)
        {
            byte[]   buffer   = new byte[RecEmasterSize];
            GCHandle gcHandle = GCHandle.Alloc(buffer, GCHandleType.Pinned);

            Marshal.StructureToPtr(rec, gcHandle.AddrOfPinnedObject(), true);
            metastockGlobals.Fs2.Write(buffer, 0, RecEmasterSize);
            gcHandle.Free();
        }
示例#2
0
        private void readFromFileStream(ref RecEmasterHdr rec)
        {
            byte[] buffer = new byte[RecEmasterSize];
            int    offset = 0;

            while (offset < buffer.Length)
            {
                offset += metastockGlobals.Fs2.Read(buffer, offset, buffer.Length - offset);
            }
            GCHandle gcHandle = GCHandle.Alloc(buffer, GCHandleType.Pinned);

            rec = (RecEmasterHdr)Marshal.PtrToStructure(gcHandle.AddrOfPinnedObject(),
                                                        typeof(RecEmasterHdr));
            gcHandle.Free();
        }
示例#3
0
 public DirHdr(MsGlobals msglobal)
 {
     metastockGlobals = msglobal;
     masterHeader     = new RecMasterHdr();
     emasterHeader    = new RecEmasterHdr();
     xmasterHeader    = new RecXmasterHdr();
     if (File.Exists(metastockGlobals.Fs1Pth) && metastockGlobals.Fs1 != null)
     {
         readFromFileStream(ref masterHeader);
     }
     if (File.Exists(metastockGlobals.Fs2Pth) && metastockGlobals.Fs2 != null)
     {
         readFromFileStream(ref emasterHeader);
     }
     if (!File.Exists(metastockGlobals.Fs3Pth) || metastockGlobals.Fs3 == null)
     {
         return;
     }
     readFromFileStream(ref xmasterHeader);
 }