Example #1
0
        private void UpdatePartialGame(GameInstall installer)
        {
            IDirectory gameDir        = FileSystem.Current.GetDirectory(Resources.GameBaseDir);
            IDirectory gameContentDir = FileSystem.Current.GetDirectory(FileSystem.Combine(Resources.GameBaseDir, Resources.ContentDir));
            IDirectory gameModulesDir = FileSystem.Current.GetDirectory(FileSystem.Combine(Resources.GameBaseDir, Resources.BinDir));

            //only allow files/dirs inside the modules/content directories to be removed by the removal process.
            foreach (string s in installer.Update.RemoveFiles)
            {
                IFile file = FileSystem.Current.GetFile(FileSystem.Combine(gameDir.FullName, s));
                if (file.Exists && (ExistsInsideGameDirectory(file, gameContentDir) || ExistsInsideGameDirectory(file, gameModulesDir)))
                {
                    file.DeleteWithTimeout();
                    continue;
                }

                IDirectory dir = FileSystem.Current.GetDirectory(FileSystem.Combine(gameDir.FullName, s));
                if (dir.Exists && (ExistsInsideGameDirectory(dir, gameContentDir) || ExistsInsideGameDirectory(dir, gameModulesDir)))
                {
                    dir.DeleteWithTimeout();
                }
            }

            UpdateFullGame(installer);
        }
Example #2
0
 private static bool ExistsInsideGameDirectory(IFile file, IDirectory parent)
 {
     IDirectory dir = file.Parent;
     while (dir != null)
     {
         if (dir.FullName == parent.FullName) return true;
         dir = dir.Parent;
     }
     return false;
 }
Example #3
0
        private static bool ExistsInsideGameDirectory(IFile file, IDirectory parent)
        {
            IDirectory dir = file.Parent;

            while (dir != null)
            {
                if (dir.FullName == parent.FullName)
                {
                    return(true);
                }
                dir = dir.Parent;
            }
            return(false);
        }