DriveCount in Linux not working?

I’m developing a desktop app for Windows, Mac and Linux. Part of it is a File Manager considering SD cards. To evaluate if an SD card was removed or attached I have created a timer checking every second the current drive amount state versus the previous saved ones:

If FolderItem.DriveCount <> OSDriveCount Then

End If

This works like a charm on Windows and Mac but on Linux the FolderItem.DriveCount always returns 1 (probably 1 for the main hard disk). Based on the description in the online manual I would expect an attached SD card would also count on Linux as drive:
“The DriveCount function returns the number of mounted Drive.”

I’m experiencing this problem with Xojo 2022 - Release 4.1 and Ubuntu ARM64 22.04. After Ubuntu mentions the SD card is now mounted (and I can see it in shell: df -T) I’d expect the timer for DriveCount should fire but it doesn’t. I’m a Linux noob and don’t understand if this is a bug or just explainable behavior. If that is “normal” for Linux how else can I evaluate the REAL amount of attached drives?

I’m not sure if you can. But maybe you could use the Shell to more reliable evaluate mounted drives.

As @Sascha_S recommends, I use the shell and the “mount” command.

Dim theShell As New Shell
// driveCount is a global Int16

theShell.Timeout = -1
theShell.Mode = 1 // Synchronous
theShell.execute"mount | grep ""^/dev"" | grep -E -v ""sysfs|tmpfs|cgroup|proc|devpts|autofs"" | wc -l"
Loop Until Not theShell.IsRunning
driveCount = Val(theShell.ReadAll)

On my current system that returns 3 since I have 3 physical disks mounted (including 1 USB thumbdrive)

1 Like

Thank you both…
The shell command above gets me an error but that’s not the issue, I have a command that is working (df -T). The point is that the code:

If FolderItem.DriveCount <> OSDriveCount Then
execute shell command to get all mounted drives
End If

… is not working on Linux while it works on Windows and Mac because FolderItem.DriveCount doesn’t change the drive count when I plug an SD card (probably same with plugging an USB stick).I guess that’s a Xojo bug.