Example #1
0
        private void writeToFileStream(RecMasterHdr rec)
        {
            byte[]   buffer   = new byte[RecMasterSize];
            GCHandle gcHandle = GCHandle.Alloc(buffer, GCHandleType.Pinned);

            Marshal.StructureToPtr(rec, gcHandle.AddrOfPinnedObject(), true);
            metastockGlobals.Fs1.Write(buffer, 0, RecMasterSize);
            gcHandle.Free();
        }
Example #2
0
        private void readFromFileStream(ref RecMasterHdr rec)
        {
            byte[] buffer = new byte[RecMasterSize];
            int    offset = 0;

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

            rec = (RecMasterHdr)Marshal.PtrToStructure(gcHandle.AddrOfPinnedObject(),
                                                       typeof(RecMasterHdr));
            gcHandle.Free();
        }
Example #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);
 }