How to join a path to a file in code, "windows safe" Given a hook (e.g. hook_theme()) and a path where something has to be looked up (e.g. templates), what is the cleanest way to deal with this?

I have the following directory structure:


sites/all/modules/mymodule

mymodule.module
templates

mymodule.tpl.php




When I define that path in code, I use the following code.

function mymodule_theme($existing, $type, $theme, $path) {
  return array(
    "mymodule"  =&gt; array(
    "variables" =&gt; array(),
    "path"      =&gt; $path . "/templates",
    "template"  =&gt; "mymodule"
  );
}


I want this code to work on Windows too, without having to do checks for OS inside that function.
Just use / as path separator: It will work on Windows, and any other OS. 

PHP defines the DIRECTORY_SEPARATOR constant, but that constant is not used from Drupal core code, and Drupal works on Windows too.
A note on the parameters accepted from basename() says:


  On Windows, both slash (/) and backslash (\) are used as directory separator character. In other environments, it is the forward slash (/).