Ejemplo n.º 1
0
        // Recursively gets a folder's size in bytes
        long CalculateSize(DirectoryInfo parent)
        {
            if (ExcludePaths.Contains(parent.Name))
            {
                return(0);
            }

            long size = 0;

            try {
                foreach (DirectoryInfo directory in parent.GetDirectories())
                {
                    size += CalculateSize(directory);
                }

                foreach (FileInfo file in parent.GetFiles())
                {
                    size += file.Length;
                }
            } catch (Exception e) {
                Logger.LogInfo("Local", "Error calculating directory size", e);
            }

            return(size);
        }
Ejemplo n.º 2
0
        // Recursively gets a folder's size in bytes
        private double CalculateSize(DirectoryInfo parent)
        {
            if (!Directory.Exists(parent.ToString()))
            {
                return(0);
            }

            double size = 0;

            if (ExcludePaths.Contains(parent.Name))
            {
                return(0);
            }

            try {
                foreach (FileInfo file in parent.GetFiles())
                {
                    if (!file.Exists)
                    {
                        return(0);
                    }

                    size += file.Length;
                }

                foreach (DirectoryInfo directory in parent.GetDirectories())
                {
                    size += CalculateSize(directory);
                }
            } catch (Exception) {
                return(0);
            }

            return(size);
        }
 /// <summary>
 /// Gets the hash code
 /// </summary>
 /// <returns>Hash code</returns>
 public override int GetHashCode()
 {
     unchecked // Overflow is fine, just wrap
     {
         var hashCode = 41;
         // Suitable nullity checks etc, of course :)
         if (ImporterMinInterval != null)
         {
             hashCode = hashCode * 59 + ImporterMinInterval.GetHashCode();
         }
         if (ImporterUser != null)
         {
             hashCode = hashCode * 59 + ImporterUser.GetHashCode();
         }
         if (ExcludePaths != null)
         {
             hashCode = hashCode * 59 + ExcludePaths.GetHashCode();
         }
         if (IncludePaths != null)
         {
             hashCode = hashCode * 59 + IncludePaths.GetHashCode();
         }
         return(hashCode);
     }
 }
        /// <summary>
        /// Returns true if ComDayCqPollingImporterImplPollingImporterImplProperties instances are equal
        /// </summary>
        /// <param name="other">Instance of ComDayCqPollingImporterImplPollingImporterImplProperties to be compared</param>
        /// <returns>Boolean</returns>
        public bool Equals(ComDayCqPollingImporterImplPollingImporterImplProperties other)
        {
            if (other is null)
            {
                return(false);
            }
            if (ReferenceEquals(this, other))
            {
                return(true);
            }

            return
                ((
                     ImporterMinInterval == other.ImporterMinInterval ||
                     ImporterMinInterval != null &&
                     ImporterMinInterval.Equals(other.ImporterMinInterval)
                     ) &&
                 (
                     ImporterUser == other.ImporterUser ||
                     ImporterUser != null &&
                     ImporterUser.Equals(other.ImporterUser)
                 ) &&
                 (
                     ExcludePaths == other.ExcludePaths ||
                     ExcludePaths != null &&
                     ExcludePaths.Equals(other.ExcludePaths)
                 ) &&
                 (
                     IncludePaths == other.IncludePaths ||
                     IncludePaths != null &&
                     IncludePaths.Equals(other.IncludePaths)
                 ));
        }
Ejemplo n.º 5
0
 static bool IsExcludedPath(string path)
 {
     return(ExcludePaths.Any(p => path.StartsWith(p, StringComparison.OrdinalIgnoreCase)) ||
            path.EndsWith(ExcludeExtension, StringComparison.OrdinalIgnoreCase));
 }
Ejemplo n.º 6
0
 public bool IsExcludedByUser(string path)
 {
     return(ExcludePaths.Any(e => path.StartsWith(e)));
 }