public static void GenerateModuleList() { IgorModuleList NewInst = new IgorModuleList(); IgorModuleList.ModuleItem NewItem = new IgorModuleList.ModuleItem(); NewItem.ModuleName = "Core.Core"; NewItem.ModuleDescriptorRelativePath = "Core/Core/Core.mod"; NewInst.Modules.Add(NewItem); NewInst.Save(IgorModulesListFilename); }
public static bool UpdateModule(string ModuleName, bool ForceUpdate) { bool bUpdated = false; if (File.Exists(InstalledModulesListPath)) { SharedModuleListInst = IgorModuleList.Load(InstalledModulesListPath); } if (SharedModuleListInst != null) { foreach (IgorModuleList.ModuleItem CurrentModule in SharedModuleListInst.Modules) { if (CurrentModule.ModuleName == ModuleName) { string ModuleDescriptor = IgorUtils.DownloadFileForUpdate(RemoteRelativeModuleRoot + CurrentModule.ModuleDescriptorRelativePath); string CurrentModuleDescriptor = Path.Combine(LocalModuleRoot, CurrentModule.ModuleDescriptorRelativePath); if (File.Exists(ModuleDescriptor)) { IgorModuleDescriptor CurrentModuleDescriptorInst = null; IgorModuleDescriptor NewModuleDescriptorInst = IgorModuleDescriptor.Load(ModuleDescriptor); if (File.Exists(CurrentModuleDescriptor)) { CurrentModuleDescriptorInst = IgorModuleDescriptor.Load(CurrentModuleDescriptor); } if (NewModuleDescriptorInst != null) { if (UpdatedModules.Contains(NewModuleDescriptorInst.ModuleName)) { return(false); } UpdatedModules.Add(NewModuleDescriptorInst.ModuleName); if (NewModuleDescriptorInst.ModuleDependencies.Count > 0) { foreach (string CurrentDependency in NewModuleDescriptorInst.ModuleDependencies) { bUpdated = UpdateModule(CurrentDependency, ForceUpdate) || bUpdated; } } int NewVersion = NewModuleDescriptorInst.ModuleVersion; if (CurrentModuleDescriptorInst == null || NewVersion > CurrentModuleDescriptorInst.ModuleVersion || bAlwaysUpdate || ForceUpdate) { bUpdated = true; UpdatedContent.Add(ModuleName); List <string> FilesToDelete = new List <string>(); if (CurrentModuleDescriptorInst != null) { IgorUpdater.HelperDelegates.DeleteFile(CurrentModuleDescriptor); FilesToDelete.AddRange(CurrentModuleDescriptorInst.ModuleFiles); } if (!Directory.Exists(Path.GetDirectoryName(CurrentModuleDescriptor))) { Directory.CreateDirectory(Path.GetDirectoryName(CurrentModuleDescriptor)); } IgorUpdater.HelperDelegates.CopyFile(ModuleDescriptor, CurrentModuleDescriptor); foreach (string ModuleFile in NewModuleDescriptorInst.ModuleFiles) { FilesToDelete.Remove(ModuleFile); bool bIsExternal = false; string LocalFile = IgorUtils.GetLocalFileFromModuleFilename(ModuleFile); string FullLocalPath = Path.Combine(LocalModuleRoot, Path.Combine(Path.GetDirectoryName(CurrentModule.ModuleDescriptorRelativePath), LocalFile)); string RemotePath = IgorUtils.GetRemoteFileFromModuleFilename(RemoteRelativeModuleRoot + Path.GetDirectoryName(CurrentModule.ModuleDescriptorRelativePath) + "/", ModuleFile, ref bIsExternal); if (LocalFile.StartsWith(".")) { string Base = Path.Combine(LocalModuleRoot.Replace('/', Path.DirectorySeparatorChar), Path.GetDirectoryName(CurrentModule.ModuleDescriptorRelativePath.Replace('/', Path.DirectorySeparatorChar))); string NewLocalFile = LocalFile.Replace('/', Path.DirectorySeparatorChar); int FirstIndex = NewLocalFile.IndexOf(".." + Path.DirectorySeparatorChar); while (FirstIndex != -1) { int LastIndex = Base.LastIndexOf(Path.DirectorySeparatorChar); if (LastIndex != -1) { Base = Base.Substring(0, LastIndex); } NewLocalFile = NewLocalFile.Substring(3); FirstIndex = NewLocalFile.IndexOf(".." + Path.DirectorySeparatorChar); } FullLocalPath = Path.Combine(Base, NewLocalFile); RemotePath = IgorUtils.GetRemoteFileFromModuleFilename(RemoteRelativeModuleRoot + Path.GetDirectoryName(CurrentModule.ModuleDescriptorRelativePath) + "/", ModuleFile, ref bIsExternal); } string TempDownloadPath = ""; if (bIsExternal) { if (!bLocalDownload || bDownloadRemoteWhenLocal || !File.Exists(FullLocalPath)) { if (LocalFile.Contains("../")) { TempDownloadPath = IgorUtils.DownloadFileForUpdate(FullLocalPath, RemotePath); } else { TempDownloadPath = IgorUtils.DownloadFileForUpdate(Path.Combine(Path.GetDirectoryName(CurrentModule.ModuleDescriptorRelativePath), LocalFile), RemotePath); } } } else { TempDownloadPath = IgorUtils.DownloadFileForUpdate(RemotePath); } if (TempDownloadPath != "") { if (File.Exists(FullLocalPath)) { IgorUpdater.HelperDelegates.DeleteFile(FullLocalPath); } if (!Directory.Exists(Path.GetDirectoryName(FullLocalPath))) { Directory.CreateDirectory(Path.GetDirectoryName(FullLocalPath)); } if (File.Exists(TempDownloadPath)) { IgorUpdater.HelperDelegates.CopyFile(TempDownloadPath, FullLocalPath); } } } foreach (string FilenameToDelete in FilesToDelete) { string LocalFile = IgorUtils.GetLocalFileFromModuleFilename(FilenameToDelete); string FullLocalPath = Path.Combine(LocalModuleRoot, Path.Combine(Path.GetDirectoryName(CurrentModule.ModuleDescriptorRelativePath), LocalFile)); if (File.Exists(FullLocalPath)) { IgorUpdater.HelperDelegates.DeleteFile(FullLocalPath); } } } } } return(bUpdated); } } } return(false); }