internal GDFEntry(GDFImage xIn) { DJsIO xIO = xIn.xIO; entryoffset = xIO.Position; xStartBlock = xIO.ReadUInt32(false); xSize = xIO.ReadInt32(false); Atts = (GDFAttributes)xIO.ReadByte(); byte nlen = xIO.ReadByte(); if (nlen != 0xFF) { xName = xIO.ReadString(StringForm.ASCII, nlen); } if (!VariousFunctions.IsValidXboxName(xName)) { throw new Exception("Invalid Name"); } xref = xIn; }
/// <summary> /// Adds a folder /// </summary> /// <param name="FolderPath"></param> /// <returns></returns> public bool AddFolder(string FolderPath) { if (string.IsNullOrEmpty(FolderPath)) { return(false); } FolderPath = FolderPath.xExtractLegitPath(); if (string.IsNullOrEmpty(FolderPath)) { return(false); } int idx = FolderPath.LastIndexOf('/'); string name = ""; if (idx == -1) { name = FolderPath; } else { name = FolderPath.Substring(idx + 1, FolderPath.Length - 1 - idx); string parentpath = FolderPath.Substring(0, idx); if (!containspath(parentpath)) { return(false); } } if (containspath(FolderPath)) { return(false); } if (!VariousFunctions.IsValidXboxName(name)) { return(false); } xFolderDirectory.Add(new CFolderEntry(FolderPath, this)); return(true); }
/// <summary> /// Get a file from a path /// </summary> /// <param name="Path"></param> /// <param name="Parent"></param> /// <returns></returns> public GDFFile GetFile(string Path, out GDFFolder Parent) { Parent = null; if (!ActiveCheck()) { return(null); } if (Path == null || Path == "") { xActive = false; return(null); } Path = Path.xExtractLegitPath(); var folders = Path.Split('/').ToList(); foreach (string x in folders) { if (!VariousFunctions.IsValidXboxName(x)) { xActive = false; return(null); } } string file = folders[folders.Count - 1]; folders.RemoveAt(folders.Count - 1); Parent = Root; bool found = false; for (int i = 0; i < folders.Count; i++) { GDFContents xRead = Parent.xRead(); found = false; foreach (GDFFolder x in xRead.xFolders) { if (x.Name.ToLower() == folders[i].ToLower()) { Parent = x; found = true; break; } } if (!found) { Parent = null; xActive = false; return(null); } } GDFContents rd = Parent.xRead(); foreach (GDFFile x in rd.xFiles) { if (x.Name.ToLower() == file.ToLower()) { xActive = false; return(x); } } xActive = false; return(null); }