48 public function __construct(
private int $storage_type,
private bool $path_conversion,
private int $container_id)
51 $this->file_system_service =
$DIC->filesystem();
57 public function fileExists(
string $a_absolute_path): bool
66 return $stream->getMetadata(
'uri');
73 return $this->file_system_service->storage();
77 return $this->file_system_service->web();
79 throw new LogicException(
'cannot determine correct filesystem');
84 return $this->container_id;
91 $num = $a_container_id;
93 for ($i = self::MAX_EXPONENT; $i > 0; $i--) {
94 $factor = self::FACTOR ** $i;
95 if (($tmp = (
int) ($num / $factor)) or $found) {
103 $path_string = (implode(
'/',
$path) .
'/');
106 return $path_string . $a_name .
'_' . $a_container_id;
114 if (!$fp = @fopen($a_absolute_path,
'w+')) {
117 if (@fwrite($fp, $a_data) ===
false) {
128 public function copyFile(
string $a_from,
string $a_to): bool
130 if (@file_exists($a_from)) {
131 @copy($a_from, $a_to);
185 return rtrim(
CLIENT_DATA_DIR,
'/') .
'/' . ltrim((
string) $this->path,
'/');
187 return rtrim(
CLIENT_WEB_DIR,
'/') .
'/' . ltrim((
string) $this->path,
'/');
190 protected function init(): bool
192 switch ($this->storage_type) {
197 $this->path = rtrim($this->path ??
'',
'/') .
'/' . self::SECURED_DIRECTORY .
'/';
204 if ($this->path_conversion) {
207 $this->path .= ($this->
getPathPostfix() .
'_' . $this->container_id);
213 public function delete():
bool
217 }
catch (Exception) {
241 $sourceFS = LegacyPathHelper::deriveFilesystemFrom($a_sdir);
242 $targetFS = LegacyPathHelper::deriveFilesystemFrom($a_tdir);
244 $sourceDir = LegacyPathHelper::createRelativePath($a_sdir);
245 $targetDir = LegacyPathHelper::createRelativePath($a_tdir);
248 if (!$sourceFS->hasDir($sourceDir)) {
252 $sourceList = $sourceFS->listContents($sourceDir,
true);
254 foreach ($sourceList as $item) {
255 if ($item->isDir()) {
259 $itemPath = $targetDir .
'/' . substr($item->getPath(), strlen($sourceDir));
260 $stream = $sourceFS->readStream($sourceDir);
261 $targetFS->writeStream($itemPath, $stream);
265 }
catch (\Exception) {
272 $this->path .= $a_appendix;
277 return $this->storage_type;
287 $relative_path = LegacyPathHelper::createRelativePath($a_absolute_path);
289 return $relative_path;
Indicates general problems with the input or output operations.
The legacy path helper provides convenient functions for the integration of the filesystem service wi...
__construct(private int $storage_type, private bool $path_conversion, private int $container_id)
Constructor.
copyFile(string $a_from, string $a_to)
deleteDirectory(string $a_abs_name)
static createPathFromId(int $a_container_id, string $a_name)
static _copyDirectory(string $a_sdir, string $a_tdir)
getAbsolutePath()
Calculates the full path on the filesystem.
Filesystems $file_system_service
getLegacyFullAbsolutePath(string $relative_path)
appendToPath(string $a_appendix)
writeToFile(string $a_data, $a_absolute_path)
deleteFile(string $a_abs_name)
fileExists(string $a_absolute_path)
createRelativePathForFileSystem(string $a_absolute_path)
getLegacyAbsolutePath()
Calculates the absolute filesystem storage location.
getPathPrefix()
Get path prefix.
getPathPostfix()
Get directory name.
The filesystem interface provides the public interface for the Filesystem service API consumer.
The Filesystems interface defines the access methods which can be used to fetch the different filesys...