-
Notifications
You must be signed in to change notification settings - Fork 8
Open
Description
Summary
Refactor IFileSystemInspector to add a centralized ClassifyEntry method that returns the FileSystemEntryKind for any filesystem entry, consolidating all classification logic in one place.
Background
Currently, IFileSystemInspector has separate boolean methods:
IsHidden()IsSystem()IsReparsePoint()IsOffline()IsRecallOnDataAccess()
Classification logic is scattered between FileSystemInspector and InventoryBuilder. This refactoring centralizes the "what type is this entry?" question.
Proposed Interface Changes
public interface IFileSystemInspector
{
// Existing methods (keep for backward compatibility)
bool IsHidden(FileSystemInfo fsi, OSPlatforms os);
bool IsSystem(FileInfo fileInfo);
bool IsReparsePoint(FileSystemInfo fsi);
bool Exists(FileInfo fileInfo);
bool IsOffline(FileInfo fileInfo);
bool IsRecallOnDataAccess(FileInfo fileInfo);
// New classification method
FileSystemEntryKind ClassifyEntry(FileSystemInfo fsi);
}Classification Logic
The ClassifyEntry method should:
- Check for symlink first (via
LinkTargetorReparsePoint) - On Linux/macOS: use POSIX detection for special files
- Return
DirectoryforDirectoryInfo - Return
RegularFilefor standardFileInfo - Return
Unknownif classification fails
Acceptance Criteria
- Add
ClassifyEntry(FileSystemInfo fsi)toIFileSystemInspector - Implement in
FileSystemInspectorwith full classification logic - Integrate POSIX detection (depends on Mono.Posix integration)
- Symlink detection using
LinkTargetproperty (cross-platform) - Fallback to
ReparsePointcheck for Windows compatibility - Unit tests for each entry kind on appropriate platforms
- Existing boolean methods remain functional (no breaking changes)
Dependencies
- Requires:
FileSystemEntryKindenum (issue #X) - Requires: POSIX detection via Mono.Posix (issue [feature] Detect POSIX special files using Mono.Posix.NETStandard #259)
Technical Notes
Example implementation structure:
public FileSystemEntryKind ClassifyEntry(FileSystemInfo fsi)
{
// 1. Symlink check (cross-platform)
if (fsi.LinkTarget != null || IsReparsePoint(fsi))
return FileSystemEntryKind.Symlink;
// 2. POSIX special files (Linux/macOS only)
if (OperatingSystem.IsLinux() || OperatingSystem.IsMacOS())
{
var posixKind = ClassifyPosixEntry(fsi.FullName);
if (posixKind != FileSystemEntryKind.Unknown)
return posixKind;
}
// 3. Standard types
return fsi switch
{
DirectoryInfo => FileSystemEntryKind.Directory,
FileInfo => FileSystemEntryKind.RegularFile,
_ => FileSystemEntryKind.Unknown
};
}Priority
Important — Core architectural improvement for classification system.
Metadata
Metadata
Assignees
Labels
No labels