PageRenderTime 55ms CodeModel.GetById 26ms RepoModel.GetById 0ms app.codeStats 0ms

/apps/files_external/lib/streamwrapper.php

https://github.com/sezuan/core
PHP | 84 lines | 61 code | 17 blank | 6 comment | 4 complexity | 7357aa83b8b6322e26c4b09e54a5cf66 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. namespace OC\Files\Storage;
  9. abstract class StreamWrapper extends Common{
  10. abstract public function constructUrl($path);
  11. public function mkdir($path) {
  12. return mkdir($this->constructUrl($path));
  13. }
  14. public function rmdir($path) {
  15. if($this->file_exists($path)) {
  16. $success = rmdir($this->constructUrl($path));
  17. clearstatcache();
  18. return $success;
  19. } else {
  20. return false;
  21. }
  22. }
  23. public function opendir($path) {
  24. return opendir($this->constructUrl($path));
  25. }
  26. public function filetype($path) {
  27. return filetype($this->constructUrl($path));
  28. }
  29. public function isReadable($path) {
  30. return true;//not properly supported
  31. }
  32. public function isUpdatable($path) {
  33. return true;//not properly supported
  34. }
  35. public function file_exists($path) {
  36. return file_exists($this->constructUrl($path));
  37. }
  38. public function unlink($path) {
  39. $success = unlink($this->constructUrl($path));
  40. clearstatcache();
  41. return $success;
  42. }
  43. public function fopen($path, $mode) {
  44. return fopen($this->constructUrl($path), $mode);
  45. }
  46. public function touch($path, $mtime=null) {
  47. if(is_null($mtime)) {
  48. $fh = $this->fopen($path, 'a');
  49. fwrite($fh, '');
  50. fclose($fh);
  51. } else {
  52. return false;//not supported
  53. }
  54. }
  55. public function getFile($path, $target) {
  56. return copy($this->constructUrl($path), $target);
  57. }
  58. public function uploadFile($path, $target) {
  59. return copy($path, $this->constructUrl($target));
  60. }
  61. public function rename($path1, $path2) {
  62. return rename($this->constructUrl($path1), $this->constructUrl($path2));
  63. }
  64. public function stat($path) {
  65. return stat($this->constructUrl($path));
  66. }
  67. }