mirror of
https://github.com/Hofknecht/SystemTrayMenu.git
synced 2024-07-09 00:06:11 +12:00
Remove RowData dependency from FolderOptions
This commit is contained in:
parent
46bd18eb7e
commit
2e1cc20593
|
@ -1110,12 +1110,14 @@ namespace SystemTrayMenu.Business
|
||||||
}
|
}
|
||||||
|
|
||||||
RowData rowDataRenamed = new(isFolder, rowData.IsAdditionalItem, false, 0, path);
|
RowData rowDataRenamed = new(isFolder, rowData.IsAdditionalItem, false, 0, path);
|
||||||
if (FolderOptions.IsHidden(rowDataRenamed))
|
FolderOptions.ReadHiddenAttributes(rowDataRenamed.Path, out bool hasHiddenFlag, out bool isDirectoryToHide);
|
||||||
|
if (isDirectoryToHide)
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
IconReader.RemoveIconFromCache(rowData.Path);
|
IconReader.RemoveIconFromCache(rowData.Path);
|
||||||
|
rowDataRenamed.HiddenEntry = hasHiddenFlag;
|
||||||
rowDataRenamed.ReadIcon(true);
|
rowDataRenamed.ReadIcon(true);
|
||||||
rowDatas.Add(rowDataRenamed);
|
rowDatas.Add(rowDataRenamed);
|
||||||
}
|
}
|
||||||
|
@ -1188,11 +1190,13 @@ namespace SystemTrayMenu.Business
|
||||||
bool isFolder = (attr & FileAttributes.Directory) == FileAttributes.Directory;
|
bool isFolder = (attr & FileAttributes.Directory) == FileAttributes.Directory;
|
||||||
bool isAddionalItem = Path.GetDirectoryName(e.FullPath) != Config.Path;
|
bool isAddionalItem = Path.GetDirectoryName(e.FullPath) != Config.Path;
|
||||||
RowData rowData = new(isFolder, isAddionalItem, false, 0, e.FullPath);
|
RowData rowData = new(isFolder, isAddionalItem, false, 0, e.FullPath);
|
||||||
if (FolderOptions.IsHidden(rowData))
|
FolderOptions.ReadHiddenAttributes(rowData.Path, out bool hasHiddenFlag, out bool isDirectoryToHide);
|
||||||
|
if (isDirectoryToHide)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
rowData.HiddenEntry = hasHiddenFlag;
|
||||||
rowData.ReadIcon(true);
|
rowData.ReadIcon(true);
|
||||||
|
|
||||||
List<RowData> rowDatas = new()
|
List<RowData> rowDatas = new()
|
||||||
|
|
|
@ -18,14 +18,6 @@ namespace SystemTrayMenu.DataClasses
|
||||||
{
|
{
|
||||||
private static DateTime contextMenuClosed;
|
private static DateTime contextMenuClosed;
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Initializes a new instance of the <see cref="RowData"/> class.
|
|
||||||
/// empty dummy.
|
|
||||||
/// </summary>
|
|
||||||
internal RowData()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Initializes a new instance of the <see cref="RowData"/> class.
|
/// Initializes a new instance of the <see cref="RowData"/> class.
|
||||||
/// (Related replace "\x00" see #171.)
|
/// (Related replace "\x00" see #171.)
|
||||||
|
|
|
@ -125,12 +125,18 @@ namespace SystemTrayMenu.Helpers
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!menuData.IsNetworkRoot && FolderOptions.IsHidden(rowData))
|
if (!menuData.IsNetworkRoot)
|
||||||
|
{
|
||||||
|
FolderOptions.ReadHiddenAttributes(rowData.Path, out bool hasHiddenFlag, out bool isDirectoryToHide);
|
||||||
|
if (isDirectoryToHide)
|
||||||
{
|
{
|
||||||
rowDatasToRemove.Add(rowData);
|
rowDatasToRemove.Add(rowData);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
rowData.HiddenEntry = hasHiddenFlag;
|
||||||
|
}
|
||||||
|
|
||||||
rowData.ReadIcon(true);
|
rowData.ReadIcon(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -9,7 +9,6 @@ namespace SystemTrayMenu.Utilities
|
||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
using System.Runtime.InteropServices;
|
using System.Runtime.InteropServices;
|
||||||
using Shell32;
|
using Shell32;
|
||||||
using SystemTrayMenu.DataClasses;
|
|
||||||
|
|
||||||
internal static class FolderOptions
|
internal static class FolderOptions
|
||||||
{
|
{
|
||||||
|
@ -54,40 +53,39 @@ namespace SystemTrayMenu.Utilities
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
internal static bool IsHidden(RowData rowData)
|
internal static void ReadHiddenAttributes(string? path, out bool hasHiddenFlag, out bool isDirectoryToHide)
|
||||||
{
|
{
|
||||||
bool isDirectoryToHide = false;
|
isDirectoryToHide = false;
|
||||||
if (rowData.Path == null || rowData.Path.Length >= 260)
|
hasHiddenFlag = false;
|
||||||
|
if (path == null || path.Length >= 260)
|
||||||
{
|
{
|
||||||
Log.Info($"path too long (>=260):'{rowData.Path}'");
|
Log.Info($"path too long (>=260):'{path}'");
|
||||||
return isDirectoryToHide;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
FileAttributes attributes = File.GetAttributes(rowData.Path);
|
FileAttributes attributes = File.GetAttributes(path);
|
||||||
rowData.HiddenEntry = attributes.HasFlag(FileAttributes.Hidden);
|
hasHiddenFlag = attributes.HasFlag(FileAttributes.Hidden);
|
||||||
bool systemEntry = attributes.HasFlag(
|
bool hasSystemFlag = attributes.HasFlag(
|
||||||
FileAttributes.Hidden | FileAttributes.System);
|
FileAttributes.Hidden | FileAttributes.System);
|
||||||
if (Properties.Settings.Default.SystemSettingsShowHiddenFiles)
|
if (Properties.Settings.Default.SystemSettingsShowHiddenFiles)
|
||||||
{
|
{
|
||||||
if ((hideHiddenEntries && rowData.HiddenEntry) ||
|
if ((hideHiddenEntries && hasHiddenFlag) ||
|
||||||
(hideSystemEntries && systemEntry))
|
(hideSystemEntries && hasSystemFlag))
|
||||||
{
|
{
|
||||||
isDirectoryToHide = true;
|
isDirectoryToHide = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (rowData.HiddenEntry && Properties.Settings.Default.NeverShowHiddenFiles)
|
else if (hasHiddenFlag && Properties.Settings.Default.NeverShowHiddenFiles)
|
||||||
{
|
{
|
||||||
isDirectoryToHide = true;
|
isDirectoryToHide = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
Log.Warn($"path:'{rowData.Path}'", ex);
|
Log.Warn($"path:'{path}'", ex);
|
||||||
}
|
}
|
||||||
|
|
||||||
return isDirectoryToHide;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue