projectDir . '/' . self::CBZ_DIRECTORY . '/' . ucfirst($mangaSlug) . " ($year)"; $this->filesystem->mkdir($directoryPath, 0755); return $directoryPath; } public function createVolumeDirectory(string $mangaDir, int $volume): string { $volumeDir = sprintf('%s/volume_%02d', $mangaDir, $volume); $this->filesystem->mkdir($volumeDir, 0755); return $volumeDir; } public function moveUploadedFile(string $sourcePath, string $destinationDir, string $originalFilename): string { $newFilename = $this->generateUniqueFilename($originalFilename); $destinationPath = $destinationDir . '/' . $newFilename; $this->filesystem->rename($sourcePath, $destinationPath, true); return $destinationPath; } public function deleteFile(string $filePath): void { if ($this->filesystem->exists($filePath)) { $this->filesystem->remove($filePath); } } public function deleteDirectory(string $directoryPath): void { if ($this->filesystem->exists($directoryPath)) { $this->filesystem->remove($directoryPath); } } public function fileExists(string $filePath): bool { return $this->filesystem->exists($filePath); } public function moveFile(string $sourcePath, string $destinationPath): void { $this->filesystem->rename($sourcePath, $destinationPath, true); } public function getUploadsDirectory(): string { return $this->projectDir . '/' . self::UPLOADS_DIRECTORY; } private function generateUniqueFilename(string $originalFilename): string { $safeFilename = $this->slugger->slug(pathinfo($originalFilename, PATHINFO_FILENAME)); return $safeFilename . '-' . uniqid() . '.' . pathinfo($originalFilename, PATHINFO_EXTENSION); } public function getImagePath(string $subDir = ''): string { return $this->projectDir . '/' . self::IMAGES_DIRECTORY . ($subDir ? "/$subDir" : ''); } public function generateUniqueImageFilename(string $originalFilename): string { $safeFilename = $this->slugger->slug(pathinfo($originalFilename, PATHINFO_FILENAME)); return $safeFilename . '-' . uniqid() . '.jpg'; } }