Skip to content
This repository was archived by the owner on Feb 22, 2023. It is now read-only.

[path_provider_windows] Update to ffi 2.0.0 #5853

Merged
merged 7 commits into from
May 28, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
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
12 changes: 10 additions & 2 deletions packages/path_provider/path_provider_linux/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 2.1.7

* Bumps ffi dependency to match path_provider_windows.

## 2.1.6

* Fixes library_private_types_in_public_api, sort_child_properties_last and use_key_in_widget_constructors
Expand Down Expand Up @@ -54,20 +58,24 @@

* Check in linux/ directory for example/

## 0.1.1 - NOT PUBLISHED
## 0.1.1 - NOT PUBLISHED

* Reverts changes on 0.1.0, which broke the tree.

## 0.1.0 - NOT PUBLISHED

## 0.1.0 - NOT PUBLISHED
* This release updates getApplicationSupportPath to use the application ID instead of the executable name.
* No migration is provided, so any older apps that were using this path will now have a different directory.

## 0.0.1+2

* This release updates the example to depend on the endorsed plugin rather than relative path

## 0.0.1+1

* This updates the readme and pubspec and example to reflect the endorsement of this implementation of `path_provider`

## 0.0.1

* The initial implementation of path\_provider for Linux
* Implements getApplicationSupportPath, getApplicationDocumentsPath, getDownloadsPath, and getTemporaryPath
4 changes: 2 additions & 2 deletions packages/path_provider/path_provider_linux/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: path_provider_linux
description: Linux implementation of the path_provider plugin
repository: https://github.com/flutter/plugins/tree/main/packages/path_provider/path_provider_linux
issue_tracker: https://github.com/flutter/flutter/issues?q=is%3Aissue+is%3Aopen+label%3A%22p%3A+path_provider%22
version: 2.1.6
version: 2.1.7

environment:
sdk: ">=2.12.0 <3.0.0"
Expand All @@ -16,7 +16,7 @@ flutter:
dartPluginClass: PathProviderLinux

dependencies:
ffi: ^1.1.2
ffi: ">=1.1.2 <3.0.0"
flutter:
sdk: flutter
path: ^1.8.0
Expand Down
5 changes: 3 additions & 2 deletions packages/path_provider/path_provider_windows/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
## 2.0.7
## 2.1.0

* Added support for unicode encoded VERSIONINFO
* Upgrades `package:ffi` dependency to 2.0.0.
* Added support for unicode encoded VERSIONINFO.
* Minor fixes for new analysis options.

## 2.0.6
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@
list(APPEND FLUTTER_PLUGIN_LIST
)

list(APPEND FLUTTER_FFI_PLUGIN_LIST
)

set(PLUGIN_BUNDLED_LIBRARIES)

foreach(plugin ${FLUTTER_PLUGIN_LIST})
Expand All @@ -13,3 +16,8 @@ foreach(plugin ${FLUTTER_PLUGIN_LIST})
list(APPEND PLUGIN_BUNDLED_LIBRARIES $<TARGET_FILE:${plugin}_plugin>)
list(APPEND PLUGIN_BUNDLED_LIBRARIES ${${plugin}_bundled_libraries})
endforeach(plugin)

foreach(ffi_plugin ${FLUTTER_FFI_PLUGIN_LIST})
add_subdirectory(flutter/ephemeral/.plugin_symlinks/${ffi_plugin}/windows plugins/${ffi_plugin})
list(APPEND PLUGIN_BUNDLED_LIBRARIES ${${ffi_plugin}_bundled_libraries})
endforeach(ffi_plugin)
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ class VersionInfoQuerier {
}
final Pointer<Utf16> keyPath =
TEXT('\\StringFileInfo\\$language$encoding\\$key');
final Pointer<Uint32> length = calloc<Uint32>();
final Pointer<UINT> length = calloc<UINT>();
final Pointer<Pointer<Utf16>> valueAddress = calloc<Pointer<Utf16>>();
try {
if (VerQueryValue(versionInfo, keyPath, valueAddress, length) == 0) {
Expand Down Expand Up @@ -192,10 +192,9 @@ class PathProviderWindows extends PathProviderPlatform {
String? companyName;
String? productName;

final Pointer<Utf16> moduleNameBuffer =
calloc<Uint16>(MAX_PATH + 1).cast<Utf16>();
final Pointer<Uint32> unused = calloc<Uint32>();
Pointer<Uint8>? infoBuffer;
final Pointer<Utf16> moduleNameBuffer = wsalloc(MAX_PATH + 1);
final Pointer<DWORD> unused = calloc<DWORD>();
Pointer<BYTE>? infoBuffer;
try {
// Get the module name.
final int moduleNameLength =
Expand All @@ -208,7 +207,7 @@ class PathProviderWindows extends PathProviderPlatform {
// From that, load the VERSIONINFO resource
final int infoSize = GetFileVersionInfoSize(moduleNameBuffer, unused);
if (infoSize != 0) {
infoBuffer = calloc<Uint8>(infoSize);
infoBuffer = calloc<BYTE>(infoSize);
if (GetFileVersionInfo(moduleNameBuffer, 0, infoSize, infoBuffer) ==
0) {
calloc.free(infoBuffer);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we still need the manual frees? I was hoping finalize support would let us simplify all this code, but I haven't followed the details of adoption in FFI.

Copy link
Contributor Author

@timsneath timsneath May 28, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, we do for now, unfortunately. The reason for the package:ffi version bump is to allow us to use a different memory allocation API for Windows, which should in principle us to use NativeFinalizer moving forward. This is the prerequisite to that.

Expand Down
8 changes: 4 additions & 4 deletions packages/path_provider/path_provider_windows/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@ name: path_provider_windows
description: Windows implementation of the path_provider plugin
repository: https://github.com/flutter/plugins/tree/main/packages/path_provider/path_provider_windows
issue_tracker: https://github.com/flutter/flutter/issues?q=is%3Aissue+is%3Aopen+label%3A%22p%3A+path_provider%22
version: 2.0.7
version: 2.1.0

environment:
sdk: ">=2.12.0 <3.0.0"
flutter: ">=2.8.0"
sdk: ">=2.17.0 <3.0.0"
flutter: ">=3.0.0"

flutter:
plugin:
Expand All @@ -16,7 +16,7 @@ flutter:
dartPluginClass: PathProviderWindows

dependencies:
ffi: ^1.0.0
ffi: ^2.0.0
flutter:
sdk: flutter
path: ^1.8.0
Expand Down