Skip to content

Commit 5390298

Browse files
committed
Fix build failures due to CsWin32 bump
1 parent 306cf96 commit 5390298

File tree

2 files changed

+13
-24
lines changed

2 files changed

+13
-24
lines changed

src/Files.App/Data/Items/AccessControlPrincipal.cs

Lines changed: 11 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -66,34 +66,27 @@ public string? FullNameHumanized
6666
public string FullNameHumanizedWithBrackes
6767
=> string.IsNullOrEmpty(Domain) ? string.Empty : $"({Domain}\\{Name})";
6868

69-
public unsafe AccessControlPrincipal(string sid)
69+
public AccessControlPrincipal(string sid)
7070
{
7171
if (string.IsNullOrEmpty(sid))
7272
return;
7373

7474
Sid = sid;
75-
PSID lpSid = default;
76-
SID_NAME_USE snu = default;
75+
PInvoke.ConvertStringSidToSid(sid, out var lpSid);
7776

78-
fixed (char* cSid = sid)
79-
PInvoke.ConvertStringSidToSid(new PCWSTR(cSid), &lpSid);
80-
81-
PWSTR lpName = default;
82-
PWSTR lpDomain = default;
77+
char[] lpName = [];
78+
char[] lpDomain = [];
8379
uint cchName = 0, cchDomainName = 0;
8480

8581
// Get size of account name and domain name
86-
bool bResult = PInvoke.LookupAccountSid(new PCWSTR(), lpSid, lpName, &cchName, lpDomain, &cchDomainName, null);
82+
bool bResult = PInvoke.LookupAccountSid(string.Empty, lpSid, lpName, ref cchName, lpDomain, ref cchDomainName, out _);
8783

8884
// Ensure requested capacity
89-
fixed (char* cName = new char[cchName])
90-
lpName = new(cName);
91-
92-
fixed (char* cDomain = new char[cchDomainName])
93-
lpDomain = new(cDomain);
85+
lpName = new char[cchName];
86+
lpDomain = new char[cchDomainName];
9487

9588
// Get account name and domain
96-
bResult = PInvoke.LookupAccountSid(new PCWSTR(), lpSid, lpName, &cchName, lpDomain, &cchDomainName, &snu);
89+
bResult = PInvoke.LookupAccountSid(string.Empty, lpSid, lpName, ref cchName, lpDomain, ref cchDomainName, out var snu);
9790
if(!bResult)
9891
return;
9992

@@ -118,16 +111,14 @@ var x when
118111
if (snu == SID_NAME_USE.SidTypeUser || snu == SID_NAME_USE.SidTypeAlias)
119112
{
120113
uint size = 256;
121-
fixed (char* cDomain = new char[size])
122-
lpDomain = new(cDomain);
123-
114+
lpDomain = new char[size];
124115
bResult = PInvoke.GetComputerName(lpDomain, ref size);
125116
if (!bResult)
126117
return;
127118
}
128119

129-
Name = lpName.ToString();
130-
Domain = lpDomain.ToString().ToLower();
120+
Name = lpName.AsSpan().ToString();
121+
Domain = lpDomain.AsSpan().ToString().ToLower();
131122

132123
IsValid = true;
133124
}

src/Files.App/Helpers/Win32/Win32Helper.Storage.cs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -949,13 +949,11 @@ public static unsafe bool CanCompressContent(string path)
949949

950950
var success = PInvoke.GetVolumeInformation(
951951
path,
952-
null,
953-
0u,
952+
[],
954953
null,
955954
null,
956955
&dwFileSystemFlags,
957-
null,
958-
0u);
956+
[]);
959957

960958
if (!success)
961959
return false;

0 commit comments

Comments
 (0)