示例#1
0
            public LogExtentEnumerator(LogExtentCollection collection)
            {
                this.collection = collection;
                this.version    = this.collection.Version;

                SafeFileHandle logHandle = this.collection.Store.Handle;

                CLFS_SCAN_CONTEXT scanContext = new CLFS_SCAN_CONTEXT();

                try
                {
                    List <LogExtent> extents = new List <LogExtent>();

                    CLFS_INFORMATION logInfo;
                    this.collection.Store.GetLogFileInformation(out logInfo);
                    if (logInfo.TotalContainers > 0)
                    {
                        UnsafeNativeMethods.CreateLogContainerScanContextSync(
                            logHandle,
                            0,
                            logInfo.TotalContainers,
                            CLFS_SCAN_MODE.CLFS_SCAN_FORWARD,
                            ref scanContext);

                        long containerPointer = scanContext.pinfoContainer.ToInt64();

                        CLFS_CONTAINER_INFORMATION_WRAPPER info;
                        info = new CLFS_CONTAINER_INFORMATION_WRAPPER();

                        int infoSize;
                        infoSize = Marshal.SizeOf(typeof(CLFS_CONTAINER_INFORMATION_WRAPPER));

                        for (uint i = 0; i < scanContext.cContainersReturned; i++)
                        {
                            Marshal.PtrToStructure(new IntPtr(containerPointer),
                                                   info);

                            LogExtent extent = new LogExtent(
                                info.info.GetActualFileName(logHandle),
                                info.info.FileSize,
                                (LogExtentState)info.info.State);
                            extents.Add(extent);

                            containerPointer += infoSize;
                        }
                    }

                    this.innerEnum = extents.GetEnumerator();
                }
                finally
                {
                    if ((scanContext.eScanMode & CLFS_SCAN_MODE.CLFS_SCAN_INITIALIZED) != 0)
                    {
                        UnsafeNativeMethods.ScanLogContainersSyncClose(
                            ref scanContext);
                    }
                }
            }
示例#2
0
        void CommonInitialize(bool writeOnly)
        {
            if (!ThreadPool.BindHandle(this.logFile))
            {
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(
                          new IOException(SR.GetString(SR.IO_BindFailed)));
            }

            this.logManagement = new LogManagementAsyncResult(this);

            if (!writeOnly)
            {
                CLFS_INFORMATION info;
                GetLogFileInformation(out info);
                this.archivable = ((info.Attributes &
                                    Const.FILE_ATTRIBUTE_ARCHIVE) != 0);

                this.extents   = new LogExtentCollection(this);
                this.logPolicy = new LogPolicy(this);
            }
        }