public static hlPackageCreateStream ( IntPtr pItem, IntPtr &pStream ) : bool | ||
pItem | IntPtr | |
pStream | IntPtr | |
리턴 | bool |
public static void ReadScriptFromVPK <T>(string filePath, List <T> ListToInsert) where T : DotaDataObject { IntPtr root = HLLib.hlPackageGetRoot(); IntPtr file = HLLib.hlFolderGetItemByPath(root, filePath, HLLib.HLFindType.HL_FIND_FILES); IntPtr stream; ErrorCheck(HLLib.hlPackageCreateStream(file, out stream)); string unitsText = ReadTextFromHLLibStream(stream); KeyValue rootkv = KVLib.KVParser.KV1.Parse(unitsText); foreach (KeyValue kv in rootkv.Children) { if (!kv.HasChildren) { continue; //Get rid of that pesky "Version" "1" key } T unit = typeof(T).GetConstructor(new Type[] { typeof(KeyValue) }).Invoke(new object[] { kv }) as T; unit.ObjectInfo.FromVPK = true; unit.ObjectInfo.ObjectClass = DotaDataObject.DataObjectInfo.ObjectDataClass.Default; unit.ObjectInfo.OriginatingFile = filePath; ListToInsert.Add(unit); } return; }
public static string ReadAllText(string filePath) { IntPtr root = HLLib.hlPackageGetRoot(); IntPtr file = HLLib.hlFolderGetItemByPath(root, filePath, HLLib.HLFindType.HL_FIND_FILES); IntPtr stream; ErrorCheck(HLLib.hlPackageCreateStream(file, out stream)); string text = ReadTextFromHLLibStream(stream); return(text); }
public string ReadTextFromVPK(string path) { IntPtr root = HLLib.hlPackageGetRoot(); IntPtr file = HLLib.hlFolderGetItemByPath(root, path, HLLib.HLFindType.HL_FIND_FILES); IntPtr stream; if (ErrorCheck(HLLib.hlPackageCreateStream(file, out stream))) { return("Unable to Load File".Localize()); } string text = ReadTextFromHLLibStream(stream); return(text); }