ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
ilFileUtils Class Reference

Class ilFileUtils. More...

+ Collaboration diagram for ilFileUtils:

Static Public Member Functions

static recursive_dirscan (string $dir, array &$arr)
 Recursively scans a given directory and writes path and filename into referenced array. More...
 
static utf8_encode (string $string)
 
static getValidFilename (string $a_filename)
 
static rename (string $a_source, string $a_target)
 
static rCopy (string $a_sdir, string $a_tdir, bool $preserveTimeAttributes=false)
 Copies content of a directory $a_sdir recursively to a directory $a_tdir. More...
 
static makeDirParents (string $a_dir)
 Create a new directory and all parent directories. More...
 
static getDataDir ()
 get data directory (outside webspace) More...
 
static dirsize (string $directory)
 get size of a directory or a file. More...
 
static makeDir (string $a_dir)
 creates a new directory and inherits all filesystem permissions of the parent directory You may pass only the name of your new directory or with the entire path or relative path information. More...
 
static moveUploadedFile (string $a_file, string $a_name, string $a_target, bool $a_raise_errors=true, string $a_mode="move_uploaded")
 move uploaded file More...
 
static zip (string $a_dir, string $a_file, bool $compress_content=false)
 
static delDir (string $a_dir, bool $a_clean_only=false)
 removes a dir and all its content (subdirs and files) recursively More...
 
static getSafeFilename (string $a_initial_filename)
 
static getDir (string $a_dir, bool $a_rec=false, ?string $a_sub_dir="")
 get directory More...
 
static getWebspaceDir (string $mode="filesystem")
 get webspace directory More...
 
static createDirectory (string $a_dir, int $a_mod=0755)
 create directory More...
 
static getFileSizeInfo ()
 
static getASCIIFilename (string $a_filename)
 
static ilTempnam (?string $a_temp_path=null)
 Returns a unique and non existing Path for e temporary file or directory. More...
 
static unzip (string $a_file, bool $overwrite=false, bool $a_flat=false)
 unzip file More...
 
static renameExecutables (string $a_dir)
 
static rRenameSuffix (string $a_dir, string $a_old_suffix, string $a_new_suffix)
 Renames all files with certain suffix and gives them a new suffix. More...
 
static removeTrailingPathSeparators (string $path)
 
static getPhpUploadSizeLimitInBytes ()
 
static _sanitizeFilemame (string $a_filename)
 

Static Protected Member Functions

static sanitateTargetPath (string $a_target)
 

Detailed Description

Class ilFileUtils.

Deprecated:
All Methods are widely used and there is currently no other service providing all of them, but please do not implement new methods in this class.

Definition at line 35 of file class.ilFileUtils.php.

Member Function Documentation

◆ _sanitizeFilemame()

static ilFileUtils::_sanitizeFilemame ( string  $a_filename)
static

Definition at line 844 of file class.ilFileUtils.php.

844 : string
845 {
846 return strip_tags(ilUtil::stripSlashes($a_filename));
847 }
static stripSlashes(string $a_str, bool $a_strip_html=true, string $a_allow="")

References ilUtil\stripSlashes().

Referenced by ilFileDataMail\storeAsAttachment(), and ilFileDataMail\storeUploadedFile().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ createDirectory()

static ilFileUtils::createDirectory ( string  $a_dir,
int  $a_mod = 0755 
)
static

create directory

Parameters
string$a_dir
int$a_mod
Deprecated:
in favour of Filesystem::createDir() located at the filesystem service.
See also
\ILIAS\Filesystem\Filesystem::createDir()

Definition at line 644 of file class.ilFileUtils.php.

644 : void
645 {
646 ilFileUtils::makeDir($a_dir);
647 }
static makeDir(string $a_dir)
creates a new directory and inherits all filesystem permissions of the parent directory You may pass ...

References makeDir().

Referenced by ilExerciseManagementCollectFilesJob\createSubmissionsDirectory(), ilObjTest\exportXMLMediaObjects(), ilObjQuestionPool\exportXMLMediaObjects(), and ilTempnam().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ delDir()

static ilFileUtils::delDir ( string  $a_dir,
bool  $a_clean_only = false 
)
static

removes a dir and all its content (subdirs and files) recursively

@access public

Parameters
string$a_dirdir to delete
bool$a_clean_only
Author
Unknown flexe.nosp@m.r@cu.nosp@m.tephp.nosp@m..com (source: http://www.php.net/rmdir)
Deprecated:
in favour of Filesystem::deleteDir() located at the filesystem service.
See also
\ILIAS\Filesystem\Filesystem::deleteDir()

Definition at line 484 of file class.ilFileUtils.php.

484 : void
485 {
486 if (!is_dir($a_dir) || is_int(strpos($a_dir, ".."))) {
487 return;
488 }
489
490 $current_dir = opendir($a_dir);
491
492 $files = [];
493
494 // this extra loop has been necessary because of a strange bug
495 // at least on MacOS X. A looped readdir() didn't work
496 // correctly with larger directories
497 // when an unlink happened inside the loop. Getting all files
498 // into the memory first solved the problem.
499 while ($entryname = readdir($current_dir)) {
500 $files[] = $entryname;
501 }
502
503 foreach ($files as $file) {
504 if (is_dir(
505 $a_dir . "/" . $file
506 ) && ($file !== "." && $file !== "..")) {
507 ilFileUtils::delDir($a_dir . "/" . $file);
508 } elseif ($file !== "." && $file !== "..") {
509 unlink($a_dir . "/" . $file);
510 }
511 }
512
513 closedir($current_dir);
514 if (!$a_clean_only) {
515 @rmdir($a_dir);
516 }
517 }
static delDir(string $a_dir, bool $a_clean_only=false)
removes a dir and all its content (subdirs and files) recursively

References delDir().

Referenced by ilObjTest\_createImportDirectory(), ilScorm2004DataSet\afterXmlRecordWriting(), ilUserDataSet\afterXmlRecordWriting(), ilSurveyExport\buildExportFileXML(), ILIAS\TestQuestionPool\Import\buildImportQuestionsSelectionForm(), ilObjStyleSheet\cleanExportDirectory(), assOrderingQuestion\cleanImagefiles(), ilObjQuestionPoolGUI\cleanupAfterImport(), assLongMenu\clearFolder(), ilObjMediaObject\clearMultiSrtDirectory(), ilMobMultiSrtUpload\clearMultiSrtDirectory(), delDir(), ilCertificateUtilHelper\delDir(), ilBadgeImageTemplate\delete(), ilObjFileBasedLM\delete(), ilObjSAHSLearningModule\delete(), ilObjSurvey\delete(), SurveyQuestion\delete(), assQuestion\delete(), ilObjSurveyQuestionPool\deleteAllData(), ilFileDataMail\deleteAttachmentDirectory(), ilFileDataCourse\deleteDirectory(), ILIAS\Mail\Cron\ExpiredOrOrphanedMails\MailDeletionHandler\deleteDirectory(), ilObjSurveyQuestionPoolGUI\deleteExportFileObject(), ilFileSystemGUI\deleteFile(), ilObjQuestionPool\deleteQuestionpool(), ilBadge\deleteStaticFiles(), assQuestion\deleteSuggestedSolutions(), ilObjSurvey\deleteSurveyRecord(), ilObjTest\deleteTest(), ilObjCmiXapi\doDelete(), ilObjFileBasedLMGUI\exportHTML(), ilExportContainer\exportObject(), ilObjSAHSLearningModuleGUI\importFile(), ilObjTestGUI\importFile(), ilObjQuestionPoolGUI\importFile(), ilObjSurveyQuestionPool\importObject(), ilObjQuestionPoolGUI\importQuestionsFile(), ILIAS\Blog\Export\BlogHtmlExport\initDirectories(), ILIAS\Notes\Export\NotesHtmlExport\initDirectories(), ilDataCollectionExportOptionsXLSX\onDeleteFiles(), ILIAS\Export\ExportHandler\Consumer\ExportOption\BasicLegacyHandler\onDeleteFiles(), ilMediaPoolExportOptionXMLMaster\onDeleteFiles(), ilMediaPoolExportOptionXMLMasterNoMedia\onDeleteFiles(), ilTestExportOptionARC\onDeleteFiles(), assKprimChoice\removeAnswerImage(), ilObjTest\removeTestResultsByActiveIds(), rRenameSuffix(), ILIAS\MediaCast\BackgroundTasks\DownloadAllZipJob\run(), ilZipJob\run(), ilCalendarZipJob\run(), assMultipleChoice\saveAdditionalQuestionDataToDb(), ilOrgUnitExporter\sendAndCreateSimpleExportFile(), ilUserCertificateZip\zipCertificatesInArchiveDirectory(), and ILIAS\Notes\Export\NotesHtmlExport\zipPackage().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ dirsize()

static ilFileUtils::dirsize ( string  $directory)
static

get size of a directory or a file.

Parameters
stringpath to a directory or a file
Returns
integer. Returns -1, if the directory does not exist.

Definition at line 263 of file class.ilFileUtils.php.

263 : int
264 {
265 $size = 0;
266 if (!is_dir($directory)) {
267 // dirsize of non-existing directory
268 $size = @filesize($directory);
269 return ($size === false) ? -1 : $size;
270 }
271 if ($DIR = opendir($directory)) {
272 while (($dirfile = readdir($DIR)) !== false) {
273 if (is_link(
274 $directory . DIRECTORY_SEPARATOR . $dirfile
275 )) {
276 continue;
277 }
278 if ($dirfile === '.') {
279 continue;
280 }
281 if ($dirfile === '..') {
282 continue;
283 }
284 if (is_file($directory . DIRECTORY_SEPARATOR . $dirfile)) {
285 $size += filesize(
286 $directory . DIRECTORY_SEPARATOR . $dirfile
287 );
288 } elseif (is_dir($directory . DIRECTORY_SEPARATOR . $dirfile)) {
289 $dirSize = ilFileUtils::dirsize(
290 $directory . DIRECTORY_SEPARATOR . $dirfile
291 );
292 if ($dirSize >= 0) {
293 $size += $dirSize;
294 } else {
295 return -1;
296 }
297 }
298 }
299 closedir($DIR);
300 }
301 return $size;
302 }
static dirsize(string $directory)
get size of a directory or a file.

References dirsize().

Referenced by ilObjFileBasedLMAccess\_lookupDiskUsage(), ilObjMediaCastAccess\_lookupDiskUsage(), ilObjSAHSLearningModuleAccess\_lookupDiskUsage(), and dirsize().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getASCIIFilename()

static ilFileUtils::getASCIIFilename ( string  $a_filename)
static
Deprecated:

Definition at line 662 of file class.ilFileUtils.php.

662 : string
663 {
664 global $DIC;
665 $policy = new ilFileServicesPolicy($DIC->fileServiceSettings());
666 return $policy->ascii($a_filename);
667 }
Class ilFileServicesPolicy.
global $DIC
Definition: shib_login.php:26

References $DIC.

Referenced by ILIAS\Wiki\Export\WikiHtmlExport\buildExportFile(), ilExerciseManagementCollectFilesJob\collectAssignmentData(), ilDownloadFilesBackgroundTask\collectFiles(), ilObjTest\deliverPDFfromFO(), ilSurveyParticipantsGUI\exportAllCodesObject(), ilSurveyParticipantsGUI\exportCodesObject(), ilSurveyEvaluationGUI\exportEvaluationUser(), ilObjExercise\exportGradesExcel(), ilContainerGUI\getBucketTitle(), ilObjWorkspaceFolderGUI\getBucketTitle(), ilExSubmission\getDirectoryNameFromUserData(), ilAssFileUploadUploadsExporter\getDispoZipFileName(), ilTestParticipantData\getFileSystemCompliantFullnameByActiveId(), ilVerificationObject\getOfflineFilename(), ilObjTest\getTitleFilenameCompliant(), assQuestion\getTitleFilenameCompliant(), ilAssFileUploadUploadsExporter\initFilenames(), ilDclMobRecordFieldModel\parseValue(), ilCollectFilesJob\recurseFolder(), ilDownloadFilesBackgroundTask\run(), ilDownloadContainerFilesBackgroundTask\run(), ilDownloadSubmissionsBackgroundTask\run(), ILIAS\MediaCast\BackgroundTasks\DownloadAllBackgroundTask\run(), ilDownloadWorkspaceFolderBackgroundTask\run(), ilQtiMatImageSecurity\sanitizeLabel(), and ILIAS\Test\ExportImport\CertificateExport\write().

+ Here is the caller graph for this function:

◆ getDataDir()

static ilFileUtils::getDataDir ( )
static

get data directory (outside webspace)

Deprecated:
in favour of the filesystem service which should be used to operate on the storage directory.
See also
\ILIAS\DI\Containerfilesystem()
\ILIAS\Filesystem\Filesystems::storage()

Definition at line 250 of file class.ilFileUtils.php.

250 : string
251 {
252 return CLIENT_DATA_DIR;
253 }
const CLIENT_DATA_DIR
Definition: constants.php:46

References CLIENT_DATA_DIR.

Referenced by ilAdvancedMDRecordImportFiles\__construct(), ilObjTest\_createImportDirectory(), ilHtmlPurifierAbstractLibWrapper\_getCacheDirectory(), ilObjCategoryGUI\_getImportDir(), assLongMenu\buildFolderName(), ilObjStyleSheet\cleanExportDirectory(), ilDclPropertyFormGUI\cleanupTempFiles(), ilSimpleSAMLphpConfigTemplateHandler\copy(), ilChatroomConfigFileHandler\createDataDirIfNotExists(), ilObjStyleSheet\createExportDirectory(), ilObjSurvey\createExportDirectory(), ilObjSurveyQuestionPool\createExportDirectory(), ilObjTest\createExportDirectory(), ilObjQuestionPool\createExportDirectory(), ilObjUserFolder\createExportDirectory(), ilObjContentObject\createImportDirectory(), ilObjStyleSheet\createImportDirectory(), ilObjSurvey\createImportDirectory(), ilObjSurveyQuestionPool\createImportDirectory(), ilObjSurveyQuestionPool\deleteAllData(), ilObjQuestionPool\deleteQuestionpool(), ilObjSurvey\deleteSurveyRecord(), ilObjTest\deleteTest(), ilImportDirectory\getAbsolutePath(), ilExportImportDirectory\getAbsolutePathForHash(), ilSamlAuthFactory\getConfigDirectory(), ilObjContentObject\getDataDirectory(), ILIAS\AdvancedMetaData\Setup\RecordFilesMigration\getExportDir(), ilObjQuestionPool\getExportDirectory(), ilObjSurvey\getExportDirectory(), ilObjSurveyQuestionPool\getExportDirectory(), ilObjTest\getExportDirectory(), ilObjUserFolder\getExportDirectory(), ilObjContentObject\getExportDirectory(), ilObjContentObject\getImportDirectory(), ilObjSurvey\getImportDirectory(), ilObjSurveyQuestionPool\getImportDirectory(), ILIAS\Authentication\Password\LocalUserPasswordManager\getInstance(), ilFSStorageMail\getRelativePathExMailDirectory(), ilLMMultiSrt\getUploadDir(), ilMepMultiSrt\getUploadDir(), ilObjUserFolderGUI\handleUploadedFiles(), ilTempnam(), ilObjUserFolderGUI\importUserRoleAssignmentObject(), ilObjUserFolderGUI\importUsersObject(), ilXmlExporter\lookupExportDirectory(), ilTestQuestionPoolExporter\lookupExportDirectory(), ilDclPropertyFormGUI\rebuildTempFileByHash(), ilPropertyFormGUI\rebuildUploadedFiles(), ILIAS\ILIASObject\Properties\AdditionalProperties\Icon\Custom\saveFromTempFileName(), and ilObjStudyProgramme\updateCustomIcon().

+ Here is the caller graph for this function:

◆ getDir()

static ilFileUtils::getDir ( string  $a_dir,
bool  $a_rec = false,
?string  $a_sub_dir = "" 
)
static

get directory

Parameters
string$a_dir
bool$a_rec
string | null$a_sub_dir
Returns
array
Deprecated:
in favour of Filesystem::listContents() located at the filesystem service.
See also
\ILIAS\Filesystem\Filesystem::listContents()

Definition at line 565 of file class.ilFileUtils.php.

569 : array {
570 $current_dir = opendir($a_dir . $a_sub_dir);
571
572 $dirs = [];
573 $files = [];
574 $subitems = [];
575 while ($entry = readdir($current_dir)) {
576 if (is_dir($a_dir . "/" . $entry)) {
577 $dirs[$entry] = [
578 "type" => "dir",
579 "entry" => $entry,
580 "subdir" => $a_sub_dir
581 ];
582 if ($a_rec && $entry !== "." && $entry !== "..") {
584 $a_dir,
585 true,
586 $a_sub_dir . "/" . $entry
587 );
588 $subitems = array_merge($subitems, $si);
589 }
590 } elseif ($entry !== "." && $entry !== "..") {
591 $size = filesize($a_dir . $a_sub_dir . "/" . $entry);
592 $files[$entry] = [
593 "type" => "file",
594 "entry" => $entry,
595 "size" => $size,
596 "subdir" => $a_sub_dir
597 ];
598 }
599 }
600 ksort($dirs);
601 ksort($files);
602
603 return array_merge($dirs, $files, $subitems);
604 }
static getDir(string $a_dir, bool $a_rec=false, ?string $a_sub_dir="")
get directory

