Skip to content

Commit 6f1a0f6

Browse files
committed
- Make SplTempFileObject work in 5.1
1 parent 299fe25 commit 6f1a0f6

File tree

1 file changed

+21
-1
lines changed

1 file changed

+21
-1
lines changed

ext/standard/php_fopen_wrapper.c

+21-1
Original file line numberDiff line numberDiff line change
@@ -158,9 +158,29 @@ php_stream * php_stream_url_wrap_php(php_stream_wrapper *wrapper, char *path, ch
158158
int mode_rw = 0;
159159
php_stream * stream = NULL;
160160
char *p, *token, *pathdup;
161+
long max_memory;
161162

162-
if (!strncasecmp(path, "php://", 6))
163+
if (!strncasecmp(path, "php://", 6)) {
163164
path += 6;
165+
}
166+
167+
if (!strncasecmp(path, "temp", 4)) {
168+
path += 4;
169+
max_memory = PHP_STREAM_MAX_MEM;
170+
if (!strncasecmp(path, "/maxmemory:", 11)) {
171+
path += 11;
172+
max_memory = strtol(path, NULL, 10);
173+
if (max_memory < 0) {
174+
php_error_docref(NULL TSRMLS_CC, E_ERROR, "Max memory must be >= 0");
175+
return NULL;
176+
}
177+
}
178+
return php_stream_temp_create(TEMP_STREAM_DEFAULT, max_memory);
179+
}
180+
181+
if (!strcasecmp(path, "memory")) {
182+
return php_stream_memory_create(TEMP_STREAM_DEFAULT);
183+
}
164184

165185
if (!strcasecmp(path, "output")) {
166186
return php_stream_alloc(&php_stream_output_ops, NULL, 0, "wb");

0 commit comments

Comments
 (0)