This library is an Unity Native Plugin for windows environment. You can use NativeArray<T> IO in Unity. You don't have to use byte[] any more!
Unity2018.4, 2019.1~
Supported OS : Windows(x86 and x64)
Distributed under MIT License.
This method issues async write order.
- string path
- Ooutput destination file path
- If path is null, ArgumentNullException will be thrown.
- byte* buffer
- Source pointer. This buffer's contnet should not be changed while writing to the file.
- If buffer is null, ArgumentNullException will be thrown.
- ulong offset
- The byte offset at which to start writing to the file.
- ulong length
- The byte length to write.
- If length is 0, default(IOHandle) will be returned.
Remarks This api lengthens the file size when the length argument is larger than the original size but never shortens. If you want exact length. You should assign the length to FileHandle.Length property.
Create File handle with path.
Create from IntPtr representing Win32 native FileHandle.
You can get/set the current byte length of the file.
You can get/set the file size via this field.
Check for the completion.
Wait for the completion.
You should call Dispose() after writing completion to free the native resources.
You can wait the completion of IO.
NativeArray<byte> bytesWrite;
// Some codes;
using(IOHandle handle = UniUnsafeIO.UnsafeIOManager.Write(@"a.txt", bytesWrite.GetUnsafePtr(), offset: 0, length: (ulong)bytesWrite.Length))
{
// Some work;
handle.Complete(); // Wait for Completion;
}
Or you can poll the IO operation.
NativeArray<byte> bytesWrite;
// Some codes;
using(IOHandle handle = UniUnsafeIO.UnsafeIOManager.Write(@"a.txt", bytesWrite.GetUnsafePtr(), offset: 0, length: bytesWrite.Length))
{
while(true)
{
// Some codes;
//
if(handle.IsCompleted) // Check for Completion;
{
break;
}
}
}