You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

files.php 3.0KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  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
  32. * this class exlusively if you want to access files
  33. */
  34. class Files {
  35. /**
  36. * @brief Recusive deletion of folders
  37. * @param string $dir path to the folder
  38. *
  39. * @return bool
  40. */
  41. static function rmdirr( $dir ) {
  42. return \OC_Helper::rmdirr( $dir );
  43. }
  44. /**
  45. * get the mimetype form a local file
  46. * @param string path
  47. * @return string
  48. * does NOT work for ownClouds filesystem, use OC_FileSystem::getMimeType instead
  49. */
  50. static function getMimeType( $path ) {
  51. return(\OC_Helper::getMimeType( $path ));
  52. }
  53. /**
  54. * search for files by mimetype
  55. *
  56. * @param string $query
  57. * @return array
  58. */
  59. public function searchByMime($mimetype) {
  60. return(\OC\Files\Filesystem::searchByMime( $mimetype ));
  61. }
  62. /**
  63. * copy the contents of one stream to another
  64. * @param resource source
  65. * @param resource target
  66. * @return int the number of bytes copied
  67. */
  68. public static function streamCopy( $source, $target ) {
  69. list($count, $result) = \OC_Helper::streamCopy( $source, $target );
  70. return $count;
  71. }
  72. /**
  73. * create a temporary file with an unique filename
  74. * @param string postfix
  75. * @return string
  76. *
  77. * temporary files are automatically cleaned up after the script is finished
  78. */
  79. public static function tmpFile( $postfix='' ) {
  80. return(\OC_Helper::tmpFile( $postfix ));
  81. }
  82. /**
  83. * create a temporary folder with an unique filename
  84. * @return string
  85. *
  86. * temporary files are automatically cleaned up after the script is finished
  87. */
  88. public static function tmpFolder() {
  89. return(\OC_Helper::tmpFolder());
  90. }
  91. /**
  92. * Adds a suffix to the name in case the file exists
  93. *
  94. * @param $path
  95. * @param $filename
  96. * @return string
  97. */
  98. public static function buildNotExistingFileName( $path, $filename ) {
  99. return(\OC_Helper::buildNotExistingFileName( $path, $filename ));
  100. }
  101. /**
  102. * @param string appid
  103. * @param $app app
  104. * @return \OC\Files\View
  105. */
  106. public static function getStorage( $app ) {
  107. return \OC_App::getStorage( $app );
  108. }
  109. }