References getDir().

Referenced by assOrderingQuestion\cleanImagefiles(), ilFileDataMail\getAttachmentPathAndFilenameByMd5Hash(), getDir(), ilCertificateUtilHelper\getDir(), ilFileSystemGUI\getFileList(), ILIAS\AdvancedMetaData\Setup\RecordFilesMigration\getFiles(), ilUploadDirFilesTableGUI\getFiles(), ilObjMediaObject\getMultiSrtFiles(), ilMobMultiSrtUpload\getMultiSrtFiles(), ilObjUser\getPersonalDataExportFile(), and ilFileSystemGUI\unzipFile().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getFileSizeInfo()

static ilFileUtils::getFileSizeInfo ( )
static

Definition at line 649 of file class.ilFileUtils.php.

649 : string
650 {
651 global $DIC;
652 $size = new DataSize(self::getPhpUploadSizeLimitInBytes(), DataSize::MB);
653 $max_filesize = $size->__toString();
654 $lng = $DIC->language();
655
656 return $lng->txt("file_notice") . " $max_filesize.";
657 }
This class provides the data size with additional information to remove the work to calculate the siz...
Definition: DataSize.php:31
global $lng
Definition: privfeed.php:31

References $DIC, and $lng.

Referenced by ilTinyMCE\addCustomRTESupport(), ilKprimChoiceWizardInputGUI\insert(), ilMatchingWizardInputGUI\insert(), ilMultipleChoiceWizardInputGUI\insert(), ilSingleChoiceWizardInputGUI\insert(), ilAssMultipleChoiceCorrectionsInputGUI\insert(), ilAssSingleChoiceCorrectionsInputGUI\insert(), and ilMultipleImagesInputGUI\render().

+ Here is the caller graph for this function:

◆ getPhpUploadSizeLimitInBytes()

static ilFileUtils::getPhpUploadSizeLimitInBytes ( )
static
Deprecated:
should use DataSize instead

Definition at line 805 of file class.ilFileUtils.php.

805 : string
806 {
807 $convertPhpIniSizeValueToBytes = function ($phpIniSizeValue) {
808 if (is_numeric($phpIniSizeValue)) {
809 return $phpIniSizeValue;
810 }
811
812 $suffix = substr($phpIniSizeValue, -1);
813 $value = substr($phpIniSizeValue, 0, -1);
814
815 switch (strtoupper($suffix)) {
816 case 'P':
817 $value *= 1024;
818 // no break
819 case 'T':
820 $value *= 1024;
821 // no break
822 case 'G':
823 $value *= 1024;
824 // no break
825 case 'M':
826 $value *= 1024;
827 // no break
828 case 'K':
829 $value *= 1024;
830 break;
831 }
832
833 return $value;
834 };
835
836 $uploadSizeLimitBytes = min(
837 $convertPhpIniSizeValueToBytes(ini_get('post_max_size')),
838 $convertPhpIniSizeValueToBytes(ini_get('upload_max_filesize'))
839 );
840
841 return $uploadSizeLimitBytes;
842 }

Referenced by ilDAVContainer\createFile(), ILIAS\FileServices\FileServicesLegacyInitialisationAdapter\getPhpUploadLimitInBytes(), ilDAVFile\put(), and ILIAS\FileUpload\FileUploadImpl\uploadSizeLimit().

+ Here is the caller graph for this function:

◆ getSafeFilename()

static ilFileUtils::getSafeFilename ( string  $a_initial_filename)
static

Definition at line 519 of file class.ilFileUtils.php.

519 : string
520 {
521 $file_peaces = explode('.', $a_initial_filename);
522
523 $file_extension = array_pop($file_peaces);
524
525 if (SUFFIX_REPL_ADDITIONAL) {
526 $string_extensions = SUFFIX_REPL_DEFAULT . "," . SUFFIX_REPL_ADDITIONAL;
527 } else {
528 $string_extensions = SUFFIX_REPL_DEFAULT;
529 }
530
531 $sufixes = explode(",", $string_extensions);
532
533 if (in_array($file_extension, $sufixes)) {
534 $file_extension = "sec";
535 }
536
537 $file_peaces[] = $file_extension;
538
539 $safe_filename = "";
540 foreach ($file_peaces as $piece) {
541 $safe_filename .= "$piece";
542 if ($piece != end($file_peaces)) {
543 $safe_filename .= ".";
544 }
545 }
546
547 return $safe_filename;
548 }

Referenced by ilExAssignment\instructionFileInsertOrder().

+ Here is the caller graph for this function:

◆ getValidFilename()

static ilFileUtils::getValidFilename ( string  $a_filename)
static

◆ getWebspaceDir()

static ilFileUtils::getWebspaceDir ( string  $mode = "filesystem")
static

get webspace directory

Parameters
string$modeuse "filesystem" for filesystem operations and "output" for output operations, e.g. images
Returns
string
Deprecated:
in favour of the filesystem service which should be used for operations on the web dir.
See also
\ILIAS\DI\Containerfilesystem()
Filesystems::web()

Definition at line 621 of file class.ilFileUtils.php.

621 : string
622 {
623 if ($mode === "filesystem") {
624 return "./" . ILIAS_WEB_DIR . "/" . CLIENT_ID;
625 }
626 if (defined("ILIAS_MODULE")) {
627 return "../" . ILIAS_WEB_DIR . "/" . CLIENT_ID;
628 }
629 return "./" . ILIAS_WEB_DIR . "/" . CLIENT_ID;
630 }
const CLIENT_ID
Definition: constants.php:41
const ILIAS_WEB_DIR
Definition: constants.php:45

References CLIENT_ID, and ILIAS_WEB_DIR.

Referenced by ilObjFileBasedLMAccess\_determineStartUrl(), ilContainer\_getContainerDirectory(), ilObjStyleSheet\_getImagesDirectory(), ilObjFileBasedLMAccess\_lookupDiskUsage(), ilObjSAHSLearningModuleAccess\_lookupDiskUsage(), ilCmiXapiLaunchGUI\buildLaunchLink(), ilContainer\createContainerDirectory(), ilObjSAHSLearningModule\createDataDirectory(), ILIAS\ILIASObject\Properties\AdditionalProperties\Icon\Custom\createFromImportDir(), ilObjStyleSheet\delete(), ilPageObjectGUI\displayMedia(), ilObjCmiXapi\doCloneObject(), ilObjCmiXapi\doDelete(), ilCOPageHTMLExport\exportHTMLMOB(), ilCOPageHTMLExport\exportQuestionFiles(), ilStudyProgrammeTypeCustomIconsFormGUI\fillForm(), ilLTIConsumeProviderIcon\getAbsoluteFilePath(), ilCmiXapiContentUploadImporter\getAbsoluteObjectDirectory(), ilDidacticTemplateIconHandler\getAbsolutePath(), ilPCInteractiveImage\getBackgroundImage(), ilBadgeHandler\getBasePath(), ilObjMediaObject\getDataDirectory(), ilObjSAHSLearningModule\getDataDirectory(), ILIAS\ILIASObject\Properties\AdditionalProperties\Icon\Custom\getFullPath(), ilOpenIdConnectSettings\getImageFilePath(), ilFileDataCourse\getOnlineLink(), ilFSStorageMail\getRelativePathExMailDirectory(), ilLMPresentationGUI\ilMedia(), ilUserCertificateGUI\listCertificates(), ilGlossaryPresentationGUI\media(), ilCmiXapiImporter\prepareLocalSourceStorage(), ilObjUserGUI\removeUserPictureObject(), ilCmiXapiContentUploadImporter\sanitizeObjectDirectory(), ilObjMediaPoolGUI\showMedia(), ilPageObjectGUI\showMediaFullscreen(), ilPageObjectGUI\showPage(), and ilLMPresentationGUI\showPrintView().

+ Here is the caller graph for this function:

◆ ilTempnam()

static ilFileUtils::ilTempnam ( ?string  $a_temp_path = null)
static

Returns a unique and non existing Path for e temporary file or directory.

Parameters
string | null$a_temp_path
Returns
string

Definition at line 676 of file class.ilFileUtils.php.

676 : string
677 {
678 $temp_path = $a_temp_path ?? ilFileUtils::getDataDir() . "/temp";
679
680 if (!is_dir($temp_path)) {
682 }
683 $temp_name = $temp_path . "/" . uniqid("tmp");
684
685 return $temp_name;
686 }
static getDataDir()
get data directory (outside webspace)
static createDirectory(string $a_dir, int $a_mod=0755)
create directory

References createDirectory(), and getDataDir().

