files.php 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. <?php
  2. /**
  3. * ownCloud
  4. *
  5. * @author Frank Karlitschek
  6. * @copyright 2012 Frank Karlitschek frank@owncloud.org
  7. *
  8. * This library is free software; you can redistribute it and/or
  9. * modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE
  10. * License as published by the Free Software Foundation; either
  11. * version 3 of the License, or any later version.
  12. *
  13. * This library is distributed in the hope that it will be useful,
  14. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16. * GNU AFFERO GENERAL PUBLIC LICENSE for more details.
  17. *
  18. * You should have received a copy of the GNU Affero General Public
  19. * License along with this library. If not, see <http://www.gnu.org/licenses/>.
  20. *
  21. */
  22. /**
  23. * Public interface of ownCloud for apps to use.
  24. * Files Class
  25. *
  26. */
  27. // use OCP namespace for all classes that are considered public.
  28. // This means that they should be used by apps instead of the internal ownCloud classes
  29. namespace OCP;
  30. /**
  31. * This class provides access to the internal filesystem abstraction layer. Use this class exlusively if you want to access files
  32. */
  33. class Files {
  34. /**
  35. * @brief Recusive deletion of folders
  36. * @param string $dir path to the folder
  37. *
  38. * @return bool
  39. */
  40. static function rmdirr( $dir ) {
  41. return \OC_Helper::rmdirr( $dir );
  42. }
  43. /**
  44. * get the mimetype form a local file
  45. * @param string path
  46. * @return string
  47. * does NOT work for ownClouds filesystem, use OC_FileSystem::getMimeType instead
  48. */
  49. static function getMimeType( $path ) {
  50. return(\OC_Helper::getMimeType( $path ));
  51. }
  52. /**
  53. * copy the contents of one stream to another
  54. * @param resource source
  55. * @param resource target
  56. * @return int the number of bytes copied
  57. */
  58. public static function streamCopy( $source, $target ) {
  59. return(\OC_Helper::streamCopy( $source, $target ));
  60. }
  61. /**
  62. * create a temporary file with an unique filename
  63. * @param string postfix
  64. * @return string
  65. *
  66. * temporary files are automatically cleaned up after the script is finished
  67. */
  68. public static function tmpFile( $postfix='' ) {
  69. return(\OC_Helper::tmpFile( $postfix ));
  70. }
  71. /**
  72. * create a temporary folder with an unique filename
  73. * @return string
  74. *
  75. * temporary files are automatically cleaned up after the script is finished
  76. */
  77. public static function tmpFolder() {
  78. return(\OC_Helper::tmpFolder());
  79. }
  80. /**
  81. * Adds a suffix to the name in case the file exists
  82. *
  83. * @param $path
  84. * @param $filename
  85. * @return string
  86. */
  87. public static function buildNotExistingFileName( $path, $filename ) {
  88. return(\OC_Helper::buildNotExistingFileName( $path, $filename ));
  89. }
  90. /**
  91. * @param string appid
  92. * @param $app app
  93. * @return \OC\Files\View
  94. */
  95. public static function getStorage( $app ) {
  96. return \OC_App::getStorage( $app );
  97. }
  98. }