streamwrapper.php 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  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. return true;
  52. } else {
  53. return false;//not supported
  54. }
  55. }
  56. public function getFile($path, $target) {
  57. return copy($this->constructUrl($path), $target);
  58. }
  59. public function uploadFile($path, $target) {
  60. return copy($path, $this->constructUrl($target));
  61. }
  62. public function rename($path1, $path2) {
  63. return rename($this->constructUrl($path1), $this->constructUrl($path2));
  64. }
  65. public function stat($path) {
  66. return stat($this->constructUrl($path));
  67. }
  68. }