Referenced by ilImagemapPreview\__construct(), ilObjUserFolder\buildExportFile(), ilTestArchiveService\buildOverviewFilename(), ilVirusScanner\createBufferFile(), ILIAS\MediaCast\BackgroundTasks\DownloadAllCollectFilesJob\createDirectory(), ilRestFileStorage\createFile(), ilAdvancedMDParser\createLocalRecord(), ilTestExportGUI\createTestArchiveExport(), ilCopyFilesToTempDirectoryJob\createUniqueTempDirectory(), ilCalendarCopyFilesToTempDirectoryJob\createUniqueTempDirectory(), ilExerciseManagementCollectFilesJob\createUniqueTempDirectory(), ilCopyWorkspaceFilesToTempDirectoryJob\createUniqueTempDirectory(), ilObjTest\deliverPDFfromFO(), ilMediaItem\determineDuration(), ilPageLayoutAdministrationGUI\exportLayout(), ILIAS\Test\ExportImport\ExportFilename\getPathname(), CustomIconUploadHandlerGUI\getUploadResult(), ilUserDataSet\getXmlRecord(), ilFileXMLParser\handlerEndTag(), assOrderingQuestionImport\handleUploadedFile(), ilObjSAHSLearningModuleGUI\importFile(), ilAssFileUploadUploadsExporter\initFilenames(), ilObjectCommonSettingFormAdapter\saveIcon(), ilExcel\sendToClient(), ilRestFileStorage\storeFileForRest(), ilECSConnector\updateResource(), ilCalendarCategoryGUI\uploadAppointments(), ilObjLanguageExtGUI\uploadObject(), ILIAS\Test\ExportImport\ResultsExportExcel\write(), and ilExcel\writeToTmpFile().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ makeDir()

static ilFileUtils::makeDir ( string  $a_dir)
static

creates a new directory and inherits all filesystem permissions of the parent directory You may pass only the name of your new directory or with the entire path or relative path information.

examples: a_dir = /tmp/tests/your_dir a_dir = ../tests/your_dir a_dir = your_dir (--> creates your_dir in current directory)

@access public

Parameters
string[path] + directory name
Returns
boolean
Deprecated:
in favour of Filesystem::createDir() located at the filesystem service.
See also
\ILIAS\Filesystem\Filesystem::createDir()

Definition at line 322 of file class.ilFileUtils.php.

322 : bool
323 {
324 $a_dir = trim($a_dir);
325
326 // remove trailing slash (bugfix for php 4.2.x)
327 if (str_ends_with($a_dir, "/")) {
328 $a_dir = substr($a_dir, 0, -1);
329 }
330
331 // check if a_dir comes with a path
332 if (($path = substr(
333 $a_dir,
334 0,
335 strrpos($a_dir, "/") - strlen($a_dir)
336 )) === '' || ($path = substr(
337 $a_dir,
338 0,
339 strrpos($a_dir, "/") - strlen($a_dir)
340 )) === '0') {
341 $path = ".";
342 }
343
344 // create directory with file permissions of parent directory
345 if (is_dir($a_dir)) {
346 return true;
347 }
348 $old_mask = umask(0000);
349 $result = @mkdir($a_dir, fileperms($path));
350 umask($old_mask);
351
352 return $result;
353 }
$path
Definition: ltiservices.php:30

References $path.

Referenced by ilFileDataCourse\__checkImportPath(), ilFileDataCourse\__checkPath(), ilFileDataCourse\__initDirectory(), ilObjStyleSheet\_createImagesDirectory(), ilObjTest\_createImportDirectory(), ilFileDataCourse\addDirectory(), ilSurveyExport\buildExportFileXML(), ilQuestionpoolExport\buildExportFileXML(), ilContainer\createContainerDirectory(), ilObjSAHSLearningModule\createDataDirectory(), ilChatroomConfigFileHandler\createDataDirIfNotExists(), ilCOPageHTMLExport\createDirectories(), ilFileSystemGUI\createDirectory(), createDirectory(), ilObjStyleSheet\createExportDirectory(), ilObjSurvey\createExportDirectory(), ilObjSurveyQuestionPool\createExportDirectory(), ilObjTest\createExportDirectory(), ilObjQuestionPool\createExportDirectory(), ilObjUserFolder\createExportDirectory(), ilObjStyleSheet\createExportSubDirectory(), ilObjContentObject\createImportDirectory(), ilObjStyleSheet\createImportDirectory(), ilObjSurvey\createImportDirectory(), ilObjSurveyQuestionPool\createImportDirectory(), ilFileDataCourse\createOnlineVersion(), ilMediaItem\determineDuration(), ilObjTest\exportFileItems(), ilObjQuestionPool\exportFileItems(), ilObjFileBasedLMGUI\exportHTML(), ilCOPageHTMLExport\exportHTMLFile(), ilCOPageHTMLExport\exportHTMLMOB(), ilPageLayoutAdministrationGUI\exportLayout(), ilObjLanguageExt\getDataPath(), ilUserDataSet\getXmlRecord(), ilObjSAHSLearningModuleGUI\importFile(), ILIAS\Blog\Export\BlogHtmlExport\initDirectories(), ILIAS\Notes\Export\NotesHtmlExport\initDirectories(), ilFileDataImport\initExportDirectory(), ilSCORM13PlayerGUI\logDirectory(), ilForumXMLWriter\start(), and ILIAS\Test\ExportImport\Export\write().

+ Here is the caller graph for this function:

◆ makeDirParents()

static ilFileUtils::makeDirParents ( string  $a_dir)
static

Create a new directory and all parent directories.

Creates a new directory and inherits all filesystem permissions of the parent directory If the parent directories doesn't exist, they will be created recursively. The directory name NEEDS TO BE an absolute path, because it seems that relative paths are not working with PHP's file_exists function.

Parameters
string$a_dirThe directory name to be created @access public
Returns
bool
Author
Helmut Schottmüller hscho.nosp@m.ttm@.nosp@m.tzi.d.nosp@m.e
Deprecated:
in favour of Filesystem::createDir() located at the filesystem service.
See also
\ILIAS\Filesystem\Filesystem::createDir()

Definition at line 188 of file class.ilFileUtils.php.

188 : bool
189 {
190 $dirs = [$a_dir];
191 $a_dir = dirname($a_dir);
192 $last_dirname = '';
193 while ($last_dirname !== $a_dir) {
194 array_unshift($dirs, $a_dir);
195 $last_dirname = $a_dir;
196 $a_dir = dirname($a_dir);
197 }
198
199 // find the first existing dir
200 $reverse_paths = array_reverse($dirs, true);
201 $found_index = -1;
202 foreach ($reverse_paths as $key => $value) {
203 if ($found_index != -1) {
204 continue;
205 }
206 if (!is_dir($value)) {
207 continue;
208 }
209 $found_index = $key;
210 }
211
212 $old_mask = umask(0000);
213 foreach ($dirs as $dirindex => $dir) {
214 // starting with the longest existing path
215 if ($dirindex >= $found_index) {
216 if (!file_exists($dir)) {
217 if (strcmp(substr($dir, strlen($dir) - 1, 1), "/") == 0) {
218 // on some systems there is an error when there is a slash
219 // at the end of a directory in mkdir, see Mantis #2554
220 $dir = substr($dir, 0, strlen($dir) - 1);
221 }
222 if (!mkdir($dir)) {
223 error_log("Can't make directory: $dir");
224 return false;
225 }
226 } elseif (!is_dir($dir)) {
227 error_log("$dir is not a directory");
228 return false;
229 } else {
230 // get umask of the last existing parent directory
231 $umask = fileperms($dir);
232 }
233 }
234 }
235 umask($old_mask);
236
237 return true;
238 }

