How to get the filesystem of $PWD
?
#21321
-
In order to not write inode names with disallowed characters to filesystems which don't support most characters (like NTFS, FAT*, and/or exFAT) I would like to ensure that the |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 5 replies
-
Assuming Linux due to BTRFS GetDrives will give you the drive format
you will need to get the drive by matching the root of your file system with Name
Unfortunately GetPathRoot does not appear useful, it always returns / on Linux as far as I can see
So back to POSIX and "df" and up to you to do the parsing to get the "Mounted on" value
On Linux GetInvalidFileNameChars just gives NUL and forward slash
|
Beta Was this translation helpful? Give feedback.
-
Per @rhubarb-geek-nz,'s damn comprehensive response at https://github.com/orgs/PowerShell/discussions/21321?sort=top#discussioncomment-8726472, I've created the answer: ([System.IO.DriveInfo]::GetDrives() | Where-Object -Property 'Name' -Eq -Value (df "$PWD" | awk '{if ($1 != "Filesystem") print $6}')).DriveFormat |
Beta Was this translation helpful? Give feedback.
Per @rhubarb-geek-nz,'s damn comprehensive response at https://github.com/orgs/PowerShell/discussions/21321?sort=top#discussioncomment-8726472, I've created the answer: