I want to access an Android device over MTP using Nodejs running on Linux.
The Android device is mounted at /run/user/1000/gvfs/mtp:host=%5Busb%3A002%2C010%5D
and can be treated as a regular file system thanks to MTP.
Now the part after mtp:host=
(%5Busb%3A002%2C010%5D
in this case) always depends on the physical USB port on which the Android device is connected.
A way to ensure we always get the right path to the file system is to use something like
$ cd /run/user/1000/gvfs/mtp*
This works well in bash
and will indeed resolve into
~$ cd /run/user/1000/gvfs/mtp*
/run/user/1000/gvfs/mtp:host=%5Busb%3A002%2C010%5D$
but I can't seem to resolve the correct path in Nodejs either using path.resolve
or path.normalize
. Even the POSIX implementations of path
(path.posix
) don't help.
Do you know a way to resolve a path containing a wildcard in Nodejs?
NB: of course I assume here that only one MTP device is plugged at a time.