renameAsync method
Implementation
Future<void> renameAsync(String desiredName, NameCollisionOption option) {
final retValuePtr = calloc<COMObject>();
final completer = Completer<void>();
final desiredNameHstring = convertToHString(desiredName);
final hr =
ptr.ref.vtable
.elementAt(7)
.cast<
Pointer<
NativeFunction<
HRESULT Function(Pointer, IntPtr desiredName,
Int32 option, Pointer<COMObject>)>>>()
.value
.asFunction<
int Function(Pointer, int desiredName, int option,
Pointer<COMObject>)>()(
ptr.ref.lpVtbl, desiredNameHstring, option.value, retValuePtr);
if (FAILED(hr)) {
free(retValuePtr);
throw WindowsException(hr);
}
WindowsDeleteString(desiredNameHstring);
final asyncAction = IAsyncAction.fromRawPointer(retValuePtr);
completeAsyncAction(asyncAction, completer);
return completer.future;
}