Skip to content
This repository was archived by the owner on Feb 22, 2023. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Update to win32 nullsafety.8
  • Loading branch information
stuartmorgan-g committed Jan 21, 2021
commit ff6bb71e764cd3998c0a3a6d11c3dae959e1235d
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,12 @@ class VersionInfoQuerier {
const kEnUsLanguageCode = '040904e4';
final keyPath = TEXT('\\StringFileInfo\\$kEnUsLanguageCode\\$key');
final length = allocate<Uint32>();
final valueAddress = allocate<IntPtr>();
final valueAddress = allocate<Pointer<Utf16>>();
try {
if (VerQueryValue(versionInfo, keyPath, valueAddress, length) == 0) {
return null;
}
return Pointer<Utf16>.fromAddress(valueAddress.value)
.unpackString(length.value);
return valueAddress.value.unpackString(length.value);
} finally {
free(keyPath);
free(length);
Expand Down Expand Up @@ -116,14 +115,12 @@ class PathProviderWindows extends PathProviderPlatform {
/// folderID is a GUID that represents a specific known folder ID, drawn from
/// [WindowsKnownFolder].
Future<String> getPath(String folderID) {
final pathPtrPtr = allocate<IntPtr>();
late Pointer<Utf16> pathPtr;
final pathPtrPtr = allocate<Pointer<Utf16>>();
final Pointer<GUID> knownFolderID = calloc<GUID>()..setGUID(folderID);;

try {
GUID knownFolderID = GUID.fromString(folderID);

final hr = SHGetKnownFolderPath(
knownFolderID.addressOf, // ignore: deprecated_member_use
knownFolderID,
KF_FLAG_DEFAULT,
NULL,
pathPtrPtr,
Expand All @@ -135,12 +132,11 @@ class PathProviderWindows extends PathProviderPlatform {
}
}

pathPtr = Pointer<Utf16>.fromAddress(pathPtrPtr.value);
final path = pathPtr.unpackString(MAX_PATH);
final path = pathPtrPtr.value.unpackString(MAX_PATH);
return Future.value(path);
} finally {
CoTaskMemFree(pathPtr.cast());
free(pathPtrPtr);
free(knownFolderID);
}
}

Expand Down
2 changes: 1 addition & 1 deletion packages/path_provider/path_provider_windows/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ dependencies:
flutter:
sdk: flutter
ffi: ^0.2.0-nullsafety.1
win32: 2.0.0-nullsafety.7
win32: ^2.0.0-nullsafety.8

dev_dependencies:
flutter_test:
Expand Down