Browse Source

Convert DOS2UNIX.

release/v0.1
Rafal Kupiec 1 year ago
parent
commit
1f78547ca2
Signed by: belliash GPG Key ID: 4E829243E0CFE6B4
1 changed files with 32 additions and 32 deletions
  1. +32
    -32
      tests/path_split.aer

+ 32
- 32
tests/path_split.aer View File

@ -1,32 +1,32 @@
class Program {
string[] parsePathComponents(string $path, bool $endSlash=true, bool $base=false) {
string[] $retArray;
$path = trim($path);
string $str, $temp;
char $char;
for(int $x = 0; $char = $path[$x]; $x++) {
if(!strstr('/', $char)) $temp += $char;
else if($temp) {
$str += $temp;
$retArray[$temp] = $str + ($endSlash ? '/' : '');
$str += '/';
$temp = '';
}
}
($base && $temp) ? $retArray[$temp] = $str + $temp : NULL;
return $retArray;
}
public void main() {
string $path = '/my//stupid//path/to///some/file.php';
print_r($this->parsePathComponents($path));
$path = 'my/other//path/';
print_r($this->parsePathComponents($path, false));
$path = '/my//other/path/to///file.php';
print_r($this->parsePathComponents($path, true, true));
}
}
class Program {
string[] parsePathComponents(string $path, bool $endSlash=true, bool $base=false) {
string[] $retArray;
$path = trim($path);
string $str, $temp;
char $char;
for(int $x = 0; $char = $path[$x]; $x++) {
if(!strstr('/', $char)) $temp += $char;
else if($temp) {
$str += $temp;
$retArray[$temp] = $str + ($endSlash ? '/' : '');
$str += '/';
$temp = '';
}
}
($base && $temp) ? $retArray[$temp] = $str + $temp : NULL;
return $retArray;
}
public void main() {
string $path = '/my//stupid//path/to///some/file.php';
print_r($this->parsePathComponents($path));
$path = 'my/other//path/';
print_r($this->parsePathComponents($path, false));
$path = '/my//other/path/to///file.php';
print_r($this->parsePathComponents($path, true, true));
}
}

Loading…
Cancel
Save