]> granicus.if.org Git - php/commitdiff
MFB: Added a warning message
authorIlia Alshanetsky <iliaa@php.net>
Sun, 30 Mar 2008 15:06:07 +0000 (15:06 +0000)
committerIlia Alshanetsky <iliaa@php.net>
Sun, 30 Mar 2008 15:06:07 +0000 (15:06 +0000)
ext/standard/file.c

index 26d14ddc74a8afd1d7fe2faa3f52e9fa044f459a..054697cc07c8936ad636416c3bccad424fbc4cd9 100644 (file)
@@ -624,6 +624,7 @@ PHP_FUNCTION(file_put_contents)
        php_stream_context *context = NULL;
        char mode[3] = { 'w', 0, 0 };
        php_stream *srcstream = NULL;
+       char mode[3] = "wb";
 
        if (zend_parse_parameters(argc TSRMLS_CC, "Zz/|lr!", &ppfilename, &data, &flags, &zcontext) == FAILURE) {
                return;
@@ -655,9 +656,14 @@ PHP_FUNCTION(file_put_contents)
 
        if (flags & LOCK_EX && (!php_stream_supports_lock(stream) || php_stream_lock(stream, LOCK_EX))) {
                php_stream_close(stream);
+               php_error_docref(NULL TSRMLS_CC, E_WARNING, "Exclusive locks are not supported for this stream");
                RETURN_FALSE;
        }
 
+       if (mode[0] = 'c') {
+               php_stream_truncate_set_size(stream, 0);
+       }
+
        switch (Z_TYPE_P(data)) {
                case IS_RESOURCE:
                        numchars = php_stream_copy_to_stream(srcstream, stream, PHP_STREAM_COPY_ALL);