Exemple #1
0
        public IEnumerable <string> GetFilesReferencedBy(string absoluteName, EditorObjects.Parsing.TopLevelOrRecursive topLevelOrRecursive)
        {
#if GLUE
            return(FileReferenceManager.Self.GetFilesReferencedBy(absoluteName, topLevelOrRecursive));
#else
            throw new NotImplementedException();
#endif
        }
Exemple #2
0
 public void GetFilesReferencedBy(string file, EditorObjects.Parsing.TopLevelOrRecursive depth, List <string> listToFill)
 {
     if (CanFileReferenceContent(file))
     {
         listToFill.AddRange(
             ContentParser.GetFilesReferencedByAsset(file));
     }
 }
Exemple #3
0
        public List <string> GetFilesReferencedBy(string absoluteName, EditorObjects.Parsing.TopLevelOrRecursive topLevelOrRecursive)
        {
            List <string> toReturn = new List <string>();

            GetFilesReferencedBy(absoluteName, topLevelOrRecursive, listToFill: toReturn);


            return(toReturn);
        }
Exemple #4
0
        public List <string> GetFilesNeededOnDiskBy(string absoluteName, EditorObjects.Parsing.TopLevelOrRecursive topLevelOrRecursive)
        {
            List <string> topLevelOnly   = null;
            bool          handledByCache = false;

            string standardized = FileManager.Standardize(absoluteName);

            if (filesNeededOnDisk.ContainsKey(standardized))
            {
                // compare dates:
                bool isOutOfDate = File.Exists(standardized) &&
                                   //File.GetLastWriteTime(standardized) > filesNeededOnDisk[standardized].LastWriteTime;
                                   // Do a != in case the user reverts a file
                                   File.GetLastWriteTime(standardized) != filesNeededOnDisk[standardized].LastWriteTime;

                if (!isOutOfDate)
                {
                    handledByCache = true;
                    topLevelOnly   = filesNeededOnDisk[standardized].References;
                }
            }

            if (!handledByCache)
            {
                // todo: do we want to change this to use
                topLevelOnly = ContentParser.GetFilesReferencedByAsset(absoluteName, TopLevelOrRecursive.TopLevel);
                PluginManager.GetFilesNeededOnDiskBy(absoluteName, TopLevelOrRecursive.TopLevel, topLevelOnly);
                // let's remove ../ if we can:
                for (int i = 0; i < topLevelOnly.Count; i++)
                {
                    topLevelOnly[i] = FlatRedBall.IO.FileManager.RemoveDotDotSlash(topLevelOnly[i]);
                }

                filesNeededOnDisk[standardized] = new FileReferenceInformation
                {
                    LastWriteTime = File.Exists(standardized) ? File.GetLastWriteTime(standardized) : DateTime.MinValue,
                    References    = topLevelOnly
                };
            }


            List <string> toReturn = new List <string>();

            toReturn.AddRange(topLevelOnly);

            if (topLevelOrRecursive == TopLevelOrRecursive.Recursive)
            {
                foreach (var item in topLevelOnly)
                {
                    toReturn.AddRange(GetFilesNeededOnDiskBy(item, TopLevelOrRecursive.Recursive));
                }
            }

            return(toReturn);
        }
Exemple #5
0
 public IEnumerable <FilePath> GetFilePathsReferencedBy(string absoluteName, EditorObjects.Parsing.TopLevelOrRecursive topLevelOrRecursive)
 {
     return(GetFilesReferencedBy(absoluteName, topLevelOrRecursive).Select(item => new FilePath(item)));
 }
Exemple #6
0
        public IEnumerable <FilePath> GetFilePathsReferencedBy(ReferencedFileSave file, EditorObjects.Parsing.TopLevelOrRecursive topLevelOrRecursive)
        {
            var absolute = GlueCommands.GetAbsoluteFileName(file);

            return(GetFilesReferencedBy(absolute, topLevelOrRecursive).Select(item => new FilePath(item)));
        }
