Beispiel #1
0
        public bool match(string s, int si = 0)
        {
            var and = (addition & crtlg.and) == crtlg.and;
            var not = (addition & crtlg.not) == crtlg.not;
            var l   = false;

            switch (crt)
            {
            case crt.startwith:
                l = s.StartsWith(val, StringComparison.OrdinalIgnoreCase);
                break;

            case crt.contain:
                l = s.IndexOf(val, StringComparison.OrdinalIgnoreCase) != -1;
                break;

            case crt.endwith:
                l = s.EndsWith(val, StringComparison.OrdinalIgnoreCase);
                break;
            }
            if (next_srch == null)
            {
                return(l);
            }
            if (and)
            {
                if (!l)
                {
                    return(false);
                }
                else
                {
                }
            }
            else if (l)
            {
                return(true);
            }
            var b = next_srch.match(s, si);

            return(not ? !b : b);
        }
Beispiel #2
0
        private int _find(srch srch)
        {
            int    i = 0;
            string s;
            var    data = new WIN32_FIND_DATA();

deb:
            string path = null;

            lock (stack)
                if (stack.Count == 0)
                {
                    if (isallsleep())
                    {
                        return(i);
                    }
                    else
                    {
                        waiting = true;
                        Thread.Sleep(1);
                        goto deb;
                    }
                }
                else
                {
                    path = stack.Pop();
                }
            if (path == null)
            {
                goto deb;
            }
            waiting = false;
            rslts rslt = null;
            var   ff   = Win32Native.FindFirstFile(path + "*", data);

            if (!ff.IsInvalid)
            {
                do
                {
                    if (!data.IsFileOrDir)
                    {
                        continue;
                    }
                    s = data.cFileName;
                    if (data.IsDir)
                    {
                        stack.Push(string.Concat(path, data.cFileName, "\\"));
                    }
                    if (srch.match(s))
                    {
                        this.i++;
                        if (rslt == null)
                        {
                            rslt = new rslts(path);
                        }
                        rslt.files.Add(data);
                        data = new WIN32_FIND_DATA();
                    }
                } while (Win32Native.FindNextFile(ff, data));
            }
            if (rslt != null)
            {
                result.Add(rslt);
            }
            goto deb;
        }