Exemplo n.º 1
0
        public override bool MoveNext()
        {
            Win32Native.WIN32_FIND_DATA data = new Win32Native.WIN32_FIND_DATA();
            switch (base.state)
            {
            case 1:
                if (!this.empty)
                {
                    if (this.searchData.searchOption == SearchOption.TopDirectoryOnly)
                    {
                        base.state = 3;
                        if (base.current != null)
                        {
                            return(true);
                        }
                        goto Label_017A;
                    }
                    base.state = 2;
                    break;
                }
                base.state = 4;
                goto Label_0250;

            case 2:
                break;

            case 3:
                goto Label_017A;

            case 4:
                goto Label_0250;

            default:
                goto Label_0256;
            }
Label_015D:
            while (this.searchStack.Count > 0)
            {
                this.searchData = this.searchStack[0];
                this.searchStack.RemoveAt(0);
                this.AddSearchableDirsToStack(this.searchData);
                string fileName = this.searchData.fullPath + this.searchCriteria;
                this._hnd = Win32Native.FindFirstFile(fileName, data);
                if (this._hnd.IsInvalid)
                {
                    int hr = Marshal.GetLastWin32Error();
                    switch (hr)
                    {
                    case 2:
                    case 0x12:
                    case 3:
                    {
                        continue;
                    }
                    }
                    this._hnd.Dispose();
                    this.HandleError(hr, this.searchData.fullPath);
                }
                base.state = 3;
                this.needsParentPathDiscoveryDemand = true;
                SearchResult result = this.CreateSearchResult(this.searchData, data);
                if (!this._resultHandler.IsResultIncluded(result))
                {
                    goto Label_017A;
                }
                if (this.needsParentPathDiscoveryDemand)
                {
                    FileSystemEnumerableIterator <TSource> .DoDemand(this.searchData.fullPath);

                    this.needsParentPathDiscoveryDemand = false;
                }
                base.current = this._resultHandler.CreateObject(result);
                return(true);
            }
            base.state = 4;
            goto Label_0250;
Label_017A:
            if ((this.searchData != null) && (this._hnd != null))
            {
                while (Win32Native.FindNextFile(this._hnd, data))
                {
                    SearchResult result2 = this.CreateSearchResult(this.searchData, data);
                    if (this._resultHandler.IsResultIncluded(result2))
                    {
                        if (this.needsParentPathDiscoveryDemand)
                        {
                            FileSystemEnumerableIterator <TSource> .DoDemand(this.searchData.fullPath);

                            this.needsParentPathDiscoveryDemand = false;
                        }
                        base.current = this._resultHandler.CreateObject(result2);
                        return(true);
                    }
                }
                int num2 = Marshal.GetLastWin32Error();
                if (this._hnd != null)
                {
                    this._hnd.Dispose();
                }
                if (((num2 != 0) && (num2 != 0x12)) && (num2 != 2))
                {
                    this.HandleError(num2, this.searchData.fullPath);
                }
            }
            if (this.searchData.searchOption == SearchOption.TopDirectoryOnly)
            {
                base.state = 4;
            }
            else
            {
                base.state = 2;
                goto Label_015D;
            }
Label_0250:
            base.Dispose();
Label_0256:
            return(false);
        }