From 2797aa9c9980ccb4cb2e564a40376371dc0a89df Mon Sep 17 00:00:00 2001 From: Chris Bracken Date: Thu, 1 Apr 2021 23:34:59 -0700 Subject: [PATCH] Add fallback for GetAbsoluteFilePath in UWP (flutter/engine#25379) In UWP, GetFinalPathNameByHandle requires the app to declare appropriate capabilities in the app's package manifest. Some of these capabilities are not permitted in shipping apps on the app store, but may be fine for development/debugging scenarios. If we can't resolve the full path due to insufficient access, but have verified the handle is valid, return the original path. This gets hot reload requests working in the UWP embedder. https://github.com/flutter/flutter/issues/79609 --- .../tonic/filesystem/filesystem/path_win.cc | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/engine/src/flutter/third_party/tonic/filesystem/filesystem/path_win.cc b/engine/src/flutter/third_party/tonic/filesystem/filesystem/path_win.cc index 9b74f07a3d0..d0f378f9a5f 100644 --- a/engine/src/flutter/third_party/tonic/filesystem/filesystem/path_win.cc +++ b/engine/src/flutter/third_party/tonic/filesystem/filesystem/path_win.cc @@ -215,8 +215,20 @@ std::string GetAbsoluteFilePath(const std::string& path) { DWORD ret = GetFinalPathNameByHandleA(file, buffer, MAX_PATH, FILE_NAME_NORMALIZED); if (ret == 0 || ret > MAX_PATH) { + std::string result; + if (GetLastError() == ERROR_ACCESS_DENIED) { + // In UWP, GetFinalPathNameByHandle requires the app to declare + // appropriate capabilities in the app's package manifest. Some of these + // capabilities are not permitted in shipping apps on the app store, but + // may be fine for development/debugging scenarios. If we can't resolve + // the full path due to insufficient access, but have verified the handle + // is valid, return AbsolutePath of the original path. + // + // https://github.com/flutter/flutter/issues/79609 + result = AbsolutePath(path); + } CloseHandle(file); - return std::string(); + return result; } std::string result(buffer); result.erase(0, strlen("\\\\?\\"));