예제 #1
0
        public IList <DirectoryEntry> GetDirectoryEntries(FullPath path)
        {
            var list = NativeFile.GetDirectoryEntries(path.Value);

            // Skip any entry that is longer than MAX_PATH.
            // Fix this once we fully support the long path syntax ("\\?\" prefix)
            if (list.Any(entry => PathHelpers.IsPathTooLong(path.Value, entry.Name)))
            {
                return(list.Where(entry => {
                    if (PathHelpers.IsPathTooLong(path.Value, entry.Name))
                    {
                        // Note: The condition is unsafe from a pure concurrency point of view,
                        //       but is ok in this case because the field is incrementally increasing.
                        //       This is just an optimization to avoid an Interlocked call.
                        if (_pathTooLongErrorCount <= MaxPathTooLogLogCount)
                        {
                            var logCount = Interlocked.Increment(ref _pathTooLongErrorCount);
                            if (logCount <= MaxPathTooLogLogCount)
                            {
                                Logger.LogInfo("Skipping directory entry because path is too long: \"{0}\"",
                                               path.Combine(new RelativePath(entry.Name)));
                            }
                            if (logCount == MaxPathTooLogLogCount)
                            {
                                Logger.LogInfo("  (Note: No more message abount path too long will be logged, because the maximum number of occurrences has been reached)");
                            }
                        }
                        return false;
                    }
                    return true;
                }).ToList());
            }
            return(list);
        }
 /// <summary>
 ///  Skip paths BCL can't process (e.g. path too long)
 /// </summary>
 private bool SkipPath(string path)
 {
     if (PathHelpers.IsPathTooLong(path))
     {
         Logger.LogInfo("Skipping file change event because path is too long: \"{0}\"", path);
         return(true);
     }
     if (!PathHelpers.IsValidBclPath(path))
     {
         Logger.LogInfo("Skipping file change event because path is invalid: \"{0}\"", path);
         return(true);
     }
     return(false);
 }
예제 #3
0
        /// <summary>
        ///  Skip paths BCL can't process (e.g. path too long)
        /// </summary>
        private bool SkipPath(string path)
        {
            if (PathHelpers.IsPathTooLong(path))
            {
                switch (_logLimiter.Proceed())
                {
                case BoundedOperationLimiter.Result.YesAndLast:
                    Logger.LogInfo("(The following log message will be the last of its kind)", path);
                    goto case BoundedOperationLimiter.Result.Yes;

                case BoundedOperationLimiter.Result.Yes:
                    Logger.LogInfo("Skipping file change event because path is too long: \"{0}\"", path);
                    break;

                case BoundedOperationLimiter.Result.NoMore:
                    break;
                }
                return(true);
            }
            if (!PathHelpers.IsValidBclPath(path))
            {
                switch (_logLimiter.Proceed())
                {
                case BoundedOperationLimiter.Result.YesAndLast:
                    Logger.LogInfo("(The following log message will be the last of its kind)", path);
                    goto case BoundedOperationLimiter.Result.Yes;

                case BoundedOperationLimiter.Result.Yes:
                    Logger.LogInfo("Skipping file change event because path is invalid: \"{0}\"", path);
                    break;

                case BoundedOperationLimiter.Result.NoMore:
                    break;
                }
                return(true);
            }
            return(false);
        }