Skip to content

Commit 002efdd

Browse files
authored
Merge pull request pterodactyl#1146 from pterodactyl/feature/windows-pathinfo-support
Add support for Windows, replace all backslashes with forwardslashes
2 parents 457e461 + f42f211 commit 002efdd

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

app/Http/Controllers/Server/Files/FileActionsController.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ public function view(UpdateFileContentsFormRequest $request, string $uuid, strin
101101
{
102102
$server = $request->attributes->get('server');
103103

104-
$dirname = pathinfo($file, PATHINFO_DIRNAME);
104+
$dirname = str_replace('\\', '/', pathinfo($file, PATHINFO_DIRNAME));
105105
try {
106106
$content = $this->repository->setServer($server)->setToken($request->attributes->get('server_token'))->getContent($file);
107107
} catch (RequestException $exception) {

app/Repositories/Daemon/FileRepository.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ class FileRepository extends BaseRepository implements FileRepositoryInterface
1818
*/
1919
public function getFileStat(string $path): stdClass
2020
{
21-
$file = pathinfo($path);
21+
$file = str_replace('\\', '/', pathinfo($path));
2222
$file['dirname'] = in_array($file['dirname'], ['.', './', '/']) ? null : trim($file['dirname'], '/') . '/';
2323

2424
$response = $this->getHttpClient()->request('GET', sprintf(
@@ -39,7 +39,7 @@ public function getFileStat(string $path): stdClass
3939
*/
4040
public function getContent(string $path): string
4141
{
42-
$file = pathinfo($path);
42+
$file = str_replace('\\', '/', pathinfo($path));
4343
$file['dirname'] = in_array($file['dirname'], ['.', './', '/']) ? null : trim($file['dirname'], '/') . '/';
4444

4545
$response = $this->getHttpClient()->request('GET', sprintf(
@@ -61,7 +61,7 @@ public function getContent(string $path): string
6161
*/
6262
public function putContent(string $path, string $content): ResponseInterface
6363
{
64-
$file = pathinfo($path);
64+
$file = str_replace('\\', '/', pathinfo($path));
6565
$file['dirname'] = in_array($file['dirname'], ['.', './', '/']) ? null : trim($file['dirname'], '/') . '/';
6666

6767
return $this->getHttpClient()->request('POST', 'server/file/save', [
@@ -100,7 +100,7 @@ public function getDirectory(string $path): array
100100
array_push($files, [
101101
'entry' => $value->name,
102102
'directory' => trim($path, '/'),
103-
'extension' => pathinfo($value->name, PATHINFO_EXTENSION),
103+
'extension' => str_replace('\\', '/', pathinfo($value->name, PATHINFO_EXTENSION)),
104104
'size' => human_readable($value->size),
105105
'date' => strtotime($value->modified),
106106
'mime' => $value->mime,

0 commit comments

Comments
 (0)