Referenced by ilHtmlPurifierAbstractLibWrapper\_getCacheDirectory(), ilExportContainer\addSubitems(), assLongMenu\assertDirExists(), ilQuestionpoolExport\buildExportFileXML(), ilCopyFilesToTempDirectoryJob\copyFiles(), ilCopyWorkspaceFilesToTempDirectoryJob\copyFiles(), ilExerciseManagementCollectFilesJob\copyFileToSubDirectory(), ilCalendarCopyFilesToTempDirectoryJob\copyWithAbsolutePath(), ilCalendarCopyFilesToTempDirectoryJob\copyWithRId(), ilIndividualAssessmentFileStorage\create(), ilUserCertificateZip\createArchiveDirectory(), ilTestArchiver\createArchiveForTest(), ilLoggingErrorFileStorage\createDir(), ilCOPageHTMLExport\createDirectories(), ilSystemStyleHTMLExport\createDirectories(), ILIAS\MediaCast\BackgroundTasks\DownloadAllCollectFilesJob\createDirectory(), ilObjMediaObject\createDirectory(), ilExplorerBaseGUI\createHTMLExportDirs(), ilExerciseManagementCollectFilesJob\createTargetDirectory(), ilCopyFilesToTempDirectoryJob\createTargetDirectory(), ilCalendarCopyFilesToTempDirectoryJob\createTargetDirectory(), ilCopyWorkspaceFilesToTempDirectoryJob\createTargetDirectory(), ilTestExportGUI\createTestArchiveExport(), ilCopyFilesToTempDirectoryJob\createUniqueTempDirectory(), ilCalendarCopyFilesToTempDirectoryJob\createUniqueTempDirectory(), ilExerciseManagementCollectFilesJob\createUniqueTempDirectory(), ilCopyWorkspaceFilesToTempDirectoryJob\createUniqueTempDirectory(), assQuestion\duplicateSuggestedSolutionFiles(), assOrderingQuestion\ensureImagePathExists(), assOrderingQuestionImport\ensureImagePathExists(), ilDclContentExporter\export(), ilBibliographicDataSet\exportLibraryFile(), ilExportContainer\exportObject(), ilTestResultsToXML\exportParticipantUploadedFiles(), ilCOPageHTMLExport\exportQuestionFiles(), ILIAS\components\Export\HTML\Util\exportResourceFile(), ilCOPageHTMLExport\exportStyles(), ILIAS\User\Export\UserHtmlExport\exportUserImages(), ilBadgeHandler\getBadgePath(), ilObjSurvey\getImportDirectory(), ilBadgeHandler\getInstancePath(), ilBibliographicExporter\getXmlRepresentation(), ilContentPageExporter\getXmlRepresentation(), ilDataCollectionExporter\getXmlRepresentation(), ilForumExporter\getXmlRepresentation(), ilIndividualAssessmentExporter\getXmlRepresentation(), ilStyleExporter\getXmlRepresentation(), ilSurveyExporter\getXmlRepresentation(), assKprimChoice\handleFileUpload(), ilAdvancedMDRecordImportFiles\init(), ilFSStorageCourse\initInfoDirectory(), ilFSStorageCourse\initMemberExportDirectory(), ilFSStorageGroup\initMemberExportDirectory(), ilFSStoragePRG\initMemberExportDirectory(), ilObjSurveyQuestionPool\pasteFromClipboard(), ilObjQuestionPool\pasteFromClipboard(), assMatchingQuestionImport\saveImage(), assFileUpload\savePreviewData(), ilOrgUnitExporter\sendAndCreateSimpleExportFile(), assMultipleChoice\setImageFile(), SurveyQuestion\setMaterialsfile(), ilForumXMLWriter\start(), and assQuestionGUI\suggestedsolution().

+ Here is the caller graph for this function:

◆ moveUploadedFile()

static ilFileUtils::moveUploadedFile ( string  $a_file,
string  $a_name,
string  $a_target,
bool  $a_raise_errors = true,
string  $a_mode = "move_uploaded" 
)
static

move uploaded file

Parameters
string$a_file
string$a_name
string$a_target
bool$a_raise_errors
string$a_mode
Returns
bool
Exceptions
ilExceptionThrown if no uploaded files are found and raise error is set to true.
Deprecated:
in favour of the FileUpload service.
See also
\ILIAS\DI\Containerupload()

Definition at line 398 of file class.ilFileUtils.php.

404 : bool {
405 global $DIC;
406 $main_tpl = $DIC->ui()->mainTemplate();
407 $target_filename = basename($a_target);
408
409 $target_filename = ilFileUtils::getValidFilename($target_filename);
410
411 // Make sure the target is in a valid subfolder. (e.g. no uploads to ilias/setup_/....)
412 [$target_filesystem, $target_dir] = self::sanitateTargetPath($a_target);
413
414 $upload = $DIC->upload();
415
416 // If the upload has not yet been processed make sure he gets processed now.
417 if (!$upload->hasBeenProcessed()) {
418 $upload->process();
419 }
420
421 try {
422 if (!$upload->hasUploads()) {
423 throw new ilException(
424 $DIC->language()->txt("upload_error_file_not_found")
425 );
426 }
427 $upload_result = $upload->getResults()[$a_file] ?? null;
428 if ($upload_result instanceof UploadResult) {
429 if (!$upload_result->isOK()) {
430 throw new ilException($upload_result->getStatus()->getMessage());
431 }
432 } else {
433 return false;
434 }
435 } catch (ilException $e) {
436 if (!$a_raise_errors) {
437 $main_tpl->setOnScreenMessage('failure', $e->getMessage(), true);
438 } else {
439 throw $e;
440 }
441
442 return false;
443 }
444
445 $upload->moveOneFileTo(
446 $upload_result,
447 $target_dir,
448 $target_filesystem,
449 $target_filename,
450 true
451 );
452
453 return true;
454 }
Base class for ILIAS Exception handling.
static sanitateTargetPath(string $a_target)
static getValidFilename(string $a_filename)

Referenced by ilCourseFile\create(), assKprimChoice\handleFileUpload(), ilObjStyleSheet\import(), ilAdvancedMDRecordImportFiles\moveUploadedFile(), ilObjSCORMLearningModuleGUI\newModuleVersionUpload(), assFileUpload\savePreviewData(), assMultipleChoice\setImageFile(), SurveyQuestion\setMaterialsfile(), assOrderingQuestion\storeImageFile(), ilFileDataMail\storeUploadedFile(), assQuestionGUI\suggestedsolution(), ilPCInteractiveImageGUI\update(), ilCalendarCategoryGUI\uploadAppointments(), ilIndividualAssessmentFileStorage\uploadFile(), ilBadge\uploadImage(), ilBadgeImageTemplate\uploadImage(), ilObjSAHSLearningModuleGUI\uploadObject(), and ilObjSurveyQuestionPoolGUI\uploadQuestionsObject().

