]> git.mxchange.org Git - core.git/commitdiff
Test class added (nothing really implemented so far).
authorRoland Haeder <roland@mxchange.org>
Tue, 25 Aug 2015 17:12:33 +0000 (19:12 +0200)
committerRoland Haeder <roland@mxchange.org>
Tue, 25 Aug 2015 17:12:33 +0000 (19:12 +0200)
Signed-off-by: Roland Häder <roland@mxchange.org>
inc/main/classes/fuse/.htaccess [new file with mode: 0644]
inc/main/classes/fuse/class_FrameworkFuseWrapper.php [new file with mode: 0644]

diff --git a/inc/main/classes/fuse/.htaccess b/inc/main/classes/fuse/.htaccess
new file mode 100644 (file)
index 0000000..3a42882
--- /dev/null
@@ -0,0 +1 @@
+Deny from all
diff --git a/inc/main/classes/fuse/class_FrameworkFuseWrapper.php b/inc/main/classes/fuse/class_FrameworkFuseWrapper.php
new file mode 100644 (file)
index 0000000..5a0a055
--- /dev/null
@@ -0,0 +1,110 @@
+<?php
+/**
+ * A class for binding to the FUSE wrapper. This class requires the PHP
+ * extension fuse.dll/so being added to your setup. If you want to use this
+ * class, please activate and use the FUSE feature instead of this class
+ * directly. This gives you all required pre-tests. Please read there for
+ * more detailed informations.
+ *
+ * @author             Roland Haeder <webmaster@ship-simu.org>
+ * @version            0.0.0
+ * @copyright  Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team
+ * @license            GNU GPL 3.0 or any newer version
+ * @link               http://www.ship-simu.org
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+public class FrameworkFuseWrapper extends FuseWrapper implements Registerable {
+       /**
+        * Get attributes
+        *
+        * @param       $path   Path to get attributes from
+        * @param       $stbuf  An instance of a FuseStat class
+        * @return      Status code
+        */
+       public function FsGetAttr ($path, FuseStat $stbuf) {
+               if (strcmp($path, '/') == 0 ) {
+                       $stbuf->st_mode = FUSE_S_IFDIR | 0750;
+                       $stbuf->st_nlink = 2;
+               } else {
+                       $stbuf->st_uid   = posix_getuid();
+                       $stbuf->st_gid   = posix_getgid();
+                       $stbuf->st_mode  = FUSE_S_IFREG | 0640;
+                       $stbuf->st_nlink = 1;
+                       $stbuf->st_size  = 56;
+                       $stbuf->st_mtime = 1226379246;
+               }
+
+               return -FUSE_ENOERR;
+       }
+
+       /**
+        * Open operation
+        *
+        * @param       $path   Path to open
+        * @param       $fi             An instance of a FuseFileInfo class
+        * @return      Status code
+        */
+       public function FsOpen ($path, FuseFileInfo $fi) {
+               if (($fi->flags & FUSE_O_ACCMODE) != FUSE_O_RDONLY) {
+                       return -FUSE_ENOACCES;
+               } // END - if
+
+               return -FUSE_ENOERR;
+       }
+
+       /**
+        * Read operation
+        *
+        * @param       $path   Path to open
+        * @param       $buf    Read data
+        * @param       $size   Maximum expected size (?)
+        * @param       $offset Seek offset
+        * @param       $fi             An instance of a FuseFileInfo class
+        * @return      Length of read data
+        */
+       public function FsRead ($path, &$buf, $size, $offset, FuseFileInfo $fi) {
+               $data = 'You have implemented your first FUSE file system with PHP!' . PHP_EOL;
+
+               if ($offset > strlen($data)) {
+                       return 0;
+               } // END - if
+
+               $buf = substr( $data, $offset, $size );
+
+               return strlen($data);
+       }
+
+       /**
+        * Read directory operation
+        *
+        * @param       $path   Path to open
+        * @param       $buf    An array with all read entries
+        * @return      Status code
+        */
+       public function FsReadDir ($path, array &$buf) {
+               if (strcmp($path, '/') != 0) {
+                       return -FUSE_ENOENT;
+               } // END - if
+
+               $buf[] = '.';
+               $buf[] = '..';
+               $buf[] = 'helloworld.txt';
+
+               return -FUSE_ENOERR;
+       }
+}
+
+// [EOF]
+?>