Files.php 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. <?php
  2. /**
  3. * SPDX-FileCopyrightText: 2016-2024 Nextcloud GmbH and Nextcloud contributors
  4. * SPDX-FileCopyrightText: 2016 ownCloud, Inc.
  5. * SPDX-License-Identifier: AGPL-3.0-only
  6. */
  7. // use OCP namespace for all classes that are considered public.
  8. // This means that they should be used by apps instead of the internal Nextcloud classes
  9. namespace OCP;
  10. /**
  11. * This class provides access to the internal filesystem abstraction layer. Use
  12. * this class exclusively if you want to access files
  13. * @since 5.0.0
  14. * @deprecated 14.0.0
  15. */
  16. class Files {
  17. /**
  18. * Recursive deletion of folders
  19. * @return bool
  20. * @since 5.0.0
  21. * @deprecated 14.0.0
  22. */
  23. public static function rmdirr($dir) {
  24. return \OC_Helper::rmdirr($dir);
  25. }
  26. /**
  27. * Get the mimetype form a local file
  28. * @param string $path
  29. * @return string
  30. * does NOT work for ownClouds filesystem, use OC_FileSystem::getMimeType instead
  31. * @since 5.0.0
  32. * @deprecated 14.0.0
  33. */
  34. public static function getMimeType($path) {
  35. return \OC::$server->getMimeTypeDetector()->detect($path);
  36. }
  37. /**
  38. * Search for files by mimetype
  39. * @param string $mimetype
  40. * @return array
  41. * @since 6.0.0
  42. * @deprecated 14.0.0
  43. */
  44. public static function searchByMime($mimetype) {
  45. return \OC\Files\Filesystem::searchByMime($mimetype);
  46. }
  47. /**
  48. * Copy the contents of one stream to another
  49. * @param resource $source
  50. * @param resource $target
  51. * @return int the number of bytes copied
  52. * @since 5.0.0
  53. * @deprecated 14.0.0
  54. */
  55. public static function streamCopy($source, $target) {
  56. [$count, ] = \OC_Helper::streamCopy($source, $target);
  57. return $count;
  58. }
  59. /**
  60. * Adds a suffix to the name in case the file exists
  61. * @param string $path
  62. * @param string $filename
  63. * @return string
  64. * @since 5.0.0
  65. * @deprecated 14.0.0 use getNonExistingName of the OCP\Files\Folder object
  66. */
  67. public static function buildNotExistingFileName($path, $filename) {
  68. return \OC_Helper::buildNotExistingFileName($path, $filename);
  69. }
  70. /**
  71. * Gets the Storage for an app - creates the needed folder if they are not
  72. * existent
  73. * @param string $app
  74. * @return \OC\Files\View
  75. * @since 5.0.0
  76. * @deprecated 14.0.0 use IAppData instead
  77. */
  78. public static function getStorage($app) {
  79. return \OC_App::getStorage($app);
  80. }
  81. }