Skip to content

Commit 973c639

Browse files
committed
Update
1 parent 0fe6984 commit 973c639

File tree

5 files changed

+256
-334
lines changed

5 files changed

+256
-334
lines changed

src/Files.App.CsWin32/NativeMethods.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,3 +142,4 @@ IInitializeWithStream
142142
IInitializeWithStreamNative
143143
IInitializeWithFile
144144
IInitializeWithItem
145+
SHCreateStreamOnFileEx
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
// Copyright (c) 2024 Files Community
2+
// Licensed under the MIT License. See the LICENSE.
3+
4+
using System;
5+
using System.Runtime.CompilerServices;
6+
using Windows.Win32;
7+
using Windows.Win32.System.Com;
8+
9+
namespace Windows.Win32
10+
{
11+
public unsafe struct ComPtr<T> : IDisposable where T : unmanaged
12+
{
13+
private T* ptr;
14+
15+
public T* Value
16+
=> this.ptr;
17+
18+
public T** Address
19+
=> (T**)Unsafe.AsPointer(ref Unsafe.AsRef(in this));
20+
21+
public bool IsNull
22+
=> ptr == default;
23+
24+
public ComPtr(T* other)
25+
{
26+
this.ptr = other;
27+
28+
if (other is not null)
29+
{
30+
_ = ((IUnknown*)other)->AddRef();
31+
}
32+
}
33+
34+
public void Dispose()
35+
{
36+
T* pointer = this.ptr;
37+
38+
if (pointer is not null)
39+
{
40+
this.ptr = null;
41+
42+
_ = ((IUnknown*)pointer)->Release();
43+
}
44+
}
45+
}
46+
}

src/Files.App/Utils/Shell/ItemStreamHelper.cs

Lines changed: 0 additions & 37 deletions
This file was deleted.

0 commit comments

Comments
 (0)