Exemplo n.º 1
0
        } /* OpenSipperDrive */

        private void   GetListOfSipperFiles()
        {
            totalSectorsUsed = Constants.MAX_SIPPER_FILES + 1; // 1 Sector for each posible file + 1 sector for the SipperPartitionSector

            sipperFiles = new SipperFileControlBlockList();

            Int64 sipperDirectorySectorByteOffset = mbr.GetSipperDirectoryByteOffset();

            fs.Seek(sipperDirectorySectorByteOffset, SeekOrigin.Begin);

            for (int i = 0; i < Constants.MAX_SIPPER_FILES; i++)
            {
                SipperFileControlBlock fcb = SipperFileControlBlock.CreateFromFileStream(fs);
                if (fcb == null)
                {
                    throw new Exception("Error reading Sipper FileControlBlock");
                }

                fcb.FcbIndex = i;

                if (fcb.EndSector <= 0)
                {
                    if (fcb.Allocated != SipperFileControlBlock.SIPPER_FILE_FREE)
                    {
                        sipperFiles.Add(fcb);
                        lastSectorUsed    = Math.Max(fcb.EndSector, lastSectorUsed);
                        totalSectorsUsed += 1 + fcb.EndSector - fcb.StartSector;
                    }
                }

                else if (fcb.EndSector > 0)
                {
                    sipperFiles.Add(fcb);
                    lastSectorUsed    = Math.Max(fcb.EndSector, lastSectorUsed);
                    totalSectorsUsed += 1 + fcb.EndSector - fcb.StartSector;
                }
            }

            return;
        } /* GetListOfSipperFiles */
Exemplo n.º 2
0
        } /* ResetSipperDirectory */

        //***********************************************************************************
        //*                  Determines if the same disk drive is attached.                 *
        //***********************************************************************************
        public bool  AreWeTheSameDrive()
        {
            if ((sipperPartitionSector == null) || (origFirstFileControlBlock == null))
            {
                return(false);
            }


            //  For now we will always return true;
            return(true);


            BlockStart();

            long lastFsPosition = 0;

            bool diskFileWasAlreadyOpened = false;

            if (fs != null)
            {
                diskFileWasAlreadyOpened = true;
                lastFsPosition           = fs.Position;
            }

            if ((!diskFileWasAlreadyOpened) && (openedSipperFiles != null) && (openedSipperFiles.Count == 0))
            {
                // We will only reopen the Disk handle if no SIPPER files are open.
                try
                {
                    ReOpen(false);
                }
                catch (Exception)
                {
                    BlockEnd();
                    return(false);
                }
            }

            bool weAreTheSameHardDrive = false;


            Int64 sipperPartitionSectorOffset = mbr.GetPartitionSectorByteOffset(Constants.SIPPER_PARTITION);

            fs.Seek(sipperPartitionSectorOffset, SeekOrigin.Begin);
            SipperPartitionSector currentSipperPartitionSector = SipperPartitionSector.CreateFromFileStream(fs);

            if (sipperPartitionSector.Equals(currentSipperPartitionSector))
            {
                SipperFileControlBlock firstFileControlBlock = SipperFileControlBlock.CreateFromFileStream(fs);
                if (firstFileControlBlock.Equals(origFirstFileControlBlock))
                {
                    weAreTheSameHardDrive = true;
                }
            }

            if (diskFileWasAlreadyOpened)
            {
                fs.Seek(lastFsPosition, SeekOrigin.Begin);
            }
            else
            {
                CloseHandleToPhysicalDisk();
            }

            BlockEnd();
            return(weAreTheSameHardDrive);
        }