Easy way to make "system" command independent of OS

Viewed 63

My work place has an extensive script library that uses plenty of system commands to make directories. Previously, all this work was done on Linux so everything is hardcoded with forwarded slashes "/", but we now want to make it windows compatible.

At the moment, trying to make a directory with system('mkdir ../dir') throws an error because Windows command line uses back slashes "\" for making directories.

Is there an easy way to tell windows to treat the hardcoded forward slashes as back slashes?

My only thought right now is to do a if(ispc) command and set a variable to "\" or "/" accordingly, but I want to know if there are alternatives.

Thanks!

1 Answers
Related