mirror of
https://git.code.sf.net/p/seeddms/code
synced 2025-05-13 21:21:27 +00:00
addDirSep() can check for arbitrary chars at end of string
This commit is contained in:
parent
bea6ab35a8
commit
4e08744631
|
@ -663,16 +663,19 @@ function get_extension($mimetype) { /* {{{ */
|
||||||
} /* }}} */
|
} /* }}} */
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Adds a missing front slash to a string
|
* Adds a missing directory separator (or any other char) to a string
|
||||||
*
|
*
|
||||||
* This function is used for making sure a directory name has a
|
* This function is used for making sure a directory name has a
|
||||||
* trailing directory separator
|
* trailing directory separator. It can also be used to add
|
||||||
|
* any other char at the end of a string, e.g. an URL which must
|
||||||
|
* end in '/' (DIRECTORY_SEPARATOR wouldn't be right in that case,
|
||||||
|
* because it is '\' on Windows)
|
||||||
*/
|
*/
|
||||||
function addDirSep($str) { /* {{{ */
|
function addDirSep($str, $chr=DIRECTORY_SEPARATOR) { /* {{{ */
|
||||||
if(trim($str) == '')
|
if(trim($str) == '')
|
||||||
return '';
|
return '';
|
||||||
if(substr(trim($str), -1, 1) != DIRECTORY_SEPARATOR)
|
if(substr(trim($str), -1, 1) != $chr)
|
||||||
return trim($str).DIRECTORY_SEPARATOR;
|
return trim($str).$chr;
|
||||||
else
|
else
|
||||||
return trim($str);
|
return trim($str);
|
||||||
} /* }}} */
|
} /* }}} */
|
||||||
|
|
Loading…
Reference in New Issue
Block a user