Beispiel #1
0
        /*
         * This function is used to check if a file should be included/excluded
         * from the list of files based on its name and type etc.  The value of
         * exclude_level is set to either SERVER_EXCLUDES or ALL_EXCLUDES.
         */
        private bool checkExcludeFile(string fileName, int isDir, int excludeLevel)
        {
            int rc;

            if (excludeLevel == Options.NO_EXCLUDES)
            {
                return(false);
            }
            if (fileName.CompareTo(String.Empty) != 0)
            {
                /* never exclude '.', even if somebody does --exclude '*' */
                if (fileName[0] == '.' && fileName.Length == 1)
                {
                    return(false);
                }
                /* Handle the -R version of the '.' dir. */
                if (fileName[0] == '/')
                {
                    int len = fileName.Length;
                    if (fileName[len - 1] == '.' && fileName[len - 2] == '/')
                    {
                        return(true);
                    }
                }
            }
            if (excludeLevel != Options.ALL_EXCLUDES)
            {
                return(false);
            }
            Exclude excl = new Exclude(options);

            if (options.excludeList.Count > 0 &&
                (rc = excl.CheckExclude(options.excludeList, fileName, isDir)) != 0)
            {
                return((rc < 0) ? true : false);
            }
            return(false);
        }
Beispiel #2
0
        /*
         * This function is used to check if a file should be included/excluded
         * from the list of files based on its name and type etc.  The value of
         * exclude_level is set to either SERVER_EXCLUDES or ALL_EXCLUDES.
         */
        private bool CheckExcludeFile(string fileName, int isDir, int excludeLevel)
        {
            int rc;

            if (excludeLevel == Options.NoExcludes)
            {
                return(false);
            }
            if (!fileName.IsBlank())
            {
                /* never exclude '.', even if somebody does --exclude '*' */
                if (fileName[0] == '.' && fileName.Length == 1)
                {
                    return(false);
                }
                /* Handle the -R version of the '.' dir. */
                if (fileName.StartsWith(Path.PathSeparator.ToString()))
                {
                    var len = fileName.Length;
                    if (fileName.EndsWith((string.Format(".{0}", Path.PathSeparator))))
                    {
                        return(true);
                    }
                }
            }
            if (excludeLevel != Options.AllExcludes)
            {
                return(false);
            }
            var excl = new Exclude(_options);

            if (_options.ExcludeList.Count > 0 &&
                (rc = excl.CheckExclude(_options.ExcludeList, fileName, isDir)) != 0)
            {
                return((rc < 0) ? true : false);
            }
            return(false);
        }
Beispiel #3
0
		/*
		 * This function is used to check if a file should be included/excluded
		 * from the list of files based on its name and type etc.  The value of
		 * exclude_level is set to either SERVER_EXCLUDES or ALL_EXCLUDES.
		 */
		private bool checkExcludeFile(string fileName, int isDir, int excludeLevel)
		{
			int rc;

			if (excludeLevel == Options.NO_EXCLUDES)
				return false;
			if (fileName.CompareTo("") != 0) 
			{
				/* never exclude '.', even if somebody does --exclude '*' */
				if (fileName[0] == '.' && fileName.Length == 1)
					return false;
				/* Handle the -R version of the '.' dir. */
				if (fileName[0] == '/') 
				{
					int len = fileName.Length;
					if (fileName[len-1] == '.' && fileName[len-2] == '/')
						return true;
				}
			}
			if (excludeLevel != Options.ALL_EXCLUDES)
				return false;
			Exclude excl = new Exclude(options);
			if (options.excludeList.Count > 0
				&& (rc = excl.CheckExclude(options.excludeList, fileName, isDir)) != 0)
				return (rc < 0) ? true : false;
			return false;
		}