Skip to content

Commit 00f85ab

Browse files
author
Szczepan Hołyszewski
committed
Absolutize paths harder
1 parent 0465d92 commit 00f85ab

File tree

3 files changed

+11
-5
lines changed

3 files changed

+11
-5
lines changed

src/classes/Obey/Front/InputResolver.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ class InputResolver
1919

2020
public function resolve(Unit $unit)
2121
{
22-
$inputPattern = Path::cat($this->getRootDir(), $unit->getGroup()->getInputPattern());
22+
$inputPattern = Path::norm(Path::cat(getcwd(), $this->getRootDir(), $unit->getGroup()->getInputPattern()));
2323
$inputFile = str_replace('*', $unit->getName(), $inputPattern);
2424
$unit->setInputFile($inputFile);
2525
}

src/classes/Obey/Front/OutputResolver.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,12 @@ class OutputResolver
2727

2828
public function resolve(Unit $unit)
2929
{
30-
$outputPattern = Path::cat(
30+
$outputPattern = PAth::norm(Path::cat(
31+
getcwd(),
3132
$this->getOutputDir(),
3233
$unit->getGroup()->getSubDir(),
3334
$this->getOutputNameTemplate()
34-
);
35+
));
3536
$outputFile = str_replace('{}', $unit->getName(), $outputPattern);
3637
$unit->setOutputFile($outputFile);
3738
}

src/classes/Obey/PathHelper.php

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,14 @@ public static function cat(?string ...$fragments) : string
99
{
1010
$nonNullFragments = array_filter($fragments,fn($v) => null!==$v);
1111
if (0===count($nonNullFragments)) return ".";
12+
$absoluteTail = [];
13+
foreach($nonNullFragments as $fragment) {
14+
if (self::isAbsolute($fragment)) $absoluteTail=[$fragment];
15+
else $absoluteTail[] = $fragment;
16+
}
1217
$explodedFragments = [
13-
self::split($nonNullFragments[0]),
14-
...array_map(fn($fragment) => self::split($fragment,false), array_slice($nonNullFragments,1))
18+
self::split($absoluteTail[0]),
19+
...array_map(fn($fragment) => self::split($fragment,false), array_slice($absoluteTail,1))
1520
];
1621
$segments = array_merge(...$explodedFragments);
1722
if (!count($segments)) return ".";

0 commit comments

Comments
 (0)