Exemple #7
0
        public IEnumerable <string> GetFilesReferencedBy(ReferencedFileSave file, EditorObjects.Parsing.TopLevelOrRecursive topLevelOrRecursive)
        {
            var absolute = GlueCommands.GetAbsoluteFileName(file);

            return(GetFilesReferencedBy(absolute, topLevelOrRecursive));
        }
Exemple #8
0
 public IEnumerable <string> GetFilesReferencedBy(string absoluteName, EditorObjects.Parsing.TopLevelOrRecursive topLevelOrRecursive)
 {
     return(FileReferenceManager.Self.GetFilesReferencedBy(absoluteName, topLevelOrRecursive));
 }
Exemple #9
0
        public void GetFilesReferencedBy(string absoluteName, EditorObjects.Parsing.TopLevelOrRecursive topLevelOrRecursive, List <string> listToFill)
        {
            List <string> topLevelOnly   = null;
            bool          handledByCache = false;

            string standardized = FileManager.Standardize(absoluteName);

            if (fileReferences.ContainsKey(standardized))
            {
                // compare dates:
                bool isOutOfDate = File.Exists(standardized) &&
                                   //File.GetLastWriteTime(standardized) > fileReferences[standardized].LastWriteTime;
                                   // Do a != in case the user reverts a file
                                   File.GetLastWriteTime(standardized) != fileReferences[standardized].LastWriteTime;

                if (!isOutOfDate)
                {
                    handledByCache = true;
                    topLevelOnly   = fileReferences[standardized].References;
                }
            }

            if (!handledByCache)
            {
                bool succeeded = false;
                try
                {
                    topLevelOnly = ContentParser.GetFilesReferencedByAsset(absoluteName, TopLevelOrRecursive.TopLevel);
                    succeeded    = true;
                }
                // August 26, 2017
                // I used to have this throw an error when a file was missing, but plugins may not know to handle it, so let's just print
                // output instead
                catch (FileNotFoundException e)
                {
                    PluginManager.ReceiveError(e.ToString());
                }

                if (succeeded)
                {
                    var response = PluginManager.GetFilesReferencedBy(absoluteName, TopLevelOrRecursive.TopLevel, topLevelOnly);

                    if (response.Succeeded)
                    {
                        // let's remove ../ if we can:
                        for (int i = 0; i < topLevelOnly.Count; i++)
                        {
                            topLevelOnly[i] = FlatRedBall.IO.FileManager.RemoveDotDotSlash(topLevelOnly[i]);
                        }


                        var referenceInfo = new FileReferenceInformation
                        {
                            LastWriteTime = File.Exists(standardized) ? File.GetLastWriteTime(standardized) : DateTime.MinValue,
                            References    = topLevelOnly
                        };

                        try
                        {
                            fileReferences[standardized] = referenceInfo;
                        }
                        catch (Exception e)
                        {
                            int m = 3;
                            throw e;
                        }
                        if (FilesWithFailedGetReferenceCalls.ContainsKey(absoluteName))
                        {
                            FilesWithFailedGetReferenceCalls.Remove(absoluteName);
                        }
                    }
                    else
                    {
                        FilesWithFailedGetReferenceCalls[absoluteName] = response;

                        // todo - need to raise an event here on parse error:
                        PluginManager.HandleFileReadError(absoluteName, response);
                    }
                }
            }



            // topLevelOnly could be null if a file wasn't found
            if (topLevelOnly != null)
            {
                var newFiles = topLevelOnly.Except(listToFill).ToList();
                listToFill.AddRange(newFiles);

                if (topLevelOrRecursive == TopLevelOrRecursive.Recursive)
                {
                    foreach (var item in newFiles)
                    {
                        GetFilesReferencedBy(item, TopLevelOrRecursive.Recursive, listToFill);
                    }
                }
            }
        }