private void writeBattery(WriteHandleRequest request) { Handle handle = this.kernelStorage.handles[request.handle]; ((Battery)handle).setStatus(request.bytesToWrite[0]); Resource response = new WriteHandleResponse(this.id, 0, 4, request.createdByProcess); this.kernelStorage.resources.add(response); request.release(); }
private void writeHandle(WriteHandleRequest request) { Handle handle = this.kernelStorage.handles[request.handle]; Resource response; if (handle is Battery) { writeBattery(request); return; } setDevice(handle, 1); uint amountWritten = 0; try { for (uint i = 0; i < request.bytesToWrite.Length; i++) { amountWritten++; handle.write(request.bytesToWrite[i]); } response = new WriteHandleResponse(this.id, 0, amountWritten, request.createdByProcess); } catch (Exception e) { if (!e.Message.Contains("Writing file out of bounds")) { throw e; } response = new WriteHandleResponse(this.id, 1, amountWritten, request.createdByProcess); } setDevice(handle, 0); kernelStorage.resources.add(response); request.release(); }