Some games (such as Digimon Survive) create temporary video files and will hang if deleting them fails. Open the files with FILE_SHARE_DELETE, which will allow this deletion to go ahead even if the FileSource hasn't yet been closed.
Note that many windows codec packs do themselves open files without FILE_SHARE_DELETE, so a similar hang can be observed in some windows configurations.
I haven't checked that this is the file share mode used on windows (alas, I don't have a windows machine available), so I haven't removed the FIXME comment. Equally, I also updated the CreateFileW() call in get_media_type(), but that _may_ be unnecessary.
I've added a basic test, but haven't had the opportunity to run it on Windows yet.
Otherwise, this patch is also available against Proton Experimental here: https://github.com/ValveSoftware/wine/pull/156
It also has been confirmed to fix the issue with Digimon Survive independently: https://github.com/ValveSoftware/Proton/issues/6041#issuecomment-1200486581
From: David Gow david@ingeniumdigital.com
Some games (such as Digimon Survive) create temporary video files and will hang if deleting them fails. Open the files with FILE_SHARE_DELETE, which will allow this deletion to go ahead even if the FileSource hasn't yet been closed.
Note that many windows codec packs do themselves open files without FILE_SHARE_DELETE, so a similar hang can be observed in some windows configurations.
I haven't checked that this is the file share mode used on windows (alas, I don't have a windows machine available), so I haven't removed the FIXME comment. Equally, I also updated the CreateFileW() call in get_media_type(), but that _may_ be unnecessary.
Signed-off-by: David Gow david@ingeniumdigital.com --- dlls/quartz/filesource.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/dlls/quartz/filesource.c b/dlls/quartz/filesource.c index 6ffae606df4..0579f564af7 100644 --- a/dlls/quartz/filesource.c +++ b/dlls/quartz/filesource.c @@ -214,7 +214,7 @@ BOOL get_media_type(const WCHAR *filename, GUID *majortype, GUID *subtype, GUID } }
- if ((file = CreateFileW(filename, GENERIC_READ, FILE_SHARE_READ, NULL, + if ((file = CreateFileW(filename, GENERIC_READ, FILE_SHARE_READ | FILE_SHARE_DELETE, NULL, OPEN_EXISTING, 0, NULL)) == INVALID_HANDLE_VALUE) { WARN("Failed to open file %s, error %lu.\n", debugstr_w(filename), GetLastError()); @@ -464,7 +464,7 @@ static HRESULT WINAPI FileSource_Load(IFileSourceFilter * iface, LPCOLESTR pszFi
/* open file */ /* FIXME: check the sharing values that native uses */ - hFile = CreateFileW(pszFileName, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_FLAG_OVERLAPPED, NULL); + hFile = CreateFileW(pszFileName, GENERIC_READ, FILE_SHARE_READ | FILE_SHARE_DELETE, NULL, OPEN_EXISTING, FILE_FLAG_OVERLAPPED, NULL);
if (hFile == INVALID_HANDLE_VALUE) {
From: David Gow david@ingeniumdigital.com
Some games (such as Digimon Survive) will delete a file while it's open as a FileSource.
Signed-off-by: David Gow david@ingeniumdigital.com --- dlls/quartz/tests/filesource.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+)
diff --git a/dlls/quartz/tests/filesource.c b/dlls/quartz/tests/filesource.c index c383d9f6579..268b265ac77 100644 --- a/dlls/quartz/tests/filesource.c +++ b/dlls/quartz/tests/filesource.c @@ -1476,6 +1476,24 @@ static void test_connect_pin(void) ok(ret, "Failed to delete file, error %lu.\n", GetLastError()); }
+static void test_file_share_delete(void) +{ + const WCHAR *filename = load_resource(L"test.avi"); + IBaseFilter *filter = create_file_source(); + ULONG ref; + BOOL ret; + + load_file(filter, filename); + + /* Test that we can delete the file while it's open. */ + ret = DeleteFileW(filename); + ok(ret, "Failed to delete file, error %lu.\n", GetLastError()); + + ref = IBaseFilter_Release(filter); + ok(!ref, "Got outstanding refcount %ld.\n", ref); +} + + START_TEST(filesource) { CoInitialize(NULL); @@ -1490,6 +1508,7 @@ START_TEST(filesource) test_async_reader(); test_enum_media_types(); test_connect_pin(); + test_file_share_delete();
CoUninitialize(); }
This merge request was approved by Zebediah Figura.