mirror of
https://git.code.sf.net/p/seeddms/code
synced 2025-02-06 15:14:58 +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
|
||||
* 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) == '')
|
||||
return '';
|
||||
if(substr(trim($str), -1, 1) != DIRECTORY_SEPARATOR)
|
||||
return trim($str).DIRECTORY_SEPARATOR;
|
||||
if(substr(trim($str), -1, 1) != $chr)
|
||||
return trim($str).$chr;
|
||||
else
|
||||
return trim($str);
|
||||
} /* }}} */
|
||||
|
|
Loading…
Reference in New Issue
Block a user