Skip to content

Commit a63ff68

Browse files
d2dyno10x5bfa
andauthored
Apply suggestions from code review
Co-authored-by: 0x5BFA <[email protected]>
1 parent bc5f489 commit a63ff68

File tree

4 files changed

+11
-36
lines changed

4 files changed

+11
-36
lines changed

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

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -952,20 +952,20 @@ public static unsafe bool SetCompressionAttributeIoctl(string lpFileName, bool i
952952
return false;
953953

954954
uint bytesReturned = 0u;
955-
var compressionFormat = isCompressed
956-
? Win32PInvoke.COMPRESSION_FORMAT_DEFAULT
957-
: Win32PInvoke.COMPRESSION_FORMAT_NONE;
955+
COMPRESSION_FORMAT compressionFormat = isCompressed
956+
? COMPRESSION_FORMAT.COMPRESSION_FORMAT_DEFAULT
957+
: COMPRESSION_FORMAT.COMPRESSION_FORMAT_NONE;
958958

959959
var result = PInvoke.DeviceIoControl(
960960
new(hFile.DangerousGetHandle()),
961-
Win32PInvoke.FSCTL_SET_COMPRESSION,
961+
(uint)FSCTL_SET_COMPRESSION,
962962
&compressionFormat,
963963
sizeof(ushort),
964-
(void*)IntPtr.Zero,
964+
null,
965965
0u,
966966
&bytesReturned);
967967

968-
if (result.Value == 0)
968+
if (!result)
969969
return false;
970970

971971
return true;

src/Files.App/ViewModels/Properties/Items/CombinedProperties.cs

Lines changed: 3 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -173,23 +173,10 @@ private void ViewModel_PropertyChanged(object sender, System.ComponentModel.Prop
173173

174174
case "IsContentCompressed":
175175
{
176-
if (ViewModel.IsContentCompressed is not null)
176+
List.ForEach(x =>
177177
{
178-
if (ViewModel.IsContentCompressed ?? false)
179-
{
180-
List.ForEach(x =>
181-
{
182-
Win32Helper.SetCompressionAttributeIoctl(x.ItemPath, true);
183-
});
184-
}
185-
else
186-
{
187-
List.ForEach(x =>
188-
{
189-
Win32Helper.SetCompressionAttributeIoctl(x.ItemPath, false);
190-
});
191-
}
192-
}
178+
Win32Helper.SetCompressionAttributeIoctl(x.ItemPath, ViewModel.IsContentCompressed ?? false);
179+
});
193180
}
194181
break;
195182
}

src/Files.App/ViewModels/Properties/Items/FolderProperties.cs

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -215,13 +215,7 @@ private async void ViewModel_PropertyChanged(object sender, System.ComponentMode
215215
break;
216216

217217
case "IsContentCompressed":
218-
if (ViewModel.IsContentCompressed is not null)
219-
{
220-
if ((bool)ViewModel.IsContentCompressed)
221-
Win32Helper.SetCompressionAttributeIoctl(Item.ItemPath, true);
222-
else
223-
Win32Helper.SetCompressionAttributeIoctl(Item.ItemPath, false);
224-
}
218+
Win32Helper.SetCompressionAttributeIoctl(Item.ItemPath, ViewModel.IsContentCompressed ?? false);
225219
break;
226220

227221
case "ShortcutItemPath":

src/Files.App/ViewModels/Properties/Items/LibraryProperties.cs

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -164,13 +164,7 @@ private void ViewModel_PropertyChanged(object sender, System.ComponentModel.Prop
164164
break;
165165

166166
case "IsContentCompressed":
167-
if (ViewModel.IsContentCompressed is not null)
168-
{
169-
if ((bool)ViewModel.IsContentCompressed)
170-
Win32Helper.SetCompressionAttributeIoctl(Library.ItemPath, true);
171-
else
172-
Win32Helper.SetCompressionAttributeIoctl(Library.ItemPath, false);
173-
}
167+
Win32Helper.SetCompressionAttributeIoctl(Item.ItemPath, ViewModel.IsContentCompressed ?? false);
174168
break;
175169
}
176170
}

0 commit comments

Comments
 (0)