Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get the file separator symbol in Qore/Qorus : / or \?

I have a service which refers to some external filesystem resources like html, css, etc, ... which fails to load in Windows because of passing incorrect path to them.

Is there any way I could retrieve the file separator of the operating system in Qorus (I mean slash or backslash depending on the system) so that I could build the proper resource path?

I know there is a function to get the path of a file normalize_dir() and based on it can be decided what separator to use

       string file_separator = normalize_dir("").find("/") > 0 ? '/' : '\';

       setDefaultResource("html" + file_separator + "index.qhtml");

but I was wondering if there is already something in place that return this char (as I was not able to find something similar in the docs) or a similar function that I could reuse.

like image 890
vlastr Avatar asked Jan 24 '17 14:01

vlastr


1 Answers

You can use Qore string constant DirSep described in documentation, which always contains the platform-specific directory separator string, i.e. / for Linux and other Unix-like OSes, and \ for Windows.

like image 85
omusil Avatar answered Oct 23 '22 12:10

omusil