@@ -9,12 +9,11 @@ discard block |
||
9 | 9 | try |
10 | 10 | { |
11 | 11 | $object = new NetObject (...$args); |
12 | - } |
|
13 | - |
|
14 | - catch (\WinformsException $e) |
|
12 | + } catch (\WinformsException $e) |
|
15 | 13 | { |
16 | - if (VoidCore::callMethod ($e->getNetException (), 'ToString') == 'System.MemberAccessException') |
|
17 | - throw $e; |
|
14 | + if (VoidCore::callMethod ($e->getNetException (), 'ToString') == 'System.MemberAccessException') { |
|
15 | + throw $e; |
|
16 | + } |
|
18 | 17 | |
19 | 18 | $object = new NetClass (...$args); |
20 | 19 | } |
@@ -32,9 +31,7 @@ discard block |
||
32 | 31 | try |
33 | 32 | { |
34 | 33 | return VoidCore::callMethod (VoidCore::getClass ('System.Enum'), ['parse', VC_OBJECT], VoidCore::typeof ($baseType), $value, true); |
35 | - } |
|
36 | - |
|
37 | - catch (\WinformsException $e) |
|
34 | + } catch (\WinformsException $e) |
|
38 | 35 | { |
39 | 36 | return (new NetClass ($baseType))->$value; |
40 | 37 | } |
@@ -45,34 +42,39 @@ discard block |
||
45 | 42 | $array = (new NetClass ('System.Array')) |
46 | 43 | ->createInstance (VoidCore::typeof ($type), $size = sizeof ($items)); |
47 | 44 | |
48 | - for ($i = 0; $i < $size; ++$i) |
|
49 | - $array[$i] = array_shift ($items); |
|
45 | + for ($i = 0; $i < $size; ++$i) { |
|
46 | + $array[$i] = array_shift ($items); |
|
47 | + } |
|
50 | 48 | |
51 | 49 | return $array; |
52 | 50 | } |
53 | 51 | |
54 | 52 | function dir_create (string $path, int $mode = 0777): void |
55 | 53 | { |
56 | - if (!is_dir ($path)) |
|
57 | - mkdir ($path, $mode, true); |
|
58 | -} |
|
54 | + if (!is_dir ($path)) { |
|
55 | + mkdir ($path, $mode, true); |
|
56 | + } |
|
57 | + } |
|
59 | 58 | |
60 | 59 | function dir_delete (string $path): bool |
61 | 60 | { |
62 | - if (!is_dir ($path)) |
|
63 | - return false; |
|
61 | + if (!is_dir ($path)) { |
|
62 | + return false; |
|
63 | + } |
|
64 | 64 | |
65 | - foreach (array_slice (scandir ($path), 2) as $file) |
|
66 | - if (is_dir ($file = $path .'/'. $file)) |
|
65 | + foreach (array_slice (scandir ($path), 2) as $file) { |
|
66 | + if (is_dir ($file = $path .'/'. $file)) |
|
67 | 67 | { |
68 | 68 | dir_delete ($file); |
69 | + } |
|
69 | 70 | |
70 | - if (is_dir ($file)) |
|
71 | - rmdir ($file); |
|
71 | + if (is_dir ($file)) { |
|
72 | + rmdir ($file); |
|
73 | + } |
|
74 | + } else { |
|
75 | + unlink ($file); |
|
72 | 76 | } |
73 | 77 | |
74 | - else unlink ($file); |
|
75 | - |
|
76 | 78 | rmdir ($path); |
77 | 79 | |
78 | 80 | return true; |
@@ -86,17 +88,22 @@ discard block |
||
86 | 88 | |
87 | 89 | function dir_copy (string $from, string $to): bool |
88 | 90 | { |
89 | - if (!is_dir ($from)) |
|
90 | - return false; |
|
91 | + if (!is_dir ($from)) { |
|
92 | + return false; |
|
93 | + } |
|
91 | 94 | |
92 | - if (!is_dir ($to)) |
|
93 | - dir_create ($to); |
|
95 | + if (!is_dir ($to)) { |
|
96 | + dir_create ($to); |
|
97 | + } |
|
94 | 98 | |
95 | - foreach (array_slice (scandir ($from), 2) as $file) |
|
96 | - if (is_dir ($f = $from .'/'. $file)) |
|
99 | + foreach (array_slice (scandir ($from), 2) as $file) { |
|
100 | + if (is_dir ($f = $from .'/'. $file)) |
|
97 | 101 | dir_copy ($f, $to .'/'. $file); |
102 | + } |
|
98 | 103 | |
99 | - else copy ($f, $to .'/'. $file); |
|
104 | + else { |
|
105 | + copy ($f, $to .'/'. $file); |
|
106 | + } |
|
100 | 107 | |
101 | 108 | return true; |
102 | 109 | } |