1<?php
2
3namespace Safe;
4
5use Safe\Exceptions\EioException;
6
7/**
8 * eio_busy artificially increases load taking
9 * delay seconds to execute. May be used for debugging,
10 * or benchmarking.
11 *
12 * @param int $delay Delay in seconds
13 * @param int $pri The request priority: EIO_PRI_DEFAULT, EIO_PRI_MIN, EIO_PRI_MAX, or NULL.
14 * If NULL passed, pri internally is set to
15 * EIO_PRI_DEFAULT.
16 * @param callable $callback This callback is called when all the group requests are done.
17 * @param mixed $data Arbitrary variable passed to callback.
18 * @return resource eio_busy returns request resource on success.
19 * @throws EioException
20 *
21 */
22function eio_busy(int $delay, int $pri = EIO_PRI_DEFAULT, callable $callback = null, $data = null)
23{
24    error_clear_last();
25    $result = \eio_busy($delay, $pri, $callback, $data);
26    if ($result === false) {
27        throw EioException::createFromPhpError();
28    }
29    return $result;
30}
31
32
33/**
34 * eio_chmod changes file, or directory permissions. The
35 * new permissions are specified by mode.
36 *
37 * @param string $path Path to the target file or directory
38 * Avoid relative
39 * paths
40 * @param int $mode The new permissions. E.g. 0644.
41 * @param int $pri The request priority: EIO_PRI_DEFAULT, EIO_PRI_MIN, EIO_PRI_MAX, or NULL.
42 * If NULL passed, pri internally is set to
43 * EIO_PRI_DEFAULT.
44 * @param callable $callback
45 * callback function is called when the request is done.
46 * It should match the following prototype:
47 *
48 *
49 * data
50 * is custom data passed to the request.
51 *
52 *
53 * result
54 * request-specific result value; basically, the value returned by corresponding
55 * system call.
56 *
57 *
58 * req
59 * is optional request resource which can be used with functions like eio_get_last_error
60 *
61 *
62 *
63 * is custom data passed to the request.
64 *
65 * request-specific result value; basically, the value returned by corresponding
66 * system call.
67 *
68 * is optional request resource which can be used with functions like eio_get_last_error
69 * @param mixed $data is custom data passed to the request.
70 * @return resource eio_chmod returns request resource on success.
71 * @throws EioException
72 *
73 */
74function eio_chmod(string $path, int $mode, int $pri = EIO_PRI_DEFAULT, callable $callback = null, $data = null)
75{
76    error_clear_last();
77    $result = \eio_chmod($path, $mode, $pri, $callback, $data);
78    if ($result === false) {
79        throw EioException::createFromPhpError();
80    }
81    return $result;
82}
83
84
85/**
86 * Changes file, or directory permissions.
87 *
88 * @param string $path Path to file or directory.
89 * Avoid relative
90 * paths
91 * @param int $uid User ID. Is ignored when equal to -1.
92 * @param int $gid Group ID. Is ignored when equal to -1.
93 * @param int $pri The request priority: EIO_PRI_DEFAULT, EIO_PRI_MIN, EIO_PRI_MAX, or NULL.
94 * If NULL passed, pri internally is set to
95 * EIO_PRI_DEFAULT.
96 * @param callable $callback
97 * callback function is called when the request is done.
98 * It should match the following prototype:
99 *
100 *
101 * data
102 * is custom data passed to the request.
103 *
104 *
105 * result
106 * request-specific result value; basically, the value returned by corresponding
107 * system call.
108 *
109 *
110 * req
111 * is optional request resource which can be used with functions like eio_get_last_error
112 *
113 *
114 *
115 * is custom data passed to the request.
116 *
117 * request-specific result value; basically, the value returned by corresponding
118 * system call.
119 *
120 * is optional request resource which can be used with functions like eio_get_last_error
121 * @param mixed $data is custom data passed to the request.
122 * @return resource eio_chown returns request resource on success.
123 * @throws EioException
124 *
125 */
126function eio_chown(string $path, int $uid, int $gid = -1, int $pri = EIO_PRI_DEFAULT, callable $callback = null, $data = null)
127{
128    error_clear_last();
129    $result = \eio_chown($path, $uid, $gid, $pri, $callback, $data);
130    if ($result === false) {
131        throw EioException::createFromPhpError();
132    }
133    return $result;
134}
135
136
137/**
138 * eio_close closes file specified by
139 * fd.
140 *
141 * @param mixed $fd Stream, Socket resource, or numeric file descriptor
142 * @param int $pri The request priority: EIO_PRI_DEFAULT, EIO_PRI_MIN, EIO_PRI_MAX, or NULL.
143 * If NULL passed, pri internally is set to
144 * EIO_PRI_DEFAULT.
145 * @param callable $callback
146 * callback function is called when the request is done.
147 * It should match the following prototype:
148 *
149 *
150 * data
151 * is custom data passed to the request.
152 *
153 *
154 * result
155 * request-specific result value; basically, the value returned by corresponding
156 * system call.
157 *
158 *
159 * req
160 * is optional request resource which can be used with functions like eio_get_last_error
161 *
162 *
163 *
164 * is custom data passed to the request.
165 *
166 * request-specific result value; basically, the value returned by corresponding
167 * system call.
168 *
169 * is optional request resource which can be used with functions like eio_get_last_error
170 * @param mixed $data is custom data passed to the request.
171 * @return resource eio_close returns request resource on success.
172 * @throws EioException
173 *
174 */
175function eio_close($fd, int $pri = EIO_PRI_DEFAULT, callable $callback = null, $data = null)
176{
177    error_clear_last();
178    $result = \eio_close($fd, $pri, $callback, $data);
179    if ($result === false) {
180        throw EioException::createFromPhpError();
181    }
182    return $result;
183}
184
185
186/**
187 * eio_custom executes custom function specified by
188 * execute processing it just like any other eio_* call.
189 *
190 * @param callable $execute Specifies the request function that should match the following prototype:
191 *
192 *
193 * callback is event completion callback that should match the following
194 * prototype:
195 *
196 *
197 * data is the data passed to
198 * execute via data argument
199 * without modifications
200 * result value returned by execute
201 * @param int $pri The request priority: EIO_PRI_DEFAULT, EIO_PRI_MIN, EIO_PRI_MAX, or NULL.
202 * If NULL passed, pri internally is set to
203 * EIO_PRI_DEFAULT.
204 * @param callable $callback
205 * callback function is called when the request is done.
206 * It should match the following prototype:
207 *
208 *
209 * data
210 * is custom data passed to the request.
211 *
212 *
213 * result
214 * request-specific result value; basically, the value returned by corresponding
215 * system call.
216 *
217 *
218 * req
219 * is optional request resource which can be used with functions like eio_get_last_error
220 *
221 *
222 *
223 * is custom data passed to the request.
224 *
225 * request-specific result value; basically, the value returned by corresponding
226 * system call.
227 *
228 * is optional request resource which can be used with functions like eio_get_last_error
229 * @param mixed $data is custom data passed to the request.
230 * @return resource eio_custom returns request resource on success.
231 * @throws EioException
232 *
233 */
234function eio_custom(callable $execute, int $pri, callable $callback, $data = null)
235{
236    error_clear_last();
237    $result = \eio_custom($execute, $pri, $callback, $data);
238    if ($result === false) {
239        throw EioException::createFromPhpError();
240    }
241    return $result;
242}
243
244
245/**
246 * eio_dup2 duplicates file descriptor.
247 *
248 * @param mixed $fd Source stream, Socket resource, or numeric file descriptor
249 * @param mixed $fd2 Target stream, Socket resource, or numeric file descriptor
250 * @param int $pri The request priority: EIO_PRI_DEFAULT, EIO_PRI_MIN, EIO_PRI_MAX, or NULL.
251 * If NULL passed, pri internally is set to
252 * EIO_PRI_DEFAULT.
253 * @param callable $callback
254 * callback function is called when the request is done.
255 * It should match the following prototype:
256 *
257 *
258 * data
259 * is custom data passed to the request.
260 *
261 *
262 * result
263 * request-specific result value; basically, the value returned by corresponding
264 * system call.
265 *
266 *
267 * req
268 * is optional request resource which can be used with functions like eio_get_last_error
269 *
270 *
271 *
272 * is custom data passed to the request.
273 *
274 * request-specific result value; basically, the value returned by corresponding
275 * system call.
276 *
277 * is optional request resource which can be used with functions like eio_get_last_error
278 * @param mixed $data is custom data passed to the request.
279 * @return resource eio_dup2 returns request resource on success.
280 * @throws EioException
281 *
282 */
283function eio_dup2($fd, $fd2, int $pri = EIO_PRI_DEFAULT, callable $callback = null, $data = null)
284{
285    error_clear_last();
286    $result = \eio_dup2($fd, $fd2, $pri, $callback, $data);
287    if ($result === false) {
288        throw EioException::createFromPhpError();
289    }
290    return $result;
291}
292
293
294/**
295 * eio_event_loop polls libeio until all requests proceeded.
296 *
297 * @throws EioException
298 *
299 */
300function eio_event_loop(): void
301{
302    error_clear_last();
303    $result = \eio_event_loop();
304    if ($result === false) {
305        throw EioException::createFromPhpError();
306    }
307}
308
309
310/**
311 * eio_fallocate allows the caller to directly manipulate the allocated disk space for the
312 * file specified by fd file descriptor for the byte
313 * range starting at offset and continuing for
314 * length bytes.
315 *
316 * @param mixed $fd Stream, Socket resource, or numeric file descriptor, e.g. returned by eio_open.
317 * @param int $mode Currently only one flag is supported for mode:
318 * EIO_FALLOC_FL_KEEP_SIZE (the same as POSIX constant
319 * FALLOC_FL_KEEP_SIZE).
320 * @param int $offset Specifies start of the byte range.
321 * @param int $length Specifies length the byte range.
322 * @param int $pri The request priority: EIO_PRI_DEFAULT, EIO_PRI_MIN, EIO_PRI_MAX, or NULL.
323 * If NULL passed, pri internally is set to
324 * EIO_PRI_DEFAULT.
325 * @param callable $callback
326 * callback function is called when the request is done.
327 * It should match the following prototype:
328 *
329 *
330 * data
331 * is custom data passed to the request.
332 *
333 *
334 * result
335 * request-specific result value; basically, the value returned by corresponding
336 * system call.
337 *
338 *
339 * req
340 * is optional request resource which can be used with functions like eio_get_last_error
341 *
342 *
343 *
344 * is custom data passed to the request.
345 *
346 * request-specific result value; basically, the value returned by corresponding
347 * system call.
348 *
349 * is optional request resource which can be used with functions like eio_get_last_error
350 * @param mixed $data is custom data passed to the request.
351 * @return resource eio_fallocate returns request resource on success.
352 * @throws EioException
353 *
354 */
355function eio_fallocate($fd, int $mode, int $offset, int $length, int $pri = EIO_PRI_DEFAULT, callable $callback = null, $data = null)
356{
357    error_clear_last();
358    $result = \eio_fallocate($fd, $mode, $offset, $length, $pri, $callback, $data);
359    if ($result === false) {
360        throw EioException::createFromPhpError();
361    }
362    return $result;
363}
364
365
366/**
367 * eio_fchmod changes permissions for the file specified
368 * by fd file descriptor.
369 *
370 * @param mixed $fd Stream, Socket resource, or numeric file descriptor, e.g. returned by eio_open.
371 * @param int $mode The new permissions. E.g. 0644.
372 * @param int $pri The request priority: EIO_PRI_DEFAULT, EIO_PRI_MIN, EIO_PRI_MAX, or NULL.
373 * If NULL passed, pri internally is set to
374 * EIO_PRI_DEFAULT.
375 * @param callable $callback
376 * callback function is called when the request is done.
377 * It should match the following prototype:
378 *
379 *
380 * data
381 * is custom data passed to the request.
382 *
383 *
384 * result
385 * request-specific result value; basically, the value returned by corresponding
386 * system call.
387 *
388 *
389 * req
390 * is optional request resource which can be used with functions like eio_get_last_error
391 *
392 *
393 *
394 * is custom data passed to the request.
395 *
396 * request-specific result value; basically, the value returned by corresponding
397 * system call.
398 *
399 * is optional request resource which can be used with functions like eio_get_last_error
400 * @param mixed $data is custom data passed to the request.
401 * @return resource eio_fchmod returns request resource on success.
402 * @throws EioException
403 *
404 */
405function eio_fchmod($fd, int $mode, int $pri = EIO_PRI_DEFAULT, callable $callback = null, $data = null)
406{
407    error_clear_last();
408    $result = \eio_fchmod($fd, $mode, $pri, $callback, $data);
409    if ($result === false) {
410        throw EioException::createFromPhpError();
411    }
412    return $result;
413}
414
415
416/**
417 * eio_fdatasync synchronizes a file's in-core state with storage device.
418 *
419 * @param mixed $fd Stream, Socket resource, or numeric file descriptor, e.g. returned by eio_open.
420 * @param int $pri The request priority: EIO_PRI_DEFAULT, EIO_PRI_MIN, EIO_PRI_MAX, or NULL.
421 * If NULL passed, pri internally is set to
422 * EIO_PRI_DEFAULT.
423 * @param callable $callback
424 * callback function is called when the request is done.
425 * It should match the following prototype:
426 *
427 *
428 * data
429 * is custom data passed to the request.
430 *
431 *
432 * result
433 * request-specific result value; basically, the value returned by corresponding
434 * system call.
435 *
436 *
437 * req
438 * is optional request resource which can be used with functions like eio_get_last_error
439 *
440 *
441 *
442 * is custom data passed to the request.
443 *
444 * request-specific result value; basically, the value returned by corresponding
445 * system call.
446 *
447 * is optional request resource which can be used with functions like eio_get_last_error
448 * @param mixed $data is custom data passed to the request.
449 * @return resource eio_fdatasync returns request resource on success.
450 * @throws EioException
451 *
452 */
453function eio_fdatasync($fd, int $pri = EIO_PRI_DEFAULT, callable $callback = null, $data = null)
454{
455    error_clear_last();
456    $result = \eio_fdatasync($fd, $pri, $callback, $data);
457    if ($result === false) {
458        throw EioException::createFromPhpError();
459    }
460    return $result;
461}
462
463
464/**
465 * eio_fstat returns file status information in
466 * result argument of callback
467 *
468 * @param mixed $fd Stream, Socket resource, or numeric file descriptor.
469 * @param int $pri The request priority: EIO_PRI_DEFAULT, EIO_PRI_MIN, EIO_PRI_MAX, or NULL.
470 * If NULL passed, pri internally is set to
471 * EIO_PRI_DEFAULT.
472 * @param callable $callback
473 * callback function is called when the request is done.
474 * It should match the following prototype:
475 *
476 *
477 * data
478 * is custom data passed to the request.
479 *
480 *
481 * result
482 * request-specific result value; basically, the value returned by corresponding
483 * system call.
484 *
485 *
486 * req
487 * is optional request resource which can be used with functions like eio_get_last_error
488 *
489 *
490 *
491 * is custom data passed to the request.
492 *
493 * request-specific result value; basically, the value returned by corresponding
494 * system call.
495 *
496 * is optional request resource which can be used with functions like eio_get_last_error
497 * @param mixed $data is custom data passed to the request.
498 * @return resource eio_busy returns request resource on success.
499 * @throws EioException
500 *
501 */
502function eio_fstat($fd, int $pri, callable $callback, $data = null)
503{
504    error_clear_last();
505    if ($data !== null) {
506        $result = \eio_fstat($fd, $pri, $callback, $data);
507    } else {
508        $result = \eio_fstat($fd, $pri, $callback);
509    }
510    if ($result === false) {
511        throw EioException::createFromPhpError();
512    }
513    return $result;
514}
515
516
517/**
518 * eio_fstatvfs returns file system statistics in
519 * result of callback.
520 *
521 * @param mixed $fd A file descriptor of a file within the mounted file system.
522 * @param int $pri The request priority: EIO_PRI_DEFAULT, EIO_PRI_MIN, EIO_PRI_MAX, or NULL.
523 * If NULL passed, pri internally is set to
524 * EIO_PRI_DEFAULT.
525 * @param callable $callback
526 * callback function is called when the request is done.
527 * It should match the following prototype:
528 *
529 *
530 * data
531 * is custom data passed to the request.
532 *
533 *
534 * result
535 * request-specific result value; basically, the value returned by corresponding
536 * system call.
537 *
538 *
539 * req
540 * is optional request resource which can be used with functions like eio_get_last_error
541 *
542 *
543 *
544 * is custom data passed to the request.
545 *
546 * request-specific result value; basically, the value returned by corresponding
547 * system call.
548 *
549 * is optional request resource which can be used with functions like eio_get_last_error
550 * @param mixed $data is custom data passed to the request.
551 * @return resource eio_fstatvfs returns request resource on success.
552 * @throws EioException
553 *
554 */
555function eio_fstatvfs($fd, int $pri, callable $callback, $data = null)
556{
557    error_clear_last();
558    if ($data !== null) {
559        $result = \eio_fstatvfs($fd, $pri, $callback, $data);
560    } else {
561        $result = \eio_fstatvfs($fd, $pri, $callback);
562    }
563    if ($result === false) {
564        throw EioException::createFromPhpError();
565    }
566    return $result;
567}
568
569
570/**
571 * Synchronize a file's in-core state with storage device
572 *
573 * @param mixed $fd Stream, Socket resource, or numeric file descriptor.
574 * @param int $pri The request priority: EIO_PRI_DEFAULT, EIO_PRI_MIN, EIO_PRI_MAX, or NULL.
575 * If NULL passed, pri internally is set to
576 * EIO_PRI_DEFAULT.
577 * @param callable $callback
578 * callback function is called when the request is done.
579 * It should match the following prototype:
580 *
581 *
582 * data
583 * is custom data passed to the request.
584 *
585 *
586 * result
587 * request-specific result value; basically, the value returned by corresponding
588 * system call.
589 *
590 *
591 * req
592 * is optional request resource which can be used with functions like eio_get_last_error
593 *
594 *
595 *
596 * is custom data passed to the request.
597 *
598 * request-specific result value; basically, the value returned by corresponding
599 * system call.
600 *
601 * is optional request resource which can be used with functions like eio_get_last_error
602 * @param mixed $data is custom data passed to the request.
603 * @return resource eio_fsync returns request resource on success.
604 * @throws EioException
605 *
606 */
607function eio_fsync($fd, int $pri = EIO_PRI_DEFAULT, callable $callback = null, $data = null)
608{
609    error_clear_last();
610    $result = \eio_fsync($fd, $pri, $callback, $data);
611    if ($result === false) {
612        throw EioException::createFromPhpError();
613    }
614    return $result;
615}
616
617
618/**
619 * eio_ftruncate causes a regular file referenced by
620 * fd file descriptor to be truncated to precisely
621 * length bytes.
622 *
623 * @param mixed $fd Stream, Socket resource, or numeric file descriptor.
624 * @param int $offset Offset from beginning of the file
625 * @param int $pri The request priority: EIO_PRI_DEFAULT, EIO_PRI_MIN, EIO_PRI_MAX, or NULL.
626 * If NULL passed, pri internally is set to
627 * EIO_PRI_DEFAULT.
628 * @param callable $callback
629 * callback function is called when the request is done.
630 * It should match the following prototype:
631 *
632 *
633 * data
634 * is custom data passed to the request.
635 *
636 *
637 * result
638 * request-specific result value; basically, the value returned by corresponding
639 * system call.
640 *
641 *
642 * req
643 * is optional request resource which can be used with functions like eio_get_last_error
644 *
645 *
646 *
647 * is custom data passed to the request.
648 *
649 * request-specific result value; basically, the value returned by corresponding
650 * system call.
651 *
652 * is optional request resource which can be used with functions like eio_get_last_error
653 * @param mixed $data is custom data passed to the request.
654 * @return resource eio_ftruncate returns request resource on success.
655 * @throws EioException
656 *
657 */
658function eio_ftruncate($fd, int $offset = 0, int $pri = EIO_PRI_DEFAULT, callable $callback = null, $data = null)
659{
660    error_clear_last();
661    $result = \eio_ftruncate($fd, $offset, $pri, $callback, $data);
662    if ($result === false) {
663        throw EioException::createFromPhpError();
664    }
665    return $result;
666}
667
668
669/**
670 * eio_futime changes file last access and modification
671 * times.
672 *
673 * @param mixed $fd Stream, Socket resource, or numeric file descriptor, e.g. returned by eio_open
674 * @param float $atime Access time
675 * @param float $mtime Modification time
676 * @param int $pri The request priority: EIO_PRI_DEFAULT, EIO_PRI_MIN, EIO_PRI_MAX, or NULL.
677 * If NULL passed, pri internally is set to
678 * EIO_PRI_DEFAULT.
679 * @param callable $callback
680 * callback function is called when the request is done.
681 * It should match the following prototype:
682 *
683 *
684 * data
685 * is custom data passed to the request.
686 *
687 *
688 * result
689 * request-specific result value; basically, the value returned by corresponding
690 * system call.
691 *
692 *
693 * req
694 * is optional request resource which can be used with functions like eio_get_last_error
695 *
696 *
697 *
698 * is custom data passed to the request.
699 *
700 * request-specific result value; basically, the value returned by corresponding
701 * system call.
702 *
703 * is optional request resource which can be used with functions like eio_get_last_error
704 * @param mixed $data is custom data passed to the request.
705 * @return resource eio_futime returns request resource on success.
706 * @throws EioException
707 *
708 */
709function eio_futime($fd, float $atime, float $mtime, int $pri = EIO_PRI_DEFAULT, callable $callback = null, $data = null)
710{
711    error_clear_last();
712    $result = \eio_futime($fd, $atime, $mtime, $pri, $callback, $data);
713    if ($result === false) {
714        throw EioException::createFromPhpError();
715    }
716    return $result;
717}
718
719
720/**
721 * eio_grp creates a request group.
722 *
723 * @param callable $callback
724 * callback function is called when the request is done.
725 * It should match the following prototype:
726 *
727 *
728 * data
729 * is custom data passed to the request.
730 *
731 *
732 * result
733 * request-specific result value; basically, the value returned by corresponding
734 * system call.
735 *
736 *
737 * req
738 * is optional request resource which can be used with functions like eio_get_last_error
739 *
740 *
741 *
742 * is custom data passed to the request.
743 *
744 * request-specific result value; basically, the value returned by corresponding
745 * system call.
746 *
747 * is optional request resource which can be used with functions like eio_get_last_error
748 * @param string $data is custom data passed to the request.
749 * @return resource eio_grp returns request group resource on success.
750 * @throws EioException
751 *
752 */
753function eio_grp(callable $callback, string $data = null)
754{
755    error_clear_last();
756    $result = \eio_grp($callback, $data);
757    if ($result === false) {
758        throw EioException::createFromPhpError();
759    }
760    return $result;
761}
762
763
764/**
765 * eio_lstat returns file status information in
766 * result argument of callback
767 *
768 * @param string $path The file path
769 * @param int $pri The request priority: EIO_PRI_DEFAULT, EIO_PRI_MIN, EIO_PRI_MAX, or NULL.
770 * If NULL passed, pri internally is set to
771 * EIO_PRI_DEFAULT.
772 * @param callable $callback
773 * callback function is called when the request is done.
774 * It should match the following prototype:
775 *
776 *
777 * data
778 * is custom data passed to the request.
779 *
780 *
781 * result
782 * request-specific result value; basically, the value returned by corresponding
783 * system call.
784 *
785 *
786 * req
787 * is optional request resource which can be used with functions like eio_get_last_error
788 *
789 *
790 *
791 * is custom data passed to the request.
792 *
793 * request-specific result value; basically, the value returned by corresponding
794 * system call.
795 *
796 * is optional request resource which can be used with functions like eio_get_last_error
797 * @param mixed $data is custom data passed to the request.
798 * @return resource eio_lstat returns request resource on success.
799 * @throws EioException
800 *
801 */
802function eio_lstat(string $path, int $pri, callable $callback, $data = null)
803{
804    error_clear_last();
805    $result = \eio_lstat($path, $pri, $callback, $data);
806    if ($result === false) {
807        throw EioException::createFromPhpError();
808    }
809    return $result;
810}
811
812
813/**
814 * eio_mkdir creates directory with specified access
815 * mode.
816 *
817 * @param string $path Path for the new directory.
818 * @param int $mode Access mode, e.g. 0755
819 * @param int $pri The request priority: EIO_PRI_DEFAULT, EIO_PRI_MIN, EIO_PRI_MAX, or NULL.
820 * If NULL passed, pri internally is set to
821 * EIO_PRI_DEFAULT.
822 * @param callable $callback
823 * callback function is called when the request is done.
824 * It should match the following prototype:
825 *
826 *
827 * data
828 * is custom data passed to the request.
829 *
830 *
831 * result
832 * request-specific result value; basically, the value returned by corresponding
833 * system call.
834 *
835 *
836 * req
837 * is optional request resource which can be used with functions like eio_get_last_error
838 *
839 *
840 *
841 * is custom data passed to the request.
842 *
843 * request-specific result value; basically, the value returned by corresponding
844 * system call.
845 *
846 * is optional request resource which can be used with functions like eio_get_last_error
847 * @param mixed $data is custom data passed to the request.
848 * @return resource eio_mkdir returns request resource on success.
849 * @throws EioException
850 *
851 */
852function eio_mkdir(string $path, int $mode, int $pri = EIO_PRI_DEFAULT, callable $callback = null, $data = null)
853{
854    error_clear_last();
855    $result = \eio_mkdir($path, $mode, $pri, $callback, $data);
856    if ($result === false) {
857        throw EioException::createFromPhpError();
858    }
859    return $result;
860}
861
862
863/**
864 * eio_mknod creates ordinary or special(often) file.
865 *
866 * @param string $path Path for the new node(file).
867 * @param int $mode Specifies both the permissions to use and the type of node to be
868 * created. It should be a combination (using bitwise OR) of one of the
869 * file types listed below and the permissions for the new node(e.g. 0640).
870 *
871 * Possible file types are: EIO_S_IFREG(regular file),
872 * EIO_S_IFCHR(character file),
873 * EIO_S_IFBLK(block special file),
874 * EIO_S_IFIFO(FIFO - named pipe) and
875 * EIO_S_IFSOCK(UNIX domain socket).
876 *
877 * To specify permissions EIO_S_I* constants could be
878 * used.
879 * @param int $dev If  the  file type is EIO_S_IFCHR or
880 * EIO_S_IFBLK then dev specifies the major and minor
881 * numbers of the newly created device special file. Otherwise
882 * dev ignored. See mknod(2) man page for
883 * details.
884 * @param int $pri The request priority: EIO_PRI_DEFAULT, EIO_PRI_MIN, EIO_PRI_MAX, or NULL.
885 * If NULL passed, pri internally is set to
886 * EIO_PRI_DEFAULT.
887 * @param callable $callback
888 * callback function is called when the request is done.
889 * It should match the following prototype:
890 *
891 *
892 * data
893 * is custom data passed to the request.
894 *
895 *
896 * result
897 * request-specific result value; basically, the value returned by corresponding
898 * system call.
899 *
900 *
901 * req
902 * is optional request resource which can be used with functions like eio_get_last_error
903 *
904 *
905 *
906 * is custom data passed to the request.
907 *
908 * request-specific result value; basically, the value returned by corresponding
909 * system call.
910 *
911 * is optional request resource which can be used with functions like eio_get_last_error
912 * @param mixed $data is custom data passed to the request.
913 * @return resource eio_mknod returns request resource on success.
914 * @throws EioException
915 *
916 */
917function eio_mknod(string $path, int $mode, int $dev, int $pri = EIO_PRI_DEFAULT, callable $callback = null, $data = null)
918{
919    error_clear_last();
920    $result = \eio_mknod($path, $mode, $dev, $pri, $callback, $data);
921    if ($result === false) {
922        throw EioException::createFromPhpError();
923    }
924    return $result;
925}
926
927
928/**
929 * eio_nop does nothing, except go through the whole
930 * request cycle. Could be useful in debugging.
931 *
932 * @param int $pri The request priority: EIO_PRI_DEFAULT, EIO_PRI_MIN, EIO_PRI_MAX, or NULL.
933 * If NULL passed, pri internally is set to
934 * EIO_PRI_DEFAULT.
935 * @param callable $callback
936 * callback function is called when the request is done.
937 * It should match the following prototype:
938 *
939 *
940 * data
941 * is custom data passed to the request.
942 *
943 *
944 * result
945 * request-specific result value; basically, the value returned by corresponding
946 * system call.
947 *
948 *
949 * req
950 * is optional request resource which can be used with functions like eio_get_last_error
951 *
952 *
953 *
954 * is custom data passed to the request.
955 *
956 * request-specific result value; basically, the value returned by corresponding
957 * system call.
958 *
959 * is optional request resource which can be used with functions like eio_get_last_error
960 * @param mixed $data is custom data passed to the request.
961 * @return resource eio_nop returns request resource on success.
962 * @throws EioException
963 *
964 */
965function eio_nop(int $pri = EIO_PRI_DEFAULT, callable $callback = null, $data = null)
966{
967    error_clear_last();
968    $result = \eio_nop($pri, $callback, $data);
969    if ($result === false) {
970        throw EioException::createFromPhpError();
971    }
972    return $result;
973}
974
975
976/**
977 * eio_readahead populates the page cache with data from a file so that subsequent reads from
978 * that file will not block on disk I/O. See READAHEAD(2) man page for details.
979 *
980 * @param mixed $fd Stream, Socket resource, or numeric file descriptor
981 * @param int $offset Starting point from which data is to be read.
982 * @param int $length Number of bytes to be read.
983 * @param int $pri The request priority: EIO_PRI_DEFAULT, EIO_PRI_MIN, EIO_PRI_MAX, or NULL.
984 * If NULL passed, pri internally is set to
985 * EIO_PRI_DEFAULT.
986 * @param callable $callback
987 * callback function is called when the request is done.
988 * It should match the following prototype:
989 *
990 *
991 * data
992 * is custom data passed to the request.
993 *
994 *
995 * result
996 * request-specific result value; basically, the value returned by corresponding
997 * system call.
998 *
999 *
1000 * req
1001 * is optional request resource which can be used with functions like eio_get_last_error
1002 *
1003 *
1004 *
1005 * is custom data passed to the request.
1006 *
1007 * request-specific result value; basically, the value returned by corresponding
1008 * system call.
1009 *
1010 * is optional request resource which can be used with functions like eio_get_last_error
1011 * @param mixed $data is custom data passed to the request.
1012 * @return resource eio_readahead returns request resource on success.
1013 * @throws EioException
1014 *
1015 */
1016function eio_readahead($fd, int $offset, int $length, int $pri = EIO_PRI_DEFAULT, callable $callback = null, $data = null)
1017{
1018    error_clear_last();
1019    $result = \eio_readahead($fd, $offset, $length, $pri, $callback, $data);
1020    if ($result === false) {
1021        throw EioException::createFromPhpError();
1022    }
1023    return $result;
1024}
1025
1026
1027/**
1028 * Reads through a whole directory(via the opendir, readdir and
1029 * closedir system calls) and returns either the names or an array in
1030 * result argument of callback
1031 * function, depending on the flags argument.
1032 *
1033 * @param string $path Directory path.
1034 * @param int $flags Combination of EIO_READDIR_* constants.
1035 * @param int $pri The request priority: EIO_PRI_DEFAULT, EIO_PRI_MIN, EIO_PRI_MAX, or NULL.
1036 * If NULL passed, pri internally is set to
1037 * EIO_PRI_DEFAULT.
1038 * @param callable $callback
1039 * callback function is called when the request is done.
1040 * It should match the following prototype:
1041 *
1042 *
1043 * data
1044 * is custom data passed to the request.
1045 *
1046 *
1047 * result
1048 * request-specific result value; basically, the value returned by corresponding
1049 * system call.
1050 *
1051 *
1052 * req
1053 * is optional request resource which can be used with functions like eio_get_last_error
1054 *
1055 *
1056 *
1057 * is custom data passed to the request.
1058 *
1059 * request-specific result value; basically, the value returned by corresponding
1060 * system call.
1061 *
1062 * is optional request resource which can be used with functions like eio_get_last_error
1063 * @param string $data is custom data passed to the request.
1064 * @return resource eio_readdir returns request resource on success. Sets result argument of
1065 * callback function according to
1066 * flags:
1067 *
1068 *
1069 *
1070 *
1071 *
1072 *
1073 * EIO_READDIR_DENTS
1074 * (integer)
1075 *
1076 *
1077 *
1078 * eio_readdir flag. If specified, the result argument of the callback
1079 * becomes an array with the following keys:
1080 * 'names' - array of directory names
1081 * 'dents' - array of struct
1082 * eio_dirent-like arrays having the following keys each:
1083 * 'name' - the directory name;
1084 * 'type' - one of EIO_DT_*
1085 * constants;
1086 * 'inode' - the inode number, if available, otherwise
1087 * unspecified;
1088 *
1089 *
1090 *
1091 *
1092 *
1093 * EIO_READDIR_DIRS_FIRST
1094 * (integer)
1095 *
1096 *
1097 *
1098 * When this flag is specified, the names will be returned in an order
1099 * where likely directories come first, in optimal stat order.
1100 *
1101 *
1102 *
1103 *
1104 *
1105 * EIO_READDIR_STAT_ORDER
1106 * (integer)
1107 *
1108 *
1109 *
1110 * When this flag is specified, then the names will be returned in an order
1111 * suitable for stat'ing each one. When planning to
1112 * stat all files in the given directory, the
1113 * returned order will likely be
1114 * fastest.
1115 *
1116 *
1117 *
1118 *
1119 *
1120 * EIO_READDIR_FOUND_UNKNOWN
1121 * (integer)
1122 *
1123 *
1124 *
1125 *
1126 *
1127 *
1128 *
1129 *
1130 *
1131 *
1132 *
1133 * Node types:
1134 *
1135 *
1136 *
1137 *
1138 *
1139 * EIO_DT_UNKNOWN
1140 * (integer)
1141 *
1142 *
1143 *
1144 * Unknown node type(very common). Further stat needed.
1145 *
1146 *
1147 *
1148 *
1149 *
1150 * EIO_DT_FIFO
1151 * (integer)
1152 *
1153 *
1154 *
1155 * FIFO node type
1156 *
1157 *
1158 *
1159 *
1160 *
1161 * EIO_DT_CHR
1162 * (integer)
1163 *
1164 *
1165 *
1166 * Node type
1167 *
1168 *
1169 *
1170 *
1171 *
1172 * EIO_DT_MPC
1173 * (integer)
1174 *
1175 *
1176 *
1177 * Multiplexed char device (v7+coherent) node type
1178 *
1179 *
1180 *
1181 *
1182 *
1183 * EIO_DT_DIR
1184 * (integer)
1185 *
1186 *
1187 *
1188 * Directory node type
1189 *
1190 *
1191 *
1192 *
1193 *
1194 * EIO_DT_NAM
1195 * (integer)
1196 *
1197 *
1198 *
1199 * Xenix special named file node type
1200 *
1201 *
1202 *
1203 *
1204 *
1205 * EIO_DT_BLK
1206 * (integer)
1207 *
1208 *
1209 *
1210 * Node type
1211 *
1212 *
1213 *
1214 *
1215 *
1216 * EIO_DT_MPB
1217 * (integer)
1218 *
1219 *
1220 *
1221 * Multiplexed block device (v7+coherent)
1222 *
1223 *
1224 *
1225 *
1226 *
1227 * EIO_DT_REG
1228 * (integer)
1229 *
1230 *
1231 *
1232 * Node type
1233 *
1234 *
1235 *
1236 *
1237 *
1238 * EIO_DT_NWK
1239 * (integer)
1240 *
1241 *
1242 *
1243 *
1244 *
1245 *
1246 *
1247 *
1248 * EIO_DT_CMP
1249 * (integer)
1250 *
1251 *
1252 *
1253 * HP-UX network special node type
1254 *
1255 *
1256 *
1257 *
1258 *
1259 * EIO_DT_LNK
1260 * (integer)
1261 *
1262 *
1263 *
1264 * Link node type
1265 *
1266 *
1267 *
1268 *
1269 *
1270 * EIO_DT_SOCK
1271 * (integer)
1272 *
1273 *
1274 *
1275 * Socket node type
1276 *
1277 *
1278 *
1279 *
1280 *
1281 * EIO_DT_DOOR
1282 * (integer)
1283 *
1284 *
1285 *
1286 * Solaris door node type
1287 *
1288 *
1289 *
1290 *
1291 *
1292 * EIO_DT_WHT
1293 * (integer)
1294 *
1295 *
1296 *
1297 * Node type
1298 *
1299 *
1300 *
1301 *
1302 *
1303 * EIO_DT_MAX
1304 * (integer)
1305 *
1306 *
1307 *
1308 * Highest node type value
1309 *
1310 *
1311 *
1312 *
1313 *
1314 *
1315 *
1316 * @throws EioException
1317 *
1318 */
1319function eio_readdir(string $path, int $flags, int $pri, callable $callback, string $data = null)
1320{
1321    error_clear_last();
1322    $result = \eio_readdir($path, $flags, $pri, $callback, $data);
1323    if ($result === false) {
1324        throw EioException::createFromPhpError();
1325    }
1326    return $result;
1327}
1328
1329
1330/**
1331 *
1332 *
1333 * @param string $path Source symbolic link path
1334 * @param int $pri The request priority: EIO_PRI_DEFAULT, EIO_PRI_MIN, EIO_PRI_MAX, or NULL.
1335 * If NULL passed, pri internally is set to
1336 * EIO_PRI_DEFAULT.
1337 * @param callable $callback
1338 * callback function is called when the request is done.
1339 * It should match the following prototype:
1340 *
1341 *
1342 * data
1343 * is custom data passed to the request.
1344 *
1345 *
1346 * result
1347 * request-specific result value; basically, the value returned by corresponding
1348 * system call.
1349 *
1350 *
1351 * req
1352 * is optional request resource which can be used with functions like eio_get_last_error
1353 *
1354 *
1355 *
1356 * is custom data passed to the request.
1357 *
1358 * request-specific result value; basically, the value returned by corresponding
1359 * system call.
1360 *
1361 * is optional request resource which can be used with functions like eio_get_last_error
1362 * @param string $data is custom data passed to the request.
1363 * @return resource eio_readlink returns request resource on success.
1364 * @throws EioException
1365 *
1366 */
1367function eio_readlink(string $path, int $pri, callable $callback, string $data = null)
1368{
1369    error_clear_last();
1370    $result = \eio_readlink($path, $pri, $callback, $data);
1371    if ($result === false) {
1372        throw EioException::createFromPhpError();
1373    }
1374    return $result;
1375}
1376
1377
1378/**
1379 * eio_rename renames or moves a file to new location.
1380 *
1381 * @param string $path Source path
1382 * @param string $new_path Target path
1383 * @param int $pri The request priority: EIO_PRI_DEFAULT, EIO_PRI_MIN, EIO_PRI_MAX, or NULL.
1384 * If NULL passed, pri internally is set to
1385 * EIO_PRI_DEFAULT.
1386 * @param callable $callback
1387 * callback function is called when the request is done.
1388 * It should match the following prototype:
1389 *
1390 *
1391 * data
1392 * is custom data passed to the request.
1393 *
1394 *
1395 * result
1396 * request-specific result value; basically, the value returned by corresponding
1397 * system call.
1398 *
1399 *
1400 * req
1401 * is optional request resource which can be used with functions like eio_get_last_error
1402 *
1403 *
1404 *
1405 * is custom data passed to the request.
1406 *
1407 * request-specific result value; basically, the value returned by corresponding
1408 * system call.
1409 *
1410 * is optional request resource which can be used with functions like eio_get_last_error
1411 * @param mixed $data is custom data passed to the request.
1412 * @return resource eio_rename returns request resource on success.
1413 * @throws EioException
1414 *
1415 */
1416function eio_rename(string $path, string $new_path, int $pri = EIO_PRI_DEFAULT, callable $callback = null, $data = null)
1417{
1418    error_clear_last();
1419    $result = \eio_rename($path, $new_path, $pri, $callback, $data);
1420    if ($result === false) {
1421        throw EioException::createFromPhpError();
1422    }
1423    return $result;
1424}
1425
1426
1427/**
1428 * eio_rmdir removes a directory.
1429 *
1430 * @param string $path Directory path
1431 * @param int $pri The request priority: EIO_PRI_DEFAULT, EIO_PRI_MIN, EIO_PRI_MAX, or NULL.
1432 * If NULL passed, pri internally is set to
1433 * EIO_PRI_DEFAULT.
1434 * @param callable $callback
1435 * callback function is called when the request is done.
1436 * It should match the following prototype:
1437 *
1438 *
1439 * data
1440 * is custom data passed to the request.
1441 *
1442 *
1443 * result
1444 * request-specific result value; basically, the value returned by corresponding
1445 * system call.
1446 *
1447 *
1448 * req
1449 * is optional request resource which can be used with functions like eio_get_last_error
1450 *
1451 *
1452 *
1453 * is custom data passed to the request.
1454 *
1455 * request-specific result value; basically, the value returned by corresponding
1456 * system call.
1457 *
1458 * is optional request resource which can be used with functions like eio_get_last_error
1459 * @param mixed $data is custom data passed to the request.
1460 * @return resource eio_rmdir returns request resource on success.
1461 * @throws EioException
1462 *
1463 */
1464function eio_rmdir(string $path, int $pri = EIO_PRI_DEFAULT, callable $callback = null, $data = null)
1465{
1466    error_clear_last();
1467    $result = \eio_rmdir($path, $pri, $callback, $data);
1468    if ($result === false) {
1469        throw EioException::createFromPhpError();
1470    }
1471    return $result;
1472}
1473
1474
1475/**
1476 * eio_seek repositions the offset of the open file associated with
1477 * stream, Socket resource, or file descriptor specified by fd to the argument offset according to the directive whence as follows:
1478 *
1479 * EIO_SEEK_SET - Set position equal to offset bytes.
1480 * EIO_SEEK_CUR - Set position to current location plus offset.
1481 * EIO_SEEK_END - Set position to end-of-file plus offset.
1482 *
1483 *
1484 * @param mixed $fd Stream, Socket resource, or numeric file descriptor
1485 * @param int $offset Starting point from which data is to be read.
1486 * @param int $whence Number of bytes to be read.
1487 * @param int $pri The request priority: EIO_PRI_DEFAULT, EIO_PRI_MIN, EIO_PRI_MAX, or NULL.
1488 * If NULL passed, pri internally is set to
1489 * EIO_PRI_DEFAULT.
1490 * @param callable $callback
1491 * callback function is called when the request is done.
1492 * It should match the following prototype:
1493 *
1494 *
1495 * data
1496 * is custom data passed to the request.
1497 *
1498 *
1499 * result
1500 * request-specific result value; basically, the value returned by corresponding
1501 * system call.
1502 *
1503 *
1504 * req
1505 * is optional request resource which can be used with functions like eio_get_last_error
1506 *
1507 *
1508 *
1509 * is custom data passed to the request.
1510 *
1511 * request-specific result value; basically, the value returned by corresponding
1512 * system call.
1513 *
1514 * is optional request resource which can be used with functions like eio_get_last_error
1515 * @param mixed $data is custom data passed to the request.
1516 * @return resource eio_seek returns request resource on success.
1517 * @throws EioException
1518 *
1519 */
1520function eio_seek($fd, int $offset, int $whence, int $pri = EIO_PRI_DEFAULT, callable $callback = null, $data = null)
1521{
1522    error_clear_last();
1523    $result = \eio_seek($fd, $offset, $whence, $pri, $callback, $data);
1524    if ($result === false) {
1525        throw EioException::createFromPhpError();
1526    }
1527    return $result;
1528}
1529
1530
1531/**
1532 * eio_sendfile copies  data between one file descriptor
1533 * and another. See SENDFILE(2) man page for details.
1534 *
1535 * @param mixed $out_fd Output stream, Socket resource, or file descriptor. Should be opened for writing.
1536 * @param mixed $in_fd Input stream, Socket resource, or file descriptor. Should be opened for reading.
1537 * @param int $offset Offset within the source file.
1538 * @param int $length Number of bytes to copy.
1539 * @param int $pri The request priority: EIO_PRI_DEFAULT, EIO_PRI_MIN, EIO_PRI_MAX, or NULL.
1540 * If NULL passed, pri internally is set to
1541 * EIO_PRI_DEFAULT.
1542 * @param callable $callback
1543 * callback function is called when the request is done.
1544 * It should match the following prototype:
1545 *
1546 *
1547 * data
1548 * is custom data passed to the request.
1549 *
1550 *
1551 * result
1552 * request-specific result value; basically, the value returned by corresponding
1553 * system call.
1554 *
1555 *
1556 * req
1557 * is optional request resource which can be used with functions like eio_get_last_error
1558 *
1559 *
1560 *
1561 * is custom data passed to the request.
1562 *
1563 * request-specific result value; basically, the value returned by corresponding
1564 * system call.
1565 *
1566 * is optional request resource which can be used with functions like eio_get_last_error
1567 * @param string $data is custom data passed to the request.
1568 * @return resource eio_sendfile returns request resource on success.
1569 * @throws EioException
1570 *
1571 */
1572function eio_sendfile($out_fd, $in_fd, int $offset, int $length, int $pri = null, callable $callback = null, string $data = null)
1573{
1574    error_clear_last();
1575    if ($data !== null) {
1576        $result = \eio_sendfile($out_fd, $in_fd, $offset, $length, $pri, $callback, $data);
1577    } elseif ($callback !== null) {
1578        $result = \eio_sendfile($out_fd, $in_fd, $offset, $length, $pri, $callback);
1579    } elseif ($pri !== null) {
1580        $result = \eio_sendfile($out_fd, $in_fd, $offset, $length, $pri);
1581    } else {
1582        $result = \eio_sendfile($out_fd, $in_fd, $offset, $length);
1583    }
1584    if ($result === false) {
1585        throw EioException::createFromPhpError();
1586    }
1587    return $result;
1588}
1589
1590
1591/**
1592 * eio_stat returns file status information in
1593 * result argument of callback
1594 *
1595 * @param string $path The file path
1596 * @param int $pri The request priority: EIO_PRI_DEFAULT, EIO_PRI_MIN, EIO_PRI_MAX, or NULL.
1597 * If NULL passed, pri internally is set to
1598 * EIO_PRI_DEFAULT.
1599 * @param callable $callback
1600 * callback function is called when the request is done.
1601 * It should match the following prototype:
1602 *
1603 *
1604 * data
1605 * is custom data passed to the request.
1606 *
1607 *
1608 * result
1609 * request-specific result value; basically, the value returned by corresponding
1610 * system call.
1611 *
1612 *
1613 * req
1614 * is optional request resource which can be used with functions like eio_get_last_error
1615 *
1616 *
1617 *
1618 * is custom data passed to the request.
1619 *
1620 * request-specific result value; basically, the value returned by corresponding
1621 * system call.
1622 *
1623 * is optional request resource which can be used with functions like eio_get_last_error
1624 * @param mixed $data is custom data passed to the request.
1625 * @return resource eio_stat returns request resource on success. On success assigns result argument of
1626 * callback to an array.
1627 * @throws EioException
1628 *
1629 */
1630function eio_stat(string $path, int $pri, callable $callback, $data = null)
1631{
1632    error_clear_last();
1633    $result = \eio_stat($path, $pri, $callback, $data);
1634    if ($result === false) {
1635        throw EioException::createFromPhpError();
1636    }
1637    return $result;
1638}
1639
1640
1641/**
1642 * eio_statvfs returns file system statistics information in
1643 * result argument of callback
1644 *
1645 * @param string $path Pathname of any file within the mounted file system
1646 * @param int $pri The request priority: EIO_PRI_DEFAULT, EIO_PRI_MIN, EIO_PRI_MAX, or NULL.
1647 * If NULL passed, pri internally is set to
1648 * EIO_PRI_DEFAULT.
1649 * @param callable $callback
1650 * callback function is called when the request is done.
1651 * It should match the following prototype:
1652 *
1653 *
1654 * data
1655 * is custom data passed to the request.
1656 *
1657 *
1658 * result
1659 * request-specific result value; basically, the value returned by corresponding
1660 * system call.
1661 *
1662 *
1663 * req
1664 * is optional request resource which can be used with functions like eio_get_last_error
1665 *
1666 *
1667 *
1668 * is custom data passed to the request.
1669 *
1670 * request-specific result value; basically, the value returned by corresponding
1671 * system call.
1672 *
1673 * is optional request resource which can be used with functions like eio_get_last_error
1674 * @param mixed $data is custom data passed to the request.
1675 * @return resource eio_statvfs returns request resource on success. On success assigns result argument of
1676 * callback to an array.
1677 * @throws EioException
1678 *
1679 */
1680function eio_statvfs(string $path, int $pri, callable $callback, $data = null)
1681{
1682    error_clear_last();
1683    if ($data !== null) {
1684        $result = \eio_statvfs($path, $pri, $callback, $data);
1685    } else {
1686        $result = \eio_statvfs($path, $pri, $callback);
1687    }
1688    if ($result === false) {
1689        throw EioException::createFromPhpError();
1690    }
1691    return $result;
1692}
1693
1694
1695/**
1696 * eio_symlink creates a symbolic link
1697 * new_path to path.
1698 *
1699 * @param string $path Source path
1700 * @param string $new_path Target path
1701 * @param int $pri The request priority: EIO_PRI_DEFAULT, EIO_PRI_MIN, EIO_PRI_MAX, or NULL.
1702 * If NULL passed, pri internally is set to
1703 * EIO_PRI_DEFAULT.
1704 * @param callable $callback
1705 * callback function is called when the request is done.
1706 * It should match the following prototype:
1707 *
1708 *
1709 * data
1710 * is custom data passed to the request.
1711 *
1712 *
1713 * result
1714 * request-specific result value; basically, the value returned by corresponding
1715 * system call.
1716 *
1717 *
1718 * req
1719 * is optional request resource which can be used with functions like eio_get_last_error
1720 *
1721 *
1722 *
1723 * is custom data passed to the request.
1724 *
1725 * request-specific result value; basically, the value returned by corresponding
1726 * system call.
1727 *
1728 * is optional request resource which can be used with functions like eio_get_last_error
1729 * @param mixed $data is custom data passed to the request.
1730 * @return resource eio_symlink returns request resource on success.
1731 * @throws EioException
1732 *
1733 */
1734function eio_symlink(string $path, string $new_path, int $pri = EIO_PRI_DEFAULT, callable $callback = null, $data = null)
1735{
1736    error_clear_last();
1737    $result = \eio_symlink($path, $new_path, $pri, $callback, $data);
1738    if ($result === false) {
1739        throw EioException::createFromPhpError();
1740    }
1741    return $result;
1742}
1743
1744
1745/**
1746 * eio_sync_file_range permits fine control when synchronizing the open file referred to by the file
1747 * descriptor fd with disk.
1748 *
1749 * @param mixed $fd File descriptor
1750 * @param int $offset The starting byte of the file range to be synchronized
1751 * @param int $nbytes Specifies the length of the range to be synchronized, in bytes. If
1752 * nbytes is zero, then all bytes from offset through
1753 * to the end of file are synchronized.
1754 * @param int $flags A bit-mask. Can include any of the following values:
1755 * EIO_SYNC_FILE_RANGE_WAIT_BEFORE,
1756 * EIO_SYNC_FILE_RANGE_WRITE,
1757 * EIO_SYNC_FILE_RANGE_WAIT_AFTER. These flags have
1758 * the same meaning as their SYNC_FILE_RANGE_*
1759 * counterparts(see SYNC_FILE_RANGE(2) man page).
1760 * @param int $pri The request priority: EIO_PRI_DEFAULT, EIO_PRI_MIN, EIO_PRI_MAX, or NULL.
1761 * If NULL passed, pri internally is set to
1762 * EIO_PRI_DEFAULT.
1763 * @param callable $callback
1764 * callback function is called when the request is done.
1765 * It should match the following prototype:
1766 *
1767 *
1768 * data
1769 * is custom data passed to the request.
1770 *
1771 *
1772 * result
1773 * request-specific result value; basically, the value returned by corresponding
1774 * system call.
1775 *
1776 *
1777 * req
1778 * is optional request resource which can be used with functions like eio_get_last_error
1779 *
1780 *
1781 *
1782 * is custom data passed to the request.
1783 *
1784 * request-specific result value; basically, the value returned by corresponding
1785 * system call.
1786 *
1787 * is optional request resource which can be used with functions like eio_get_last_error
1788 * @param mixed $data is custom data passed to the request.
1789 * @return resource eio_sync_file_range returns request resource on success.
1790 * @throws EioException
1791 *
1792 */
1793function eio_sync_file_range($fd, int $offset, int $nbytes, int $flags, int $pri = EIO_PRI_DEFAULT, callable $callback = null, $data = null)
1794{
1795    error_clear_last();
1796    $result = \eio_sync_file_range($fd, $offset, $nbytes, $flags, $pri, $callback, $data);
1797    if ($result === false) {
1798        throw EioException::createFromPhpError();
1799    }
1800    return $result;
1801}
1802
1803
1804/**
1805 *
1806 *
1807 * @param int $pri
1808 * @param callable $callback
1809 * @param mixed $data
1810 * @return resource eio_sync returns request resource on success.
1811 * @throws EioException
1812 *
1813 */
1814function eio_sync(int $pri = EIO_PRI_DEFAULT, callable $callback = null, $data = null)
1815{
1816    error_clear_last();
1817    $result = \eio_sync($pri, $callback, $data);
1818    if ($result === false) {
1819        throw EioException::createFromPhpError();
1820    }
1821    return $result;
1822}
1823
1824
1825/**
1826 *
1827 *
1828 * @param mixed $fd File descriptor
1829 * @param int $pri The request priority: EIO_PRI_DEFAULT, EIO_PRI_MIN, EIO_PRI_MAX, or NULL.
1830 * If NULL passed, pri internally is set to
1831 * EIO_PRI_DEFAULT.
1832 * @param callable $callback
1833 * callback function is called when the request is done.
1834 * It should match the following prototype:
1835 *
1836 *
1837 * data
1838 * is custom data passed to the request.
1839 *
1840 *
1841 * result
1842 * request-specific result value; basically, the value returned by corresponding
1843 * system call.
1844 *
1845 *
1846 * req
1847 * is optional request resource which can be used with functions like eio_get_last_error
1848 *
1849 *
1850 *
1851 * is custom data passed to the request.
1852 *
1853 * request-specific result value; basically, the value returned by corresponding
1854 * system call.
1855 *
1856 * is optional request resource which can be used with functions like eio_get_last_error
1857 * @param mixed $data is custom data passed to the request.
1858 * @return resource eio_syncfs returns request resource on success.
1859 * @throws EioException
1860 *
1861 */
1862function eio_syncfs($fd, int $pri = EIO_PRI_DEFAULT, callable $callback = null, $data = null)
1863{
1864    error_clear_last();
1865    $result = \eio_syncfs($fd, $pri, $callback, $data);
1866    if ($result === false) {
1867        throw EioException::createFromPhpError();
1868    }
1869    return $result;
1870}
1871
1872
1873/**
1874 * eio_truncate causes the regular file named by path to be truncated to
1875 * a size of precisely length bytes
1876 *
1877 * @param string $path File path
1878 * @param int $offset Offset from beginning of the file.
1879 * @param int $pri The request priority: EIO_PRI_DEFAULT, EIO_PRI_MIN, EIO_PRI_MAX, or NULL.
1880 * If NULL passed, pri internally is set to
1881 * EIO_PRI_DEFAULT.
1882 * @param callable $callback
1883 * callback function is called when the request is done.
1884 * It should match the following prototype:
1885 *
1886 *
1887 * data
1888 * is custom data passed to the request.
1889 *
1890 *
1891 * result
1892 * request-specific result value; basically, the value returned by corresponding
1893 * system call.
1894 *
1895 *
1896 * req
1897 * is optional request resource which can be used with functions like eio_get_last_error
1898 *
1899 *
1900 *
1901 * is custom data passed to the request.
1902 *
1903 * request-specific result value; basically, the value returned by corresponding
1904 * system call.
1905 *
1906 * is optional request resource which can be used with functions like eio_get_last_error
1907 * @param mixed $data is custom data passed to the request.
1908 * @return resource eio_busy returns request resource on success.
1909 * @throws EioException
1910 *
1911 */
1912function eio_truncate(string $path, int $offset = 0, int $pri = EIO_PRI_DEFAULT, callable $callback = null, $data = null)
1913{
1914    error_clear_last();
1915    $result = \eio_truncate($path, $offset, $pri, $callback, $data);
1916    if ($result === false) {
1917        throw EioException::createFromPhpError();
1918    }
1919    return $result;
1920}
1921
1922
1923/**
1924 * eio_unlink deletes  a  name from the file system.
1925 *
1926 * @param string $path Path to file
1927 * @param int $pri The request priority: EIO_PRI_DEFAULT, EIO_PRI_MIN, EIO_PRI_MAX, or NULL.
1928 * If NULL passed, pri internally is set to
1929 * EIO_PRI_DEFAULT.
1930 * @param callable $callback
1931 * callback function is called when the request is done.
1932 * It should match the following prototype:
1933 *
1934 *
1935 * data
1936 * is custom data passed to the request.
1937 *
1938 *
1939 * result
1940 * request-specific result value; basically, the value returned by corresponding
1941 * system call.
1942 *
1943 *
1944 * req
1945 * is optional request resource which can be used with functions like eio_get_last_error
1946 *
1947 *
1948 *
1949 * is custom data passed to the request.
1950 *
1951 * request-specific result value; basically, the value returned by corresponding
1952 * system call.
1953 *
1954 * is optional request resource which can be used with functions like eio_get_last_error
1955 * @param mixed $data is custom data passed to the request.
1956 * @return resource eio_unlink returns request resource on success.
1957 * @throws EioException
1958 *
1959 */
1960function eio_unlink(string $path, int $pri = EIO_PRI_DEFAULT, callable $callback = null, $data = null)
1961{
1962    error_clear_last();
1963    $result = \eio_unlink($path, $pri, $callback, $data);
1964    if ($result === false) {
1965        throw EioException::createFromPhpError();
1966    }
1967    return $result;
1968}
1969
1970
1971/**
1972 *
1973 *
1974 * @param string $path Path to the file.
1975 * @param float $atime Access time
1976 * @param float $mtime Modification time
1977 * @param int $pri The request priority: EIO_PRI_DEFAULT, EIO_PRI_MIN, EIO_PRI_MAX, or NULL.
1978 * If NULL passed, pri internally is set to
1979 * EIO_PRI_DEFAULT.
1980 * @param callable $callback
1981 * callback function is called when the request is done.
1982 * It should match the following prototype:
1983 *
1984 *
1985 * data
1986 * is custom data passed to the request.
1987 *
1988 *
1989 * result
1990 * request-specific result value; basically, the value returned by corresponding
1991 * system call.
1992 *
1993 *
1994 * req
1995 * is optional request resource which can be used with functions like eio_get_last_error
1996 *
1997 *
1998 *
1999 * is custom data passed to the request.
2000 *
2001 * request-specific result value; basically, the value returned by corresponding
2002 * system call.
2003 *
2004 * is optional request resource which can be used with functions like eio_get_last_error
2005 * @param mixed $data is custom data passed to the request.
2006 * @return resource eio_utime returns request resource on success.
2007 * @throws EioException
2008 *
2009 */
2010function eio_utime(string $path, float $atime, float $mtime, int $pri = EIO_PRI_DEFAULT, callable $callback = null, $data = null)
2011{
2012    error_clear_last();
2013    $result = \eio_utime($path, $atime, $mtime, $pri, $callback, $data);
2014    if ($result === false) {
2015        throw EioException::createFromPhpError();
2016    }
2017    return $result;
2018}
2019
2020
2021/**
2022 * eio_write writes up to length
2023 * bytes from str at offset
2024 * offset from the beginning of the file.
2025 *
2026 * @param mixed $fd Stream, Socket resource, or numeric file descriptor, e.g. returned by eio_open
2027 * @param string $str Source string
2028 * @param int $length Maximum number of bytes to write.
2029 * @param int $offset Offset from the beginning of file.
2030 * @param int $pri The request priority: EIO_PRI_DEFAULT, EIO_PRI_MIN, EIO_PRI_MAX, or NULL.
2031 * If NULL passed, pri internally is set to
2032 * EIO_PRI_DEFAULT.
2033 * @param callable $callback
2034 * callback function is called when the request is done.
2035 * It should match the following prototype:
2036 *
2037 *
2038 * data
2039 * is custom data passed to the request.
2040 *
2041 *
2042 * result
2043 * request-specific result value; basically, the value returned by corresponding
2044 * system call.
2045 *
2046 *
2047 * req
2048 * is optional request resource which can be used with functions like eio_get_last_error
2049 *
2050 *
2051 *
2052 * is custom data passed to the request.
2053 *
2054 * request-specific result value; basically, the value returned by corresponding
2055 * system call.
2056 *
2057 * is optional request resource which can be used with functions like eio_get_last_error
2058 * @param mixed $data is custom data passed to the request.
2059 * @return resource eio_write returns request resource on success.
2060 * @throws EioException
2061 *
2062 */
2063function eio_write($fd, string $str, int $length = 0, int $offset = 0, int $pri = EIO_PRI_DEFAULT, callable $callback = null, $data = null)
2064{
2065    error_clear_last();
2066    $result = \eio_write($fd, $str, $length, $offset, $pri, $callback, $data);
2067    if ($result === false) {
2068        throw EioException::createFromPhpError();
2069    }
2070    return $result;
2071}
2072