/// <summary> /// Returns true if this is a namespace that should be added to this. /// </summary> /// <param name="name"></param> /// <returns></returns> public bool CheckIfNameIsInPackage(ArkNamespace name) { //This behaves very differently if this is a mod or not if (isMod) { //Only namespaces inside of the Mods/{id}/ folder are OK return(name.fullName.StartsWith("/Game/Mods/" + id + "/")); } else { //We allow everything BUT a mod that isn't a system mod if (name.fullName.StartsWith("/Game/Mods/")) { //We'll have to check if this is a system mod string modId = name.fullName.Substring("/Game/Mods/".Length); if (modId.Contains('/')) { modId = modId.Substring(0, modId.IndexOf('/')); } if (modId.Length == 0) { return(true); //We'll scan subdirs } return(Program.config.system_mods.Contains(modId)); } else { //This will always be permitted. return(true); } } }
/// <summary> /// Gets the asset from a filesystem folder path. /// </summary> /// <param name="path"></param> /// <param name="parent"></param> /// <returns></returns> public static ArkAsset GetAssetFromFolderPath(string path, ArkInstall install) { //Get the fileinfo FileInfo info = new FileInfo(path); //Get the parent namespace ArkNamespace parent = ArkNamespace.GetNamespaceFromFolderPath(info.Directory.FullName, install); //Create object ArkAsset a = new ArkAsset { info = info, filename = path, parent = parent, installation = install }; //Get the name without the extension if (info.Name.Contains(".")) { a.name = info.Name.Substring(0, info.Name.LastIndexOf('.')); a.extension = info.Name.Substring(a.name.Length + 1); } else { a.name = info.Name; a.extension = ""; } //Set name a.fullName = parent.fullName + a.name; return(a); }
/// <summary> /// Returns children namespaces /// </summary> /// <returns></returns> public List <ArkNamespace> GetChildren() { List <ArkNamespace> children = new List <ArkNamespace>(); string[] paths = Directory.GetDirectories(contentFolder); foreach (var p in paths) { children.Add(ArkNamespace.GetNamespaceFromFolderPath(p, this)); } return(children); }
/// <summary> /// Gets a namespace from a folder path. /// </summary> /// <param name="path"></param> /// <param name="install"></param> /// <returns></returns> public static ArkNamespace GetNamespaceFromFolderPath(string path, ArkInstall install) { //Get the directory info DirectoryInfo info = new DirectoryInfo(path); //Find root names DirectoryInfo lastParent = info.Parent; List <string> rootNames = new List <string>(); while (lastParent.FullName != install.dir.FullName) { rootNames.Add(lastParent.Name); lastParent = lastParent.Parent; } rootNames.Reverse(); //Reverse so that we match the direction we said //Create the full name string fullName = "/Game/"; foreach (var s in rootNames) { fullName += s + "/"; } fullName += info.Name + "/"; //Make data ArkNamespace n = new ArkNamespace { dir = info, name = info.Name, installation = install, roots = rootNames.ToArray(), fullName = fullName, pathname = path }; return(n); }