+ Here is the caller graph for this function:

◆ rCopy()

static ilFileUtils::rCopy ( string  $a_sdir,
string  $a_tdir,
bool  $preserveTimeAttributes = false 
)
static

Copies content of a directory $a_sdir recursively to a directory $a_tdir.

Parameters
string$a_sdirsource directory
string$a_tdirtarget directory
boolean$preserveTimeAttributesif true, ctime will be kept.
Returns
boolean TRUE for sucess, FALSE otherwise
Exceptions
DirectoryNotFoundException
FileNotFoundException
IOException@access public
Deprecated:
in favour of Filesystem::copyDir() located at the filesystem service.
See also
Filesystem::copyDir()

Definition at line 132 of file class.ilFileUtils.php.

136 : bool {
137 $sourceFS = LegacyPathHelper::deriveFilesystemFrom($a_sdir);
138 $targetFS = LegacyPathHelper::deriveFilesystemFrom($a_tdir);
139
140 $sourceDir = LegacyPathHelper::createRelativePath($a_sdir);
141 $targetDir = LegacyPathHelper::createRelativePath($a_tdir);
142
143 // check if arguments are directories
144 if (!$sourceFS->hasDir($sourceDir)) {
145 return false;
146 }
147
148 $sourceList = $sourceFS->listContents($sourceDir, true);
149
150 foreach ($sourceList as $item) {
151 if ($item->isDir()) {
152 continue;
153 }
154 try {
155 $itemPath = $targetDir . '/' . substr(
156 $item->getPath(),
157 strlen($sourceDir)
158 );
159 $stream = $sourceFS->readStream($item->getPath());
160 $targetFS->writeStream($itemPath, $stream);
162 // Do nothing with that type of exception
163 }
164 }
165
166 return true;
167 }

Referenced by ilObjStyleSheet\copyImagesToDir(), ILIAS\ILIASObject\Properties\AdditionalProperties\Icon\Custom\createFromImportDir(), ilFileDataCourse\createOnlineVersion(), ilObjCmiXapi\doCloneObject(), ilObjStyleSheet\export(), ilObjFileBasedLMGUI\exportHTML(), ilCOPageHTMLExport\exportHTMLMOB(), ilCOPageHTMLExport\exportQuestionFiles(), ilCOPageHTMLExport\exportStyles(), ilObjSAHSLearningModule\populateByDirectoy(), and ilFileDataCourse\rCopy().

+ Here is the caller graph for this function:

◆ recursive_dirscan()

static ilFileUtils::recursive_dirscan ( string  $dir,
array &  $arr 
)
static

Recursively scans a given directory and writes path and filename into referenced array.

Parameters
string$dirDirectory to start from
array&$arrReferenced array which is filled with Filename and path
Exceptions
ilFileUtilsException
Deprecated:
Will be removed completely with ILIAS 9

Definition at line 46 of file class.ilFileUtils.php.

46 : void
47 {
48 global $DIC;
49
50 $lng = $DIC->language();
51
52 $dirlist = opendir($dir);
53 while (false !== ($file = readdir($dirlist))) {
54 if (!is_file($dir . "/" . $file) && !is_dir($dir . "/" . $file)) {
55 throw new ilFileUtilsException(
56 $lng->txt("filenames_not_supported"),
58 );
59 }
60
61 if ($file !== '.' && $file !== '..') {
62 $newpath = $dir . '/' . $file;
63 $level = explode('/', $newpath);
64 if (is_dir($newpath)) {
65 ilFileUtils::recursive_dirscan($newpath, $arr);
66 } else {
67 $arr["path"][] = $dir . "/";
68 $arr["file"][] = end($level);
69 }
70 }
71 }
72 closedir($dirlist);
73 }
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static recursive_dirscan(string $dir, array &$arr)
Recursively scans a given directory and writes path and filename into referenced array.

References ilFileUtilsException\$BROKEN_FILE, $DIC, $lng, and recursive_dirscan().

Referenced by recursive_dirscan(), and ilFileSystemGUI\unzipFile().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ removeTrailingPathSeparators()

◆ rename()

static ilFileUtils::rename ( string  $a_source,
string  $a_target 
)
static
Deprecated:

Definition at line 100 of file class.ilFileUtils.php.

100 : bool
101 {
102 $pi = pathinfo($a_target);
103 global $DIC;
104 $sanitizer = new ilFileServicesFilenameSanitizer(
105 $DIC->fileServiceSettings()
106 );
107
108 if (!$sanitizer->isClean($a_target)) {
109 throw new ilFileUtilsException("Invalid target file");
110 }
111
112 return rename($a_source, $a_target);
113 }
static rename(string $a_source, string $a_target)

References $DIC, and rename().

Referenced by ilAssFileUploadUploadsExporter\createFileUploadCollectionZipFile(), ilObjSAHSLearningModuleGUI\importFile(), ilObjSCORMLearningModuleGUI\newModuleVersionUpload(), ilDclMobRecordFieldModel\parseValue(), ilObjSurveyQuestionPool\pasteFromClipboard(), rename(), ilFileSystemGUI\renameFile(), ilFileDataMail\rotateFiles(), and assOrderingQuestion\updateImageFile().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ renameExecutables()

static ilFileUtils::renameExecutables ( string  $a_dir)
static
Deprecated:

Definition at line 715 of file class.ilFileUtils.php.

715 : void
716 {
717 $def_arr = explode(",", SUFFIX_REPL_DEFAULT);
718 foreach ($def_arr as $def) {
719 self::rRenameSuffix($a_dir, trim($def), "sec");
720 }
721
722 $def_arr = explode(",", SUFFIX_REPL_ADDITIONAL);
723 foreach ($def_arr as $def) {
724 self::rRenameSuffix($a_dir, trim($def), "sec");
725 }
726 }
static rRenameSuffix(string $a_dir, string $a_old_suffix, string $a_new_suffix)
Renames all files with certain suffix and gives them a new suffix.

Referenced by ilObjSAHSLearningModuleGUI\importFile(), ilObjSCORMLearningModuleGUI\newModuleVersionUpload(), ilDclMobRecordFieldModel\parseValue(), ilObjSAHSLearningModule\populateByDirectoy(), ilFileSystemGUI\renameFile(), ilCmiXapiContentUploadImporter\sanitizeObjectDirectory(), assQuestionGUI\suggestedsolution(), ilFileSystemGUI\unzipFile(), ilFileSystemGUI\uploadFile(), and ilObjSAHSLearningModuleGUI\uploadObject().

+ Here is the caller graph for this function:

