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

I have a service that links to some external filesystem resources, such as html, css, etc ... that do not load on Windows due to going through the wrong path with them.

Is there any way to get the file separator of the operating system in Qorus (I mean a slash or a backslash depending on the system) so that I can create the correct resource path?

I know that there is a function to get the path to the normalize_dir () file and based on this you can decide which separator to use

string file_separator = normalize_dir("").find("/") > 0 ? '/' : '\'; setDefaultResource("html" + file_separator + "index.qhtml"); 

but I was wondering if there was something in place that returned this char (since I could not find something similar in the docs) or a similar function that I could reuse.

+5
source share
1 answer

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

+5
source

Source: https://habr.com/ru/post/1263264/


All Articles