Last active
February 16, 2019 16:25
-
-
Save larsonmars/bf9b691c359bbd4be31e1e1e36277bbf to your computer and use it in GitHub Desktop.
WSL windows to linux path converter
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* w2lp.c | |
* | |
* 2017 by Lars Stockmann | |
* released in the public domain | |
*/ | |
#include <stdio.h> | |
#define PRE_PATH "/mnt/" | |
int main(int argC, const char* argV[]) | |
{ | |
FILE* out = stdout; | |
int i, errC = 0; | |
for (i = 1; i < argC; ++i) { | |
const char* pSrc = argV[i]; | |
int c = *pSrc++; | |
if (c < 'a') | |
c += 'a' - 'A'; | |
if (c < 'a' || c > 'z' || *pSrc++ != ':') { | |
++errC; | |
continue; | |
} | |
if (i > 1) | |
putc(' ', out); | |
fwrite(PRE_PATH, 1, sizeof PRE_PATH - 1, out); | |
putc((char)c, out); | |
while((c = *pSrc++)) | |
putc(c == '\\' ? '/' : (char)c, out); | |
} | |
putc('\n', out); | |
return errC; | |
} |
@larsonmars: A dedicated GitHub repository with Makefile / packaging would be awesome 👍
I thought it is too simple to be worthy a repository, but if you think it's worth, I can see what I can do. Note that I just more or less followed the msdn blog to build it using visual studio, specifically targeting WSL, which was really easy.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Allows you to drag & drop windows files in the bash
ls "$(w2lp '
drag&drop windows file')"