July 27, 2011

Converting paths on a linux filesystem to WINE relative paths

Wine is a windows software emulator for Linux. Wine generally installs itself to ~/.wine and the C:\ Drive for the corresponding emulated windows environment is ~/.wine/drive_c/ . Wine sees the actually filesystem as mounted under a emulated Z:\ drive, so for example /mnt on the linux filesystem becomes Z:\mnt. To automatically run windows programs which require files from the linux filesystem, it is nifty if the linux filesystem path for a file can be converted to the emulated version starting with Z:\ , here is a small snippet of code which does that for the current working directory :

$ echo Z:`pwd` | sed 's/\//\\/g'

It gets the absolute path for the current working directory and converts all forward slashes ('/') to backward slashes ('\') and prepends the drive letter (Z:) to it. Now adapting the above snippet to get the wine path for a normal file is quite easy, and is left for those who are interested