]> granicus.if.org Git - php/commitdiff
Skip large ftruncate test if large files not supported
authorNikita Popov <nikita.ppv@gmail.com>
Thu, 24 Oct 2019 12:32:11 +0000 (14:32 +0200)
committerNikita Popov <nikita.ppv@gmail.com>
Thu, 24 Oct 2019 12:46:49 +0000 (14:46 +0200)
ext/standard/tests/file/ftruncate_bug76422.phpt

index 4f434d324ab5548190cfa2987cb8399bb118a497..77334545a97cfccbc5aca15866a2ab15199ae5ad 100644 (file)
@@ -17,6 +17,15 @@ if (false === $file_handle) {
     die('Cannot open test file :/');
 }
 
+/* Check if ftruncate() with 2GB works. If it doesn't, it's likely that large files are
+ * generally not supported (EFBIG). */
+$truncate_offset = 2 * 1024 * 1024 * 1024;
+$ftruncate_result = ftruncate($file_handle, $truncate_offset);
+if (false === $ftruncate_result) {
+    var_dump(true);
+    return;
+}
+
 $truncate_offset = 4 * 1024 * 1024 * 1024 + 1;
 $ftruncate_result = ftruncate($file_handle, $truncate_offset);