Exemple #1
0
        private static void ExcludeSubFoldersOfEmptyFolders(ref List <string> emptyFolders)
        {
            var emptyFoldersFiltered = new List <string>(emptyFolders.Count);

            for (var i = emptyFolders.Count - 1; i >= 0; i--)
            {
                var folder = emptyFolders[i];
                if (!CSArrayTools.IsItemContainsAnyStringFromArray(folder, emptyFoldersFiltered))
                {
                    emptyFoldersFiltered.Add(folder);
                }
            }
            emptyFolders = emptyFoldersFiltered;
        }
Exemple #2
0
        private static void ExcludeSubFoldersOfEmptyFolders(ref List <string> emptyFolders)
        {
            var emptyFoldersFiltered = new List <string>(emptyFolders.Count);

            for (var i = emptyFolders.Count - 1; i >= 0; i--)
            {
                var folder = emptyFolders[i];

                if (CSFilterTools.HasEnabledFilters(ProjectSettings.Cleaner.pathIncludesFilters))
                {
                    var emptyFolder = CSPathTools.GetProjectRelativePath(folder);
                    if (!CSFilterTools.IsValueMatchesAnyFilter(emptyFolder, ProjectSettings.Cleaner.pathIncludesFilters))
                    {
                        continue;
                    }
                }

                if (!CSArrayTools.IsItemContainsAnyStringFromArray(folder, emptyFoldersFiltered))
                {
                    emptyFoldersFiltered.Add(folder);
                }
            }
            emptyFolders = emptyFoldersFiltered;
        }
Exemple #3
0
        private static bool FindEmptyFoldersRecursive(List <string> foundEmptyFolders, string root, bool showProgress, out bool canceledByUser)
        {
            string[] rootSubFolders = Directory.GetDirectories(root);

            bool canceled        = false;
            bool emptySubFolders = true;

            foreach (string folder in rootSubFolders)
            {
                folderIndex++;

                if (showProgress && EditorUtility.DisplayCancelableProgressBar(string.Format(PROGRESS_CAPTION, currentPhase, phasesCount, folderIndex, foldersCount), "Scanning folders...", (float)folderIndex / foldersCount))
                {
                    canceled = true;
                    break;
                }

                if (CSArrayTools.IsItemContainsAnyStringFromArray(folder.Replace('\\', '/'), MaintainerSettings.Cleaner.pathIgnores))
                {
                    emptySubFolders = false;
                    continue;
                }

                if (Path.GetFileName(folder).StartsWith("."))
                {
                    continue;
                }

                emptySubFolders &= FindEmptyFoldersRecursive(foundEmptyFolders, folder, showProgress, out canceled);
                if (canceled)
                {
                    break;
                }
            }

            if (canceled)
            {
                canceledByUser = true;
                return(false);
            }

            bool rootFolderHasFiles = true;

            string[] filesInRootFolder = Directory.GetFiles(root);

            foreach (string file in filesInRootFolder)
            {
                if (file.EndsWith(".meta"))
                {
                    continue;
                }

                rootFolderHasFiles = false;
                break;
            }

            bool rootFolderEmpty = emptySubFolders && rootFolderHasFiles;

            if (rootFolderEmpty)
            {
                foundEmptyFolders.Add(root);
            }

            canceledByUser = false;
            return(rootFolderEmpty);
        }