mirror of
https://github.com/aaru-dps/Aaru.git
synced 2025-12-16 19:24:25 +00:00
* DiscImageChef.Devices/Device/Constructor.cs:
Added support for USB on Linux. * DiscImageChef/Commands/DeviceInfo.cs: * DiscImageChef.Devices/Device/Variables.cs: Added support for USB detection and metadata. * DiscImageChef.Devices/Linux/Extern.cs: * DiscImageChef.Devices/Linux/Command.cs: Added readlink(3) support, for getting symlink destinations.
This commit is contained in:
@@ -328,6 +328,34 @@ namespace DiscImageChef.Devices.Linux
|
||||
|
||||
return error;
|
||||
}
|
||||
|
||||
public static string ReadLink(string path)
|
||||
{
|
||||
IntPtr buf = Marshal.AllocHGlobal(int.MaxValue);
|
||||
int resultSize;
|
||||
|
||||
if (Interop.DetectOS.Is64Bit())
|
||||
{
|
||||
long result64 = Extern.readlink64(path, buf, (long)int.MaxValue);
|
||||
if (result64 <= 0)
|
||||
return null;
|
||||
|
||||
resultSize = (int)result64;
|
||||
}
|
||||
else
|
||||
{
|
||||
int result = Extern.readlink(path, buf, int.MaxValue);
|
||||
if (result <= 0)
|
||||
return null;
|
||||
|
||||
resultSize = result;
|
||||
}
|
||||
|
||||
byte[] resultString = new byte[resultSize];
|
||||
Marshal.Copy(buf, resultString, 0, resultSize);
|
||||
Marshal.FreeHGlobal(buf);
|
||||
return System.Text.Encoding.ASCII.GetString(resultString);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user