22
33namespace React \Filesystem \ChildProcess ;
44
5+ use Exception ;
56use React \EventLoop \LoopInterface ;
67use React \Filesystem \AdapterInterface ;
78use React \Filesystem \CallInvokerInterface ;
8- use React \Filesystem \Node \NodeInterface ;
9- use React \Filesystem \Stream \StreamFactory ;
109use React \Filesystem \FilesystemInterface ;
1110use React \Filesystem \MappedTypeDetector ;
1211use React \Filesystem \ModeTypeDetector ;
12+ use React \Filesystem \Node \NodeInterface ;
1313use React \Filesystem \ObjectStream ;
1414use React \Filesystem \OpenFileLimiter ;
15+ use React \Filesystem \PermissionFlagResolver ;
16+ use React \Filesystem \Stream \StreamFactory ;
1517use React \Filesystem \TypeDetectorInterface ;
1618use React \Promise \FulfilledPromise ;
1719use React \Promise \PromiseInterface ;
@@ -69,6 +71,11 @@ class Adapter implements AdapterInterface
6971 'lsFlags ' => SCANDIR_SORT_NONE ,
7072 ];
7173
74+ /**
75+ * @var PermissionFlagResolver
76+ */
77+ private $ permissionFlagResolver ;
78+
7279 /**
7380 * Adapter constructor.
7481 * @param LoopInterface $loop
@@ -80,6 +87,7 @@ public function __construct(LoopInterface $loop, array $options = [])
8087
8188 $ this ->invoker = \React \Filesystem \getInvoker ($ this , $ options , 'invoker ' , 'React\Filesystem\InstantInvoker ' );
8289 $ this ->openFileLimiter = new OpenFileLimiter (\React \Filesystem \getOpenFileLimit ($ options ));
90+ $ this ->permissionFlagResolver = new PermissionFlagResolver ();
8391
8492 $ this ->setUpPool ($ options );
8593
@@ -148,6 +156,8 @@ public function callFilesystem($function, $args, $errorResultCode = -1)
148156 {
149157 return $ this ->pool ->rpc (Factory::rpc ($ function , $ args ))->then (function (Payload $ payload ) {
150158 return \React \Promise \resolve ($ payload ->getPayload ());
159+ }, function (Payload $ payload ) {
160+ return \React \Promise \reject (new Exception ($ payload ->getPayload ()['error ' ]['error ' ]['message ' ]));
151161 });
152162 }
153163
@@ -160,7 +170,7 @@ public function mkdir($path, $mode = self::CREATION_MODE)
160170 {
161171 return $ this ->invoker ->invokeCall ('mkdir ' , [
162172 'path ' => $ path ,
163- 'mode ' => $ mode ,
173+ 'mode ' => decoct ( $ this -> permissionFlagResolver -> resolve ( $ mode)) ,
164174 ]);
165175 }
166176
@@ -279,6 +289,7 @@ public function touch($path, $mode = self::CREATION_MODE)
279289 {
280290 return $ this ->invoker ->invokeCall ('touch ' , [
281291 'path ' => $ path ,
292+ 'mode ' => decoct ($ this ->permissionFlagResolver ->resolve ($ mode )),
282293 ]);
283294 }
284295
0 commit comments