Beispiel #1
0
        /// <summary>
        /// Scans the local branches data to locate all binaries that do not have a counterpart in the project database
        /// </summary>
        private bool LocateNonMogAssetsScanFiles(BackgroundWorker worker, string path, ArrayList rogueFiles, HybridDictionary MergeableAssets, string targetProjectPath, MOG_Properties classificationProperties)
        {
            // Check if this is a library path?
            if (MOG_ControllerLibrary.GetWorkingDirectory().Length > 0 &&
                path.StartsWith(MOG_ControllerLibrary.GetWorkingDirectory(), StringComparison.CurrentCultureIgnoreCase))
            {
                // Build us our library classification for this library path
                string classification = MOG_ControllerLibrary.ConstructLibraryClassificationFromPath(path);
                // Check if this library classification exists?
                if (MOG_ControllerProject.IsValidClassification(classification))
                {
                    // Obtain the properties for this library classification
                    classificationProperties = new MOG_Properties(classification);
                }
            }

            // Get all the files withing this directory
            FileInfo [] files = DosUtils.FileGetList(path, "*.*");
            if (files != null)
            {
                // For each file, check to see if we have a DB link for that filename
                foreach (FileInfo file in files)
                {
                    if (worker.CancellationPending)
                    {
                        return(false);
                    }

                    try
                    {
                        // Check to see if we have a DB link for that filename
                        if (MergeableAssets.Contains(file.FullName) == false)
                        {
                            // Check if we have a classificationProperties?
                            if (classificationProperties != null)
                            {
                                // Make sure this does not violate the classification filters
                                // Check the classification's inclusion filter.
                                if (classificationProperties.FilterInclusions.Length > 0)
                                {
                                    FilePattern inclusions = new FilePattern(classificationProperties.FilterInclusions);
                                    if (inclusions.IsFilePatternMatch(file.FullName) == false)
                                    {
                                        // Skip this file as it is not included
                                        continue;
                                    }
                                }
                                // Check the classification's exclusion filter.
                                if (classificationProperties.FilterExclusions.Length > 0)
                                {
                                    FilePattern exclusions = new FilePattern(classificationProperties.FilterExclusions);
                                    if (exclusions.IsFilePatternMatch(file.FullName) == true)
                                    {
                                        // Skip this file as it is excluded
                                        continue;
                                    }
                                }
                            }

                            // Make sure it is not hidden
                            if (Convert.ToBoolean(file.Attributes & FileAttributes.Hidden) == false)
                            {
                                // If no match was found, add to our list of rogue assets
                                rogueFiles.Add(file.FullName);
                            }
                        }
                    }
                    catch
                    {
                        // Needed just in case we have some files larger than 260 in length
                    }
                }
            }

            // Now check all these subDirs
            DirectoryInfo [] dirs = DosUtils.DirectoryGetList(path, "*.*");
            if (dirs != null)
            {
                foreach (DirectoryInfo dir in dirs)
                {
                    // Make sure it is not hidden
                    if (Convert.ToBoolean(dir.Attributes & FileAttributes.Hidden) == false)
                    {
                        // Scan their respective files
                        if (!LocateNonMogAssetsScanFiles(worker, dir.FullName, rogueFiles, MergeableAssets, targetProjectPath, classificationProperties))
                        {
                            return(false);
                        }
                    }
                }
            }

            return(true);
        }