Convert DOS2UNIX.
The build was successful.
Details
The build was successful.
Details
This commit is contained in:
parent
ddd46a4e80
commit
1f78547ca2
|
@ -1,32 +1,32 @@
|
||||||
class Program {
|
class Program {
|
||||||
|
|
||||||
string[] parsePathComponents(string $path, bool $endSlash=true, bool $base=false) {
|
string[] parsePathComponents(string $path, bool $endSlash=true, bool $base=false) {
|
||||||
string[] $retArray;
|
string[] $retArray;
|
||||||
$path = trim($path);
|
$path = trim($path);
|
||||||
string $str, $temp;
|
string $str, $temp;
|
||||||
char $char;
|
char $char;
|
||||||
for(int $x = 0; $char = $path[$x]; $x++) {
|
for(int $x = 0; $char = $path[$x]; $x++) {
|
||||||
if(!strstr('/', $char)) $temp += $char;
|
if(!strstr('/', $char)) $temp += $char;
|
||||||
else if($temp) {
|
else if($temp) {
|
||||||
$str += $temp;
|
$str += $temp;
|
||||||
$retArray[$temp] = $str + ($endSlash ? '/' : '');
|
$retArray[$temp] = $str + ($endSlash ? '/' : '');
|
||||||
$str += '/';
|
$str += '/';
|
||||||
$temp = '';
|
$temp = '';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
($base && $temp) ? $retArray[$temp] = $str + $temp : NULL;
|
($base && $temp) ? $retArray[$temp] = $str + $temp : NULL;
|
||||||
return $retArray;
|
return $retArray;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void main() {
|
public void main() {
|
||||||
string $path = '/my//stupid//path/to///some/file.php';
|
string $path = '/my//stupid//path/to///some/file.php';
|
||||||
print_r($this->parsePathComponents($path));
|
print_r($this->parsePathComponents($path));
|
||||||
|
|
||||||
$path = 'my/other//path/';
|
$path = 'my/other//path/';
|
||||||
print_r($this->parsePathComponents($path, false));
|
print_r($this->parsePathComponents($path, false));
|
||||||
|
|
||||||
$path = '/my//other/path/to///file.php';
|
$path = '/my//other/path/to///file.php';
|
||||||
print_r($this->parsePathComponents($path, true, true));
|
print_r($this->parsePathComponents($path, true, true));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue