Skip to content

Commit 5b04dde

Browse files
committed
wip
1 parent 2e0c9c3 commit 5b04dde

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed

src/Concerns/InteractWithFiles.php

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,16 @@ public function getDefaultUrlFormatter(): string
4848
return $formatter;
4949
}
5050

51+
public function dirname(): ?string
52+
{
53+
54+
if ($this->path) {
55+
return dirname($this->path);
56+
}
57+
58+
return null;
59+
}
60+
5161
public function getDisk(): ?Filesystem
5262
{
5363
if (! $this->disk) {
@@ -133,6 +143,23 @@ public function deleteFile(): bool
133143
return true;
134144
}
135145

146+
public function deleteDirectory(): bool
147+
{
148+
$dirname = $this->dirname();
149+
150+
if (! $dirname) {
151+
return true;
152+
}
153+
154+
$filesystem = $this->getDisk();
155+
156+
if (! $filesystem) {
157+
return true;
158+
}
159+
160+
return $filesystem->deleteDirectory($dirname);
161+
}
162+
136163
/**
137164
* @return ?string The new file path on success, null on failure
138165
*/

0 commit comments

Comments
 (0)