|
9 | 9 | * Path to the public directory |
10 | 10 | * |
11 | 11 | * @param string $path |
| 12 | + * @param string $resource |
12 | 13 | * @return string |
13 | 14 | */ |
14 | | - function public_path($path = '') |
| 15 | + function public_path($path = '', $resource = '') |
15 | 16 | { |
| 17 | + if ( ! empty($path) && !empty($resource)) { |
| 18 | + return FCPATH . $path . DIRECTORY_SEPARATOR . $resource; |
| 19 | + } |
| 20 | + |
16 | 21 | if ( ! empty($path) && is_dir(FCPATH . $path)) { |
17 | 22 | return FCPATH . $path . DIRECTORY_SEPARATOR; |
18 | 23 | } |
19 | 24 |
|
| 25 | + if ( ! empty($path) && is_file(FCPATH . $path)) { |
| 26 | + return FCPATH . $path; |
| 27 | + } |
| 28 | + |
20 | 29 | if (empty($path)) { |
21 | 30 | return FCPATH; |
22 | 31 | } |
@@ -64,14 +73,24 @@ function app_path($path = '') |
64 | 73 | * Path to the writable directory |
65 | 74 | * |
66 | 75 | * @param string $path |
| 76 | + * @param string $resource |
67 | 77 | * @return string |
68 | 78 | */ |
69 | | - function writable_path($path = '') |
| 79 | + function writable_path($path = '', $resource = '') |
70 | 80 | { |
| 81 | + |
| 82 | + if ( ! empty($path) && !empty($resource)) { |
| 83 | + return WRITABLEPATH . $path . DIRECTORY_SEPARATOR . $resource; |
| 84 | + } |
| 85 | + |
71 | 86 | if ( ! empty($path) && is_dir(WRITABLEPATH . $path)) { |
72 | 87 | return WRITABLEPATH . $path . DIRECTORY_SEPARATOR; |
73 | 88 | } |
74 | 89 |
|
| 90 | + if ( ! empty($path) && is_file(WRITABLEPATH . $path)) { |
| 91 | + return WRITABLEPATH . $path; |
| 92 | + } |
| 93 | + |
75 | 94 | return; |
76 | 95 | } |
77 | 96 | } |
@@ -107,7 +126,7 @@ function resource($path = null, $item = null) |
107 | 126 | } |
108 | 127 |
|
109 | 128 | if ( ! is_null($item)) { |
110 | | - $path .= '/'.$item; |
| 129 | + $path .= DIRECTORY_SEPARATOR .$item; |
111 | 130 | } |
112 | 131 |
|
113 | 132 | return (!empty($path)) ? load_path($path) : site_url() . ASSETS; |
|
0 commit comments