PageRenderTime 47ms CodeModel.GetById 17ms RepoModel.GetById 1ms app.codeStats 0ms

/lib/legacy/filesystem.php

https://github.com/sezuan/core
PHP | 415 lines | 141 code | 48 blank | 226 comment | 0 complexity | 4806b86558e7e6b811e68008a8909acd MD5 | raw file
Possible License(s): AGPL-3.0, AGPL-1.0, MPL-2.0-no-copyleft-exception
  1. <?php
  2. /**
  3. * Copyright (c) 2012 Robin Appelman <icewind@owncloud.com>
  4. * This file is licensed under the Affero General Public License version 3 or
  5. * later.
  6. * See the COPYING-README file.
  7. */
  8. /**
  9. * Class for abstraction of filesystem functions
  10. * This class won't call any filesystem functions for itself but but will pass them to the correct OC_Filestorage object
  11. * this class should also handle all the file permission related stuff
  12. *
  13. * Hooks provided:
  14. * read(path)
  15. * write(path, &run)
  16. * post_write(path)
  17. * create(path, &run) (when a file is created, both create and write will be emitted in that order)
  18. * post_create(path)
  19. * delete(path, &run)
  20. * post_delete(path)
  21. * rename(oldpath,newpath, &run)
  22. * post_rename(oldpath,newpath)
  23. * copy(oldpath,newpath, &run) (if the newpath doesn't exists yes, copy, create and write will be emitted in that order)
  24. * post_rename(oldpath,newpath)
  25. *
  26. * the &run parameter can be set to false to prevent the operation from occurring
  27. */
  28. /**
  29. * @deprecated OC_Filesystem is replaced by \OC\Files\Filesystem
  30. */
  31. class OC_Filesystem {
  32. /**
  33. * get the mountpoint of the storage object for a path
  34. * ( note: because a storage is not always mounted inside the fakeroot, the
  35. * returned mountpoint is relative to the absolute root of the filesystem
  36. * and doesn't take the chroot into account )
  37. *
  38. * @deprecated OC_Filesystem is replaced by \OC\Files\Filesystem
  39. * @param string $path
  40. * @return string
  41. */
  42. static public function getMountPoint($path) {
  43. return \OC\Files\Filesystem::getMountPoint($path);
  44. }
  45. /**
  46. * resolve a path to a storage and internal path
  47. *
  48. * @deprecated OC_Filesystem is replaced by \OC\Files\Filesystem
  49. * @param string $path
  50. * @return array consisting of the storage and the internal path
  51. */
  52. static public function resolvePath($path) {
  53. return \OC\Files\Filesystem::resolvePath($path);
  54. }
  55. /**
  56. * @deprecated OC_Filesystem is replaced by \OC\Files\Filesystem
  57. */
  58. static public function init($user, $root) {
  59. return \OC\Files\Filesystem::init($user, $root);
  60. }
  61. /**
  62. * get the default filesystem view
  63. *
  64. * @deprecated OC_Filesystem is replaced by \OC\Files\Filesystem
  65. * @return \OC\Files\View
  66. */
  67. static public function getView() {
  68. return \OC\Files\Filesystem::getView();
  69. }
  70. /**
  71. * tear down the filesystem, removing all storage providers
  72. *
  73. * @deprecated OC_Filesystem is replaced by \OC\Files\Filesystem
  74. */
  75. static public function tearDown() {
  76. \OC\Files\Filesystem::tearDown();
  77. }
  78. /**
  79. * @brief get the relative path of the root data directory for the current user
  80. * @return string
  81. *
  82. * @deprecated OC_Filesystem is replaced by \OC\Files\Filesystem
  83. * Returns path like /admin/files
  84. */
  85. static public function getRoot() {
  86. return \OC\Files\Filesystem::getRoot();
  87. }
  88. /**
  89. * clear all mounts and storage backends
  90. *
  91. * @deprecated OC_Filesystem is replaced by \OC\Files\Filesystem
  92. */
  93. public static function clearMounts() {
  94. \OC\Files\Filesystem::clearMounts();
  95. }
  96. /**
  97. * mount an \OC\Files\Storage\Storage in our virtual filesystem
  98. *
  99. * @deprecated OC_Filesystem is replaced by \OC\Files\Filesystem
  100. * @param \OC\Files\Storage\Storage $class
  101. * @param array $arguments
  102. * @param string $mountpoint
  103. */
  104. static public function mount($class, $arguments, $mountpoint) {
  105. \OC\Files\Filesystem::mount($class, $arguments, $mountpoint);
  106. }
  107. /**
  108. * return the path to a local version of the file
  109. * we need this because we can't know if a file is stored local or not from
  110. * outside the filestorage and for some purposes a local file is needed
  111. *
  112. * @deprecated OC_Filesystem is replaced by \OC\Files\Filesystem
  113. * @param string $path
  114. * @return string
  115. */
  116. static public function getLocalFile($path) {
  117. return \OC\Files\Filesystem::getLocalFile($path);
  118. }
  119. /**
  120. * @deprecated OC_Filesystem is replaced by \OC\Files\Filesystem
  121. * @param string $path
  122. * @return string
  123. */
  124. static public function getLocalFolder($path) {
  125. return \OC\Files\Filesystem::getLocalFolder($path);
  126. }
  127. /**
  128. * return path to file which reflects one visible in browser
  129. *
  130. * @deprecated OC_Filesystem is replaced by \OC\Files\Filesystem
  131. * @param string $path
  132. * @return string
  133. */
  134. static public function getLocalPath($path) {
  135. return \OC\Files\Filesystem::getLocalPath($path);
  136. }
  137. /**
  138. * check if the requested path is valid
  139. *
  140. * @deprecated OC_Filesystem is replaced by \OC\Files\Filesystem
  141. * @param string $path
  142. * @return bool
  143. */
  144. static public function isValidPath($path) {
  145. return \OC\Files\Filesystem::isValidPath($path);
  146. }
  147. /**
  148. * checks if a file is blacklisted for storage in the filesystem
  149. * Listens to write and rename hooks
  150. *
  151. * @deprecated OC_Filesystem is replaced by \OC\Files\Filesystem
  152. * @param array $data from hook
  153. */
  154. static public function isBlacklisted($data) {
  155. \OC\Files\Filesystem::isBlacklisted($data);
  156. }
  157. /**
  158. * following functions are equivalent to their php builtin equivalents for arguments/return values.
  159. *
  160. * @deprecated OC_Filesystem is replaced by \OC\Files\Filesystem
  161. */
  162. static public function mkdir($path) {
  163. return \OC\Files\Filesystem::mkdir($path);
  164. }
  165. /**
  166. * @deprecated OC_Filesystem is replaced by \OC\Files\Filesystem
  167. */
  168. static public function rmdir($path) {
  169. return \OC\Files\Filesystem::rmdir($path);
  170. }
  171. /**
  172. * @deprecated OC_Filesystem is replaced by \OC\Files\Filesystem
  173. */
  174. static public function opendir($path) {
  175. return \OC\Files\Filesystem::opendir($path);
  176. }
  177. /**
  178. * @deprecated OC_Filesystem is replaced by \OC\Files\Filesystem
  179. */
  180. static public function readdir($path) {
  181. return \OC\Files\Filesystem::readdir($path);
  182. }
  183. /**
  184. * @deprecated OC_Filesystem is replaced by \OC\Files\Filesystem
  185. */
  186. static public function is_dir($path) {
  187. return \OC\Files\Filesystem::is_dir($path);
  188. }
  189. /**
  190. * @deprecated OC_Filesystem is replaced by \OC\Files\Filesystem
  191. */
  192. static public function is_file($path) {
  193. return \OC\Files\Filesystem::is_file($path);
  194. }
  195. /**
  196. * @deprecated OC_Filesystem is replaced by \OC\Files\Filesystem
  197. */
  198. static public function stat($path) {
  199. return \OC\Files\Filesystem::stat($path);
  200. }
  201. /**
  202. * @deprecated OC_Filesystem is replaced by \OC\Files\Filesystem
  203. */
  204. static public function filetype($path) {
  205. return \OC\Files\Filesystem::filetype($path);
  206. }
  207. /**
  208. * @deprecated OC_Filesystem is replaced by \OC\Files\Filesystem
  209. */
  210. static public function filesize($path) {
  211. return \OC\Files\Filesystem::filesize($path);
  212. }
  213. /**
  214. * @deprecated OC_Filesystem is replaced by \OC\Files\Filesystem
  215. */
  216. static public function readfile($path) {
  217. return \OC\Files\Filesystem::readfile($path);
  218. }
  219. /**
  220. * @deprecated Replaced by isReadable() as part of CRUDS
  221. */
  222. static public function is_readable($path) {
  223. return \OC\Files\Filesystem::isReadable($path);
  224. }
  225. /**
  226. * @deprecated OC_Filesystem is replaced by \OC\Files\Filesystem
  227. */
  228. static public function isCreatable($path) {
  229. return \OC\Files\Filesystem::isCreatable($path);
  230. }
  231. /**
  232. * @deprecated OC_Filesystem is replaced by \OC\Files\Filesystem
  233. */
  234. static public function isReadable($path) {
  235. return \OC\Files\Filesystem::isReadable($path);
  236. }
  237. /**
  238. * @deprecated OC_Filesystem is replaced by \OC\Files\Filesystem
  239. */
  240. static public function isUpdatable($path) {
  241. return \OC\Files\Filesystem::isUpdatable($path);
  242. }
  243. /**
  244. * @deprecated OC_Filesystem is replaced by \OC\Files\Filesystem
  245. */
  246. static public function isDeletable($path) {
  247. return \OC\Files\Filesystem::isDeletable($path);
  248. }
  249. /**
  250. * @deprecated OC_Filesystem is replaced by \OC\Files\Filesystem
  251. */
  252. static public function isSharable($path) {
  253. return \OC\Files\Filesystem::isSharable($path);
  254. }
  255. /**
  256. * @deprecated OC_Filesystem is replaced by \OC\Files\Filesystem
  257. */
  258. static public function file_exists($path) {
  259. return \OC\Files\Filesystem::file_exists($path);
  260. }
  261. /**
  262. * @deprecated OC_Filesystem is replaced by \OC\Files\Filesystem
  263. */
  264. static public function filemtime($path) {
  265. return \OC\Files\Filesystem::filemtime($path);
  266. }
  267. /**
  268. * @deprecated OC_Filesystem is replaced by \OC\Files\Filesystem
  269. */
  270. static public function touch($path, $mtime = null) {
  271. return \OC\Files\Filesystem::touch($path, $mtime);
  272. }
  273. /**
  274. * @deprecated OC_Filesystem is replaced by \OC\Files\Filesystem
  275. */
  276. static public function file_get_contents($path) {
  277. return \OC\Files\Filesystem::file_get_contents($path);
  278. }
  279. /**
  280. * @deprecated OC_Filesystem is replaced by \OC\Files\Filesystem
  281. */
  282. static public function file_put_contents($path, $data) {
  283. return \OC\Files\Filesystem::file_put_contents($path, $data);
  284. }
  285. /**
  286. * @deprecated OC_Filesystem is replaced by \OC\Files\Filesystem
  287. */
  288. static public function unlink($path) {
  289. return \OC\Files\Filesystem::unlink($path);
  290. }
  291. /**
  292. * @deprecated OC_Filesystem is replaced by \OC\Files\Filesystem
  293. */
  294. static public function rename($path1, $path2) {
  295. return \OC\Files\Filesystem::rename($path1, $path2);
  296. }
  297. /**
  298. * @deprecated OC_Filesystem is replaced by \OC\Files\Filesystem
  299. */
  300. static public function copy($path1, $path2) {
  301. return \OC\Files\Filesystem::copy($path1, $path2);
  302. }
  303. /**
  304. * @deprecated OC_Filesystem is replaced by \OC\Files\Filesystem
  305. */
  306. static public function fopen($path, $mode) {
  307. return \OC\Files\Filesystem::fopen($path, $mode);
  308. }
  309. /**
  310. * @deprecated OC_Filesystem is replaced by \OC\Files\Filesystem
  311. */
  312. static public function toTmpFile($path) {
  313. return \OC\Files\Filesystem::toTmpFile($path);
  314. }
  315. /**
  316. * @deprecated OC_Filesystem is replaced by \OC\Files\Filesystem
  317. */
  318. static public function fromTmpFile($tmpFile, $path) {
  319. return \OC\Files\Filesystem::fromTmpFile($tmpFile, $path);
  320. }
  321. /**
  322. * @deprecated OC_Filesystem is replaced by \OC\Files\Filesystem
  323. */
  324. static public function getMimeType($path) {
  325. return \OC\Files\Filesystem::getMimeType($path);
  326. }
  327. /**
  328. * @deprecated OC_Filesystem is replaced by \OC\Files\Filesystem
  329. */
  330. static public function hash($type, $path, $raw = false) {
  331. return \OC\Files\Filesystem::hash($type, $path, $raw);
  332. }
  333. /**
  334. * @deprecated OC_Filesystem is replaced by \OC\Files\Filesystem
  335. */
  336. static public function free_space($path = '/') {
  337. return \OC\Files\Filesystem::free_space($path);
  338. }
  339. /**
  340. * @deprecated OC_Filesystem is replaced by \OC\Files\Filesystem
  341. */
  342. static public function search($query) {
  343. return \OC\Files\Filesystem::search($query);
  344. }
  345. /**
  346. * check if a file or folder has been updated since $time
  347. *
  348. * @deprecated OC_Filesystem is replaced by \OC\Files\Filesystem
  349. * @param string $path
  350. * @param int $time
  351. * @return bool
  352. */
  353. static public function hasUpdated($path, $time) {
  354. return \OC\Files\Filesystem::hasUpdated($path, $time);
  355. }
  356. /**
  357. * normalize a path
  358. *
  359. * @deprecated OC_Filesystem is replaced by \OC\Files\Filesystem
  360. * @param string $path
  361. * @param bool $stripTrailingSlash
  362. * @return string
  363. */
  364. public static function normalizePath($path, $stripTrailingSlash = true) {
  365. return \OC\Files\Filesystem::normalizePath($path, $stripTrailingSlash);
  366. }
  367. }