public static CPackage *pkg_load_file(byte *pathPtr) { var environment = new NativeEnvironment(); try { if (!TryGetExistingFilePath(pathPtr, out var path)) { return(null); } using (var stream = File.OpenRead(path)) using (var binaryReader = new BinaryReader(stream, Encoding.UTF8)) { var package = _packageReader.ReadFrom(binaryReader); var cpackage = environment.ConvertToCPackage(package); _environments[new IntPtr(cpackage)] = environment; return(cpackage); } } catch (Exception exception) { HandleException(exception); environment.Dispose(); return(null); } }
public WCList( int *count, TStruct **pointerToArrayPointer, NativeEnvironment environment, CStructToItem cStructToItemFunc) { _count = count; _pointerToArrayPointer = pointerToArrayPointer; _environment = environment; _items = new List <TItem>(); _cStructToItemFunc = cStructToItemFunc; }
public static bool TryGetEnvironment(void *pointer, out NativeEnvironment outEnvironment) { outEnvironment = null; if (pointer == null) { return(Error("Argument is a null pointer")); } if (!_environments.TryGetValue(new IntPtr(pointer), out var environment)) { return(Error("Failed to get environment for tex")); } outEnvironment = environment; return(true); }
public WCString(void **pointerToCStringPointer, NativeEnvironment environment) { _pointer = pointerToCStringPointer; _environment = environment; }