Added comments, clean-up
This commit is contained in:
@@ -8,17 +8,18 @@ namespace LightlessSync.Utils
|
||||
public enum FilesystemType
|
||||
{
|
||||
Unknown = 0,
|
||||
NTFS,
|
||||
Btrfs,
|
||||
NTFS, // Compressable
|
||||
Btrfs, // Compressable
|
||||
Ext4,
|
||||
Xfs,
|
||||
Apfs,
|
||||
HfsPlus,
|
||||
Fat,
|
||||
Exfat,
|
||||
Zfs
|
||||
Zfs // Compressable
|
||||
}
|
||||
|
||||
private const string _mountPath = "/proc/mounts";
|
||||
private static readonly ConcurrentDictionary<string, FilesystemType> _filesystemTypeCache = new(StringComparer.OrdinalIgnoreCase);
|
||||
|
||||
public static FilesystemType GetFilesystemType(string filePath, bool isWine = false)
|
||||
@@ -75,8 +76,8 @@ namespace LightlessSync.Utils
|
||||
try
|
||||
{
|
||||
var path = Path.GetFullPath(filePath);
|
||||
if (!File.Exists("/proc/mounts")) return "/";
|
||||
var mounts = File.ReadAllLines("/proc/mounts");
|
||||
if (!File.Exists(_mountPath)) return "/";
|
||||
var mounts = File.ReadAllLines(_mountPath);
|
||||
|
||||
string bestMount = "/";
|
||||
foreach (var line in mounts)
|
||||
@@ -109,7 +110,7 @@ namespace LightlessSync.Utils
|
||||
try
|
||||
{
|
||||
var mountPoint = GetMountPoint(filePath);
|
||||
var mounts = File.ReadAllLines("/proc/mounts");
|
||||
var mounts = File.ReadAllLines(_mountPath);
|
||||
|
||||
foreach (var line in mounts)
|
||||
{
|
||||
@@ -140,6 +141,7 @@ namespace LightlessSync.Utils
|
||||
}
|
||||
}
|
||||
|
||||
//Extra check on
|
||||
private static bool IsProbablyWine() => Environment.GetEnvironmentVariable("WINELOADERNOEXEC") != null || Environment.GetEnvironmentVariable("WINEDLLPATH") != null || Directory.Exists("/proc/self") && File.Exists("/proc/mounts");
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user