From: Roland Haeder Date: Tue, 25 Aug 2015 17:12:33 +0000 (+0200) Subject: Test class added (nothing really implemented so far). X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=cce93583f1b92d609e38e67a5967bfaefd6bdb97;p=core.git Test class added (nothing really implemented so far). Signed-off-by: Roland Häder --- diff --git a/inc/main/classes/fuse/.htaccess b/inc/main/classes/fuse/.htaccess new file mode 100644 index 00000000..3a428827 --- /dev/null +++ b/inc/main/classes/fuse/.htaccess @@ -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 index 00000000..5a0a055f --- /dev/null +++ b/inc/main/classes/fuse/class_FrameworkFuseWrapper.php @@ -0,0 +1,110 @@ + + * @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 . + */ +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] +?>