Ejemplo n.º 1
0
        public unsafe void Execute(FileWriteResult target)
        {
            target.Pin(buffer.Data);

            Overlapped overlapped = new Overlapped
            {
                AsyncResult = target,
                OffsetLow   = (int)(target.Position & 0xffffffff),
                OffsetHigh  = (int)((target.Position >> 32) & 0xffffffff)
            };

            NativeOverlapped *native = overlapped.UnsafePack(null, null);
            IntPtr            array  = Marshal.UnsafeAddrOfPinnedArrayElement(buffer.Data, buffer.Offset);

            int  read;
            int  result = FileInterop.WriteFile(handle, array, buffer.Count, out read, native);
            uint error  = FileInterop.GetLastError();

            if (result == 0 && error != 997)
            {
                target.Fail(error);
            }

            if (result == 1)
            {
                target.Complete(native, read);
            }
        }
Ejemplo n.º 2
0
        public File OpenOrCreate(string path)
        {
            IntPtr handle = FileInterop.CreateFile(path, 0x80000000 | 0x40000000, 0x01 | 0x02, IntPtr.Zero, 0x04, 0x40000000 | 0x00000080, IntPtr.Zero);
            uint   error  = FileInterop.GetLastError();

            worker.Add(handle);

            return(new FileInstance(handle, worker));
        }
Ejemplo n.º 3
0
 public void Fail()
 {
     Fail(FileInterop.GetLastError());
 }