summaryrefslogtreecommitdiffstats
path: root/apps/files_external/3rdparty/icewind/smb/src/NativeFileInfo.php
diff options
context:
space:
mode:
authorRobin Appelman <icewind@owncloud.com>2014-08-26 18:46:07 +0200
committerThomas Müller <thomas.mueller@tmit.eu>2015-02-16 13:52:11 +0100
commitd2255a1d304aa5e537e8aa097add2a51aa0e5d89 (patch)
tree79801d54149e6c8037e717a1d5d6ac43327eb6db /apps/files_external/3rdparty/icewind/smb/src/NativeFileInfo.php
parent78febb2ee594bac5d483f7c8534ed5eb33c2c528 (diff)
downloadnextcloud-server-d2255a1d304aa5e537e8aa097add2a51aa0e5d89.tar.gz
nextcloud-server-d2255a1d304aa5e537e8aa097add2a51aa0e5d89.zip
New SMB storage backend
Diffstat (limited to 'apps/files_external/3rdparty/icewind/smb/src/NativeFileInfo.php')
-rw-r--r--apps/files_external/3rdparty/icewind/smb/src/NativeFileInfo.php142
1 files changed, 142 insertions, 0 deletions
diff --git a/apps/files_external/3rdparty/icewind/smb/src/NativeFileInfo.php b/apps/files_external/3rdparty/icewind/smb/src/NativeFileInfo.php
new file mode 100644
index 00000000000..6ef5cf0c5b9
--- /dev/null
+++ b/apps/files_external/3rdparty/icewind/smb/src/NativeFileInfo.php
@@ -0,0 +1,142 @@
+<?php
+/**
+ * Copyright (c) 2014 Robin Appelman <icewind@owncloud.com>
+ * This file is licensed under the Licensed under the MIT license:
+ * http://opensource.org/licenses/MIT
+ */
+
+namespace Icewind\SMB;
+
+class NativeFileInfo implements IFileInfo {
+ const MODE_FILE = 0100000;
+
+ /**
+ * @var string
+ */
+ protected $path;
+
+ /**
+ * @var string
+ */
+ protected $name;
+
+ /**
+ * @var \Icewind\SMB\NativeShare
+ */
+ protected $share;
+
+ /**
+ * @var array | null
+ */
+ protected $statCache;
+
+ /**
+ * @var int
+ */
+ protected $modeCache;
+
+ /**
+ * @param \Icewind\SMB\NativeShare $share
+ * @param string $path
+ * @param string $name
+ * @param array $stat
+ */
+ public function __construct($share, $path, $name, $stat = null) {
+ $this->share = $share;
+ $this->path = $path;
+ $this->name = $name;
+ $this->statCache = $stat;
+ }
+
+ /**
+ * @return string
+ */
+ public function getPath() {
+ return $this->path;
+ }
+
+ /**
+ * @return string
+ */
+ public function getName() {
+ return $this->name;
+ }
+
+ /**
+ * @return array
+ */
+ protected function stat() {
+ if (!$this->statCache) {
+ $this->statCache = $this->share->getStat($this->getPath());
+ }
+ return $this->statCache;
+ }
+
+ /**
+ * @return int
+ */
+ public function getSize() {
+ $stat = $this->stat();
+ return $stat['size'];
+ }
+
+ /**
+ * @return int
+ */
+ public function getMTime() {
+ $stat = $this->stat();
+ return $stat['mtime'];
+ }
+
+ /**
+ * @return bool
+ */
+ public function isDirectory() {
+ $stat = $this->stat();
+ return !($stat['mode'] & self::MODE_FILE);
+ }
+
+ /**
+ * @return int
+ */
+ protected function getMode() {
+ if (!$this->modeCache) {
+ $attribute = $this->share->getAttribute($this->path, 'system.dos_attr.mode');
+ // parse hex string
+ $this->modeCache = (int)hexdec(substr($attribute, 2));
+ }
+ return $this->modeCache;
+ }
+
+ /**
+ * @return bool
+ */
+ public function isReadOnly() {
+ $mode = $this->getMode();
+ return (bool)($mode & FileInfo::MODE_READONLY);
+ }
+
+ /**
+ * @return bool
+ */
+ public function isHidden() {
+ $mode = $this->getMode();
+ return (bool)($mode & FileInfo::MODE_HIDDEN);
+ }
+
+ /**
+ * @return bool
+ */
+ public function isSystem() {
+ $mode = $this->getMode();
+ return (bool)($mode & FileInfo::MODE_SYSTEM);
+ }
+
+ /**
+ * @return bool
+ */
+ public function isArchived() {
+ $mode = $this->getMode();
+ return (bool)($mode & FileInfo::MODE_ARCHIVE);
+ }
+}