Some updates:
[core.git] / framework / main / classes / fuse / class_FrameworkFuseWrapper.php_discontinued
1 <?php
2 // Own namespace
3 namespace Org\Mxchange\CoreFramework\Wrapper\Fuse;
4
5 // Import framework stuff
6 use Org\Mxchange\CoreFramework\Registry\Registerable;
7
8 // Import library stuff
9 use \FuseWrapper;
10
11 /**
12  * A class for binding to the FUSE wrapper. This class requires the PHP
13  * extension fuse.dll/so being added to your setup. If you want to use this
14  * class, please activate and use the FUSE feature instead of using this class
15  * directly. This gives you all required pre-tests. Please read there for
16  * more detailed informations.
17  *
18  * @author              Roland Haeder <webmaster@ship-simu.org>
19  * @version             0.0.0
20 <<<<<<< HEAD:framework/main/classes/fuse/class_FrameworkFuseWrapper.php_discontinued
21  * @copyright   Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2017 Core Developer Team
22 =======
23  * @copyright   Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2016 Core Developer Team
24 >>>>>>> Some updates::inc/main/classes/fuse/class_FrameworkFuseWrapper.php
25  * @license             GNU GPL 3.0 or any newer version
26  * @link                http://www.ship-simu.org
27  *
28  * This program is free software: you can redistribute it and/or modify
29  * it under the terms of the GNU General Public License as published by
30  * the Free Software Foundation, either version 3 of the License, or
31  * (at your option) any later version.
32  *
33  * This program is distributed in the hope that it will be useful,
34  * but WITHOUT ANY WARRANTY; without even the implied warranty of
35  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
36  * GNU General Public License for more details.
37  *
38  * You should have received a copy of the GNU General Public License
39  * along with this program. If not, see <http://www.gnu.org/licenses/>.
40  */
41 class FrameworkFuseWrapper extends FuseWrapper implements Registerable {
42         /**
43          * Get attributes
44          *
45          * @param       $path   Path to get attributes from
46          * @param       $stbuf  An instance of a FuseStat class
47          * @return      Status code
48          */
49         public function FsGetAttr ($path, FuseStat $stbuf) {
50                 if (strcmp($path, '/') == 0 ) {
51                         $stbuf->st_mode = FUSE_S_IFDIR | 0750;
52                         $stbuf->st_nlink = 2;
53                 } else {
54                         $stbuf->st_uid   = posix_getuid();
55                         $stbuf->st_gid   = posix_getgid();
56                         $stbuf->st_mode  = FUSE_S_IFREG | 0640;
57                         $stbuf->st_nlink = 1;
58                         $stbuf->st_size  = 56;
59                         $stbuf->st_mtime = 1226379246;
60                 }
61
62                 return -FUSE_ENOERR;
63         }
64
65         /**
66          * Open operation
67          *
68          * @param       $path   Path to open
69          * @param       $fi             An instance of a FuseFileInfo class
70          * @return      Status code
71          */
72         public function FsOpen ($path, FuseFileInfo $fi) {
73                 if (($fi->flags & FUSE_O_ACCMODE) != FUSE_O_RDONLY) {
74                         return -FUSE_ENOACCES;
75                 } // END - if
76
77                 return -FUSE_ENOERR;
78         }
79
80         /**
81          * Read operation
82          *
83          * @param       $path   Path to open
84          * @param       $buf    Read data
85          * @param       $size   Maximum expected size (?)
86          * @param       $offset Seek offset
87          * @param       $fi             An instance of a FuseFileInfo class
88          * @return      Length of read data
89          */
90         public function FsRead ($path, &$buf, $size, $offset, FuseFileInfo $fi) {
91                 $data = 'You have implemented your first FUSE file system with PHP!' . PHP_EOL;
92
93                 if ($offset > strlen($data)) {
94                         return 0;
95                 } // END - if
96
97                 $buf = substr( $data, $offset, $size );
98
99                 return strlen($data);
100         }
101
102         /**
103          * Read directory operation
104          *
105          * @param       $path   Path to open
106          * @param       $buf    An array with all read entries
107          * @return      Status code
108          */
109         public function FsReadDir ($path, array &$buf) {
110                 if (strcmp($path, '/') != 0) {
111                         return -FUSE_ENOENT;
112                 } // END - if
113
114                 $buf[] = '.';
115                 $buf[] = '..';
116                 $buf[] = 'helloworld.txt';
117
118                 return -FUSE_ENOERR;
119         }
120
121 }