示例#1
0
            public void AddResult(FsxResult r)
            {
                if (r == null)
                {
                    Debug.Assert(false); return;
                }

                lock (m_oResultsSync) { m_lResults.Add(r); }
            }
示例#2
0
            public static int CompareByPath(FsxResult a, FsxResult b)
            {
                if (a == null)
                {
                    Debug.Assert(false); return((b == null) ? 0 : -1);
                }
                if (b == null)
                {
                    Debug.Assert(false); return(1);
                }

                return(StrUtil.CompareNaturally(a.Path, b.Path));
            }
示例#3
0
        private static void FindInDirectory(string strPath, FsxContext ctx)
        {
            if (string.IsNullOrEmpty(strPath))
            {
                Debug.Assert(false); return;
            }
            if (ctx == null)
            {
                Debug.Assert(false); return;
            }

            try
            {
                string[] vFiles = Directory.GetFiles(strPath, "*",
                                                     SearchOption.TopDirectoryOnly);
                if (vFiles == null)
                {
                    Debug.Assert(false); vFiles = new string[0];
                }

                foreach (string strFile in vFiles)
                {
                    if (string.IsNullOrEmpty(strFile))
                    {
                        Debug.Assert(false); continue;
                    }
                    if (ctx.End)
                    {
                        return;
                    }

                    FsxResult r = ctx.Match(strFile);
                    if (r != null)
                    {
                        ctx.AddResult(r);
                    }
                }

                string[] vDirs = Directory.GetDirectories(strPath, "*",
                                                          SearchOption.TopDirectoryOnly);
                if (vDirs == null)
                {
                    Debug.Assert(false); vDirs = new string[0];
                }

                foreach (string strDir in vDirs)
                {
                    if (string.IsNullOrEmpty(strDir))
                    {
                        Debug.Assert(false); continue;
                    }
                    if (ctx.End)
                    {
                        return;
                    }

                    string strTerm = UrlUtil.EnsureTerminatingSeparator(strDir, false);
                    if (IsDirTraversal(strTerm))
                    {
                        Debug.Assert(false); continue;
                    }

                    FindInDirectory(strDir, ctx);
                }
            }
            catch (UnauthorizedAccessException) { }
            catch (Exception) { Debug.Assert(false); }
        }