◆ rRenameSuffix()

static ilFileUtils::rRenameSuffix ( string  $a_dir,
string  $a_old_suffix,
string  $a_new_suffix 
)
static

Renames all files with certain suffix and gives them a new suffix.

This words recursively through a directory.

Deprecated:

Definition at line 734 of file class.ilFileUtils.php.

734 : bool
735 {
736 if ($a_dir === "/" || $a_dir === "" || is_int(strpos($a_dir, ".."))
737 || trim($a_old_suffix) === "") {
738 return false;
739 }
740
741 // check if argument is directory
742 if (!@is_dir($a_dir)) {
743 return false;
744 }
745
746 // read a_dir
747 $dir = opendir($a_dir);
748
749 while ($file = readdir($dir)) {
750 if ($file !== "." && $file !== "..") {
751 // triple dot is not allowed in filenames
752 if ($file === '...') {
753 unlink($a_dir . "/" . $file);
754 continue;
755 }
756 // directories
757 if (@is_dir($a_dir . "/" . $file)) {
758 ilFileUtils::rRenameSuffix($a_dir . "/" . $file, $a_old_suffix, $a_new_suffix);
759 }
760
761 // files
762 if (@is_file($a_dir . "/" . $file)) {
763 // first check for files with trailing dot
764 if (strrpos($file, '.') == (strlen($file) - 1)) {
765 try {
766 rename($a_dir . '/' . $file, substr($a_dir . '/' . $file, 0, -1));
767 } catch (Throwable) {
768 // to avoid exploits we do delete this file and continue renaming
769 unlink($a_dir . '/' . $file);
770 continue;
771 }
772 $file = substr($file, 0, -1);
773 }
774
775 $path_info = pathinfo($a_dir . "/" . $file);
776
777 if (strtolower($path_info["extension"] ?? '') === strtolower($a_old_suffix)) {
778 $pos = strrpos($a_dir . "/" . $file, ".");
779 $new_name = substr($a_dir . "/" . $file, 0, $pos) . "." . $a_new_suffix;
780 // check if file exists
781 if (file_exists($new_name)) {
782 if (is_dir($new_name)) {
783 ilFileUtils::delDir($new_name);
784 } else {
785 unlink($new_name);
786 }
787 }
788 rename($a_dir . "/" . $file, $new_name);
789 }
790 }
791 }
792 }
793 return true;
794 }

References delDir(), and rRenameSuffix().

Referenced by ilObjMediaObject\renameExecutables(), and rRenameSuffix().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ sanitateTargetPath()

static ilFileUtils::sanitateTargetPath ( string  $a_target)
staticprotected

Definition at line 355 of file class.ilFileUtils.php.

355 : array
356 {
357 $target_file_system = match (true) {
358 str_starts_with($a_target, 'public/' . ILIAS_WEB_DIR . '/' . CLIENT_ID),
359 str_starts_with($a_target, './public/' . ILIAS_WEB_DIR . '/' . CLIENT_ID),
360 str_starts_with($a_target, '/' . ILIAS_WEB_DIR . '/' . CLIENT_ID),
361 str_starts_with($a_target, './' . ILIAS_WEB_DIR . '/' . CLIENT_ID),
362 str_starts_with($a_target, CLIENT_WEB_DIR) => Location::WEB,
363
364 str_starts_with($a_target, CLIENT_DATA_DIR . "/temp") => Location::TEMPORARY,
365 str_starts_with($a_target, CLIENT_DATA_DIR) => Location::STORAGE,
366
367 str_starts_with($a_target, ILIAS_ABSOLUTE_PATH . '/public/Customizing') => Location::CUSTOMIZING,
368 default => throw new InvalidArgumentException(
369 "Can not move files to \"$a_target\" because path can not be mapped to web, storage or customizing location."
370 ),
371 };
372
373 $absolute_target_dir = dirname($a_target);
374 $target_dir = LegacyPathHelper::createRelativePath($absolute_target_dir);
375
376 return [$target_file_system, $target_dir];
377 }
const CLIENT_WEB_DIR
Definition: constants.php:47

References CLIENT_DATA_DIR, CLIENT_ID, CLIENT_WEB_DIR, and ILIAS_WEB_DIR.

◆ unzip()

static ilFileUtils::unzip ( string  $a_file,
bool  $overwrite = false,
bool  $a_flat = false 
)
static

unzip file

Parameters
string$a_filefull path/filename
boolean$overwritepass true to overwrite existing files

Definition at line 696 of file class.ilFileUtils.php.

696 : bool
697 {
698 if (defined('DEVMODE') && DEVMODE) {
699 trigger_error('Deprecated method called: ' . __METHOD__, E_USER_DEPRECATED);
700 }
701
702 global $DIC;
703 return $DIC->legacyArchives()->unzip(
704 $a_file,
705 null,
706 $overwrite,
707 $a_flat,
708 false
709 );
710 }

References $DIC.

◆ utf8_encode()

static ilFileUtils::utf8_encode ( string  $string)
static
Deprecated:
in ILIAS 9 for ILIAS 10: Use Refinery\String\Encoding instead

Definition at line 78 of file class.ilFileUtils.php.

78 : string
79 {
80 global $DIC;
81 return $DIC->refinery()->string()->encoding()->latin1ToUtf8()->transform($string);
82 }

References $DIC.

◆ zip()

static ilFileUtils::zip ( string  $a_dir,
string  $a_file,
bool  $compress_content = false 
)
static
Deprecated:
Please refactor your code using $DIC->archives()->zip() (recommended) or $DIC->legacyArchives()->zip() instead.

Definition at line 459 of file class.ilFileUtils.php.

463 : bool {
464 global $DIC;
465 // ensure top directory should be the same behaviour as before, if you need it to be different, you should legacyArchives directly
466 return $DIC->legacyArchives()->zip($a_dir, $a_file, true);
467 }

Referenced by ilSurveyExport\buildExportFileXML(), ilQuestionpoolExport\buildExportFileXML(), ilTestArchiver\compressTestArchive(), ilAssFileUploadUploadsExporter\createFileUploadCollectionZipFile(), ilSkinStyleContainer\createTempZip(), ilObjStyleSheet\export(), ilObjFileBasedLMGUI\exportHTML(), ilExportContainer\exportObject(), ILIAS\MediaCast\BackgroundTasks\DownloadAllZipJob\run(), ilCalendarZipJob\run(), ilOrgUnitExporter\sendAndCreateSimpleExportFile(), ILIAS\Test\ExportImport\Export\write(), ilUserCertificateZip\zipCertificatesInArchiveDirectory(), ilFileDataCourse\zipFile(), and ILIAS\Notes\Export\NotesHtmlExport\zipPackage().

+ Here is the caller graph for this function:

The documentation for this class was generated from the following file: