Migrate TestExtFile to php
I dropped a couple tests that did nothing (e.g. clearstatcache) or almost nothing, or that 'tested' things that almost all the tests do (e.g. unlink or fclose). Dropped a few unixy apis that really didn't test that they do anything. Combined a few tests also.
Esse commit está contido em:
@@ -35,7 +35,6 @@
|
||||
#include "hphp/facebook/extensions/tao/test_ext_tao.h"
|
||||
#include "hphp/facebook/extensions/urlextraction/test_ext_urlextraction.h"
|
||||
#include "hphp/test/ext/test_ext_curl.h"
|
||||
#include "hphp/test/ext/test_ext_file.h"
|
||||
#include "hphp/test/ext/test_ext_icu_ucnv.h"
|
||||
#include "hphp/test/ext/test_ext_icu_ucsdet.h"
|
||||
#include "hphp/test/ext/test_ext_icu_uspoof.h"
|
||||
|
||||
Diferenças do arquivo suprimidas por serem muito extensas
Carregar Diff
@@ -1,132 +0,0 @@
|
||||
/*
|
||||
+----------------------------------------------------------------------+
|
||||
| HipHop for PHP |
|
||||
+----------------------------------------------------------------------+
|
||||
| Copyright (c) 2010-2013 Facebook, Inc. (http://www.facebook.com) |
|
||||
+----------------------------------------------------------------------+
|
||||
| This source file is subject to version 3.01 of the PHP license, |
|
||||
| that is bundled with this package in the file LICENSE, and is |
|
||||
| available through the world-wide-web at the following url: |
|
||||
| http://www.php.net/license/3_01.txt |
|
||||
| If you did not receive a copy of the PHP license and are unable to |
|
||||
| obtain it through the world-wide-web, please send a note to |
|
||||
| license@php.net so we can mail you a copy immediately. |
|
||||
+----------------------------------------------------------------------+
|
||||
*/
|
||||
|
||||
#ifndef incl_HPHP_TEST_EXT_FILE_H_
|
||||
#define incl_HPHP_TEST_EXT_FILE_H_
|
||||
|
||||
// >>>>>> Generated by idl.php. Do NOT modify. <<<<<<
|
||||
|
||||
#include "hphp/test/ext/test_cpp_ext.h"
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
class TestExtFile : public TestCppExt {
|
||||
public:
|
||||
virtual bool RunTests(const std::string &which);
|
||||
|
||||
bool test_fopen();
|
||||
bool test_popen();
|
||||
bool test_fclose();
|
||||
bool test_pclose();
|
||||
bool test_fseek();
|
||||
bool test_rewind();
|
||||
bool test_ftell();
|
||||
bool test_feof();
|
||||
bool test_fstat();
|
||||
bool test_fread();
|
||||
bool test_fgetc();
|
||||
bool test_fgets();
|
||||
bool test_fgetss();
|
||||
bool test_fscanf();
|
||||
bool test_fpassthru();
|
||||
bool test_fwrite();
|
||||
bool test_read_write();
|
||||
bool test_fputs();
|
||||
bool test_fprintf();
|
||||
bool test_vfprintf();
|
||||
bool test_fflush();
|
||||
bool test_ftruncate();
|
||||
bool test_flock();
|
||||
bool test_fputcsv();
|
||||
bool test_fgetcsv();
|
||||
bool test_file_get_contents();
|
||||
bool test_file_put_contents();
|
||||
bool test_file();
|
||||
bool test_readfile();
|
||||
bool test_move_uploaded_file();
|
||||
bool test_parse_ini_file();
|
||||
bool test_parse_ini_string();
|
||||
bool test_parse_hdf_file();
|
||||
bool test_parse_hdf_string();
|
||||
bool test_write_hdf_file();
|
||||
bool test_write_hdf_string();
|
||||
bool test_md5_file();
|
||||
bool test_sha1_file();
|
||||
bool test_chmod();
|
||||
bool test_chown();
|
||||
bool test_lchown();
|
||||
bool test_chgrp();
|
||||
bool test_lchgrp();
|
||||
bool test_touch();
|
||||
bool test_copy();
|
||||
bool test_rename();
|
||||
bool test_umask();
|
||||
bool test_unlink();
|
||||
bool test_link();
|
||||
bool test_symlink();
|
||||
bool test_basename();
|
||||
bool test_fnmatch();
|
||||
bool test_glob();
|
||||
bool test_tempnam();
|
||||
bool test_tmpfile();
|
||||
bool test_fileperms();
|
||||
bool test_fileinode();
|
||||
bool test_filesize();
|
||||
bool test_fileowner();
|
||||
bool test_filegroup();
|
||||
bool test_fileatime();
|
||||
bool test_filemtime();
|
||||
bool test_filectime();
|
||||
bool test_filetype();
|
||||
bool test_linkinfo();
|
||||
bool test_is_writable();
|
||||
bool test_is_writeable();
|
||||
bool test_is_readable();
|
||||
bool test_is_executable();
|
||||
bool test_is_file();
|
||||
bool test_is_dir();
|
||||
bool test_is_link();
|
||||
bool test_is_uploaded_file();
|
||||
bool test_file_exists();
|
||||
bool test_stat();
|
||||
bool test_lstat();
|
||||
bool test_clearstatcache();
|
||||
bool test_readlink();
|
||||
bool test_realpath();
|
||||
bool test_pathinfo();
|
||||
bool test_disk_free_space();
|
||||
bool test_diskfreespace();
|
||||
bool test_disk_total_space();
|
||||
bool test_mkdir();
|
||||
bool test_rmdir();
|
||||
bool test_dirname();
|
||||
bool test_getcwd();
|
||||
bool test_chdir();
|
||||
bool test_chroot();
|
||||
bool test_dir();
|
||||
bool test_opendir();
|
||||
bool test_readdir();
|
||||
bool test_rewinddir();
|
||||
bool test_scandir();
|
||||
bool test_closedir();
|
||||
|
||||
private:
|
||||
bool VerifyFile(CVarRef f, CStrRef contents);
|
||||
};
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#endif // incl_HPHP_TEST_EXT_FILE_H_
|
||||
@@ -0,0 +1,15 @@
|
||||
<?php
|
||||
|
||||
$tempfile = tempnam('/tmp', 'vmextfiletest');
|
||||
|
||||
$f = fopen($tempfile, 'w');
|
||||
fputs($f, "testing feof");
|
||||
fclose($f);
|
||||
|
||||
$f = fopen($tempfile, "r");
|
||||
var_dump(feof($f));
|
||||
echo fread($f, 20);
|
||||
echo "\n";
|
||||
var_dump(feof($f));
|
||||
|
||||
unlink($tempfile);
|
||||
@@ -0,0 +1,3 @@
|
||||
bool(false)
|
||||
testing feof
|
||||
bool(true)
|
||||
@@ -0,0 +1,15 @@
|
||||
<?php
|
||||
|
||||
$tempfile = tempnam('/tmp', 'vmextfiletest');
|
||||
|
||||
$f = fopen($tempfile, 'w');
|
||||
fputs($f, "testing fgetc");
|
||||
fclose($f);
|
||||
|
||||
$f = fopen($tempfile, "r");
|
||||
var_dump(fgetc($f));
|
||||
var_dump(fgetc($f));
|
||||
var_dump(fgetc($f));
|
||||
var_dump(fgetc($f));
|
||||
|
||||
unlink($tempfile);
|
||||
@@ -0,0 +1,4 @@
|
||||
string(1) "t"
|
||||
string(1) "e"
|
||||
string(1) "s"
|
||||
string(1) "t"
|
||||
@@ -0,0 +1,14 @@
|
||||
<?php
|
||||
|
||||
$tempfile = tempnam('/tmp', 'vmextfiletest');
|
||||
|
||||
$f = fopen($tempfile, 'w');
|
||||
fputs($f, "testing\nfgets\n\n");
|
||||
fclose($f);
|
||||
|
||||
$f = fopen($tempfile, 'r');
|
||||
var_dump(fgets($f));
|
||||
var_dump(fgets($f));
|
||||
var_dump(fgets($f));
|
||||
|
||||
unlink($tempfile);
|
||||
@@ -0,0 +1,6 @@
|
||||
string(8) "testing
|
||||
"
|
||||
string(6) "fgets
|
||||
"
|
||||
string(1) "
|
||||
"
|
||||
@@ -0,0 +1,12 @@
|
||||
<?php
|
||||
|
||||
$tempfile = tempnam('/tmp', 'vmextfiletest');
|
||||
|
||||
$f = fopen($tempfile, 'w');
|
||||
fputs($f, "<html><head>testing</head><body> fgetss</body></html>\n");
|
||||
fclose($f);
|
||||
|
||||
$f = fopen($tempfile, "r");
|
||||
var_dump(fgetss($f));
|
||||
|
||||
unlink($tempfile);
|
||||
@@ -0,0 +1,2 @@
|
||||
string(15) "testing fgetss
|
||||
"
|
||||
@@ -0,0 +1,12 @@
|
||||
<?php
|
||||
|
||||
$tempfile = tempnam('/tmp', 'vmextfiletest');
|
||||
|
||||
$f = fopen($tempfile, 'w');
|
||||
fputs($f, "testing\nfile\n");
|
||||
fclose($f);
|
||||
|
||||
$items = file($tempfile);
|
||||
var_dump($items);
|
||||
|
||||
unlink($tempfile);
|
||||
@@ -0,0 +1,8 @@
|
||||
array(2) {
|
||||
[0]=>
|
||||
string(8) "testing
|
||||
"
|
||||
[1]=>
|
||||
string(5) "file
|
||||
"
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
<?php
|
||||
|
||||
var_dump(md5_file(__DIR__.'/test_ext_file.txt'));
|
||||
var_dump(sha1_file(__DIR__.'/test_ext_file.txt'));
|
||||
@@ -0,0 +1,2 @@
|
||||
string(32) "f53a9b64dc3846f27ee10848d0493320"
|
||||
string(40) "3f0f6cb904835174e35697d8262170aa060be3a5"
|
||||
@@ -0,0 +1,8 @@
|
||||
<?php
|
||||
|
||||
$tempfile = tempnam('/tmp', 'vmextfiletest');
|
||||
|
||||
file_put_contents($tempfile, 'testing file_put_contents');
|
||||
var_dump(file_get_contents($tempfile));
|
||||
|
||||
unlink($tempfile);
|
||||
@@ -0,0 +1 @@
|
||||
string(25) "testing file_put_contents"
|
||||
@@ -0,0 +1,4 @@
|
||||
<?php
|
||||
|
||||
$f = fopen(__DIR__.'/test_ext_file.txt', 'r');
|
||||
fpassthru($f);
|
||||
Arquivo executável → Arquivo normal
@@ -0,0 +1,13 @@
|
||||
<?php
|
||||
|
||||
$tempfile = tempnam('/tmp', 'vmextfiletest');
|
||||
|
||||
$f = fopen($tempfile, 'w');
|
||||
fprintf($f, "%s %s", "testing", "fprintf");
|
||||
fclose($f);
|
||||
|
||||
$f = fopen($tempfile, "r");
|
||||
fpassthru($f);
|
||||
echo "\n";
|
||||
|
||||
unlink($tempfile);
|
||||
@@ -0,0 +1 @@
|
||||
testing fprintf
|
||||
@@ -0,0 +1,19 @@
|
||||
<?php
|
||||
|
||||
$tempfile = tempnam('/tmp', 'vmextfiletest');
|
||||
|
||||
$fields = array('apple', "\"banana\"");
|
||||
$f = fopen($tempfile, 'w');
|
||||
// #2511892: have to specify all fields due to a bug
|
||||
fputcsv($f, $fields, ',', '"');
|
||||
fclose($f);
|
||||
|
||||
$f = fopen($tempfile, 'r');
|
||||
fpassthru($f);
|
||||
fclose($f);
|
||||
|
||||
$f = fopen($tempfile, 'r');
|
||||
$vals = fgetcsv($f, 0, ',', '"', '\\'); // #2511892
|
||||
var_dump($vals);
|
||||
|
||||
unlink($tempfile);
|
||||
@@ -0,0 +1,7 @@
|
||||
apple,"""banana"""
|
||||
array(2) {
|
||||
[0]=>
|
||||
string(5) "apple"
|
||||
[1]=>
|
||||
string(8) ""banana""
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
<?php
|
||||
|
||||
$tempfile = tempnam('/tmp', 'vmextfiletest');
|
||||
|
||||
$f = fopen($tempfile, 'w');
|
||||
fputs($f, "testing fputs\n");
|
||||
fclose($f);
|
||||
|
||||
$f = fopen($tempfile, "r");
|
||||
fpassthru($f);
|
||||
|
||||
unlink($tempfile);
|
||||
@@ -0,0 +1 @@
|
||||
testing fputs
|
||||
@@ -0,0 +1,14 @@
|
||||
<?php
|
||||
|
||||
$tempfile = tempnam('/tmp', 'vmextfiletest');
|
||||
|
||||
$f = fopen($tempfile, 'w');
|
||||
fputs($f, "testing fread");
|
||||
fclose($f);
|
||||
|
||||
$f = fopen($tempfile, "r");
|
||||
echo fread($f, 7);
|
||||
echo fread($f, 100);
|
||||
echo "\n";
|
||||
|
||||
unlink($tempfile);
|
||||
@@ -0,0 +1 @@
|
||||
testing fread
|
||||
@@ -0,0 +1,13 @@
|
||||
<?php
|
||||
|
||||
$tempfile = tempnam('/tmp', 'vmextfiletest');
|
||||
|
||||
$f = fopen($tempfile, 'w');
|
||||
fputs($f, "testing fscanf");
|
||||
fclose($f);
|
||||
|
||||
$f = fopen($tempfile, "r");
|
||||
$res = fscanf($f, "%s %s");
|
||||
var_dump($res);
|
||||
|
||||
unlink($tempfile);
|
||||
@@ -0,0 +1,6 @@
|
||||
array(2) {
|
||||
[0]=>
|
||||
string(7) "testing"
|
||||
[1]=>
|
||||
string(6) "fscanf"
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
<?php
|
||||
|
||||
$tempfile = tempnam('/tmp', 'vmextfiletest');
|
||||
|
||||
$f = fopen($tempfile, 'w');
|
||||
fputs($f, "testing fseek");
|
||||
fclose($f);
|
||||
|
||||
$f = fopen($tempfile, "r");
|
||||
fseek($f, -5, SEEK_END);
|
||||
echo fread($f, 7);
|
||||
echo "\n";
|
||||
fseek($f, 7);
|
||||
echo fread($f, 7);
|
||||
echo "\n";
|
||||
|
||||
unlink($tempfile);
|
||||
@@ -0,0 +1,2 @@
|
||||
fseek
|
||||
fseek
|
||||
@@ -0,0 +1,12 @@
|
||||
<?php
|
||||
|
||||
$tempfile = tempnam('/tmp', 'vmextfiletest');
|
||||
|
||||
$f = fopen($tempfile, 'w');
|
||||
fputs($f, "testing fseek");
|
||||
fclose($f);
|
||||
|
||||
$f = fopen($tempfile, "r");
|
||||
var_dump(fstat($f)['size']);
|
||||
|
||||
unlink($tempfile);
|
||||
@@ -0,0 +1 @@
|
||||
int(13)
|
||||
@@ -0,0 +1,13 @@
|
||||
<?php
|
||||
|
||||
$tempfile = tempnam('/tmp', 'vmextfiletest');
|
||||
|
||||
$f = fopen($tempfile, 'w');
|
||||
fputs($f, "testing fseek");
|
||||
fclose($f);
|
||||
|
||||
$f = fopen($tempfile, "r");
|
||||
fseek($f, -5, SEEK_END);
|
||||
var_dump(ftell($f));
|
||||
|
||||
unlink($tempfile);
|
||||
@@ -0,0 +1 @@
|
||||
int(8)
|
||||
@@ -0,0 +1,16 @@
|
||||
<?php
|
||||
|
||||
$tempfile = tempnam('/tmp', 'vmextfiletest');
|
||||
|
||||
$f = fopen($tempfile, 'w');
|
||||
fputs($f, "testing ftruncate");
|
||||
fclose($f);
|
||||
|
||||
$f = fopen($tempfile, "r+");
|
||||
ftruncate($f, 7);
|
||||
fclose($f);
|
||||
|
||||
$f = fopen($tempfile, "r");
|
||||
var_dump(fread($f, 20));
|
||||
|
||||
unlink($tempfile);
|
||||
@@ -0,0 +1 @@
|
||||
string(7) "testing"
|
||||
@@ -0,0 +1,13 @@
|
||||
<?php
|
||||
|
||||
$tempfile = tempnam('/tmp', 'vmextfiletest');
|
||||
|
||||
$f = fopen($tempfile, 'w');
|
||||
fwrite($f, "testing fwrite", 7);
|
||||
fclose($f);
|
||||
|
||||
$f = fopen($tempfile, 'r');
|
||||
fpassthru($f);
|
||||
echo "\n";
|
||||
|
||||
unlink($tempfile);
|
||||
@@ -0,0 +1 @@
|
||||
testing
|
||||
@@ -0,0 +1,17 @@
|
||||
<?php
|
||||
|
||||
$tempfile = tempnam('/tmp', 'vmextfiletest');
|
||||
$tempfile2 = tempnam('/tmp', 'vmextfiletest');
|
||||
|
||||
unlink($tempfile2);
|
||||
var_dump(file_exists($tempfile2));
|
||||
link($tempfile, $tempfile2);
|
||||
var_dump(file_exists($tempfile2));
|
||||
|
||||
unlink($tempfile2);
|
||||
var_dump(file_exists($tempfile2));
|
||||
symlink($tempfile, $tempfile2);
|
||||
var_dump(file_exists($tempfile2));
|
||||
|
||||
unlink($tempfile);
|
||||
unlink($tempfile2);
|
||||
@@ -0,0 +1,4 @@
|
||||
bool(false)
|
||||
bool(true)
|
||||
bool(false)
|
||||
bool(true)
|
||||
@@ -0,0 +1,8 @@
|
||||
<?php
|
||||
|
||||
var_dump(basename('test/ext/test_ext_file.tmp'));
|
||||
var_dump(basename('test/ext/test_ext_file.tmp', '.tmp'));
|
||||
|
||||
var_dump(fnmatch(__DIR__.'/test_*_file.txt', __DIR__.'/test_ext_file.txt'));
|
||||
|
||||
var_dump(glob(__DIR__.'/test_*_file.txt'));
|
||||
@@ -0,0 +1,7 @@
|
||||
string(17) "test_ext_file.tmp"
|
||||
string(13) "test_ext_file"
|
||||
bool(true)
|
||||
array(1) {
|
||||
[0]=>
|
||||
string(%d) %s
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
<?php
|
||||
|
||||
$hdf = "bool = false\n".
|
||||
"string = text\n".
|
||||
"num = 12345\n".
|
||||
"arr {\n".
|
||||
" bool = false\n".
|
||||
" string = anothertext\n".
|
||||
" num = 6789\n".
|
||||
"}\n";
|
||||
|
||||
var_dump(parse_hdf_string($hdf));
|
||||
@@ -0,0 +1,17 @@
|
||||
array(4) {
|
||||
["bool"]=>
|
||||
bool(false)
|
||||
["string"]=>
|
||||
string(4) "text"
|
||||
["num"]=>
|
||||
int(12345)
|
||||
["arr"]=>
|
||||
array(3) {
|
||||
["bool"]=>
|
||||
bool(false)
|
||||
["string"]=>
|
||||
string(11) "anothertext"
|
||||
["num"]=>
|
||||
int(6789)
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
<?php
|
||||
|
||||
$ini =
|
||||
";;; Created on Tuesday, October 27, 2009 at 12:01 PM GMT\n".
|
||||
"[GJK_Browscap_Version]\n".
|
||||
"Version=4520\n".
|
||||
"Released=Tue, 27 Oct 2009 12:01:07 -0000\n".
|
||||
"\n".
|
||||
"\n;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; DefaultProperties\n".
|
||||
"\n".
|
||||
"[DefaultProperties]\n".
|
||||
"Browser=\"DefaultProperties\"\n".
|
||||
"Version=0\n".
|
||||
"Platform=unknown\n".
|
||||
"Beta=false\n";
|
||||
|
||||
var_dump(parse_ini_string($ini));
|
||||
echo "===\n";
|
||||
var_dump(parse_ini_string($ini, true));
|
||||
@@ -0,0 +1,33 @@
|
||||
array(5) {
|
||||
["Version"]=>
|
||||
string(1) "0"
|
||||
["Released"]=>
|
||||
string(31) "Tue, 27 Oct 2009 12:01:07 -0000"
|
||||
["Browser"]=>
|
||||
string(17) "DefaultProperties"
|
||||
["Platform"]=>
|
||||
string(7) "unknown"
|
||||
["Beta"]=>
|
||||
string(0) ""
|
||||
}
|
||||
===
|
||||
array(2) {
|
||||
["GJK_Browscap_Version"]=>
|
||||
array(2) {
|
||||
["Version"]=>
|
||||
string(4) "4520"
|
||||
["Released"]=>
|
||||
string(31) "Tue, 27 Oct 2009 12:01:07 -0000"
|
||||
}
|
||||
["DefaultProperties"]=>
|
||||
array(4) {
|
||||
["Browser"]=>
|
||||
string(17) "DefaultProperties"
|
||||
["Version"]=>
|
||||
string(1) "0"
|
||||
["Platform"]=>
|
||||
string(7) "unknown"
|
||||
["Beta"]=>
|
||||
string(0) ""
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
<?php
|
||||
|
||||
var_dump(pathinfo(__DIR__.'/test_ext_file.txt'));
|
||||
|
||||
@@ -0,0 +1,10 @@
|
||||
array(4) {
|
||||
["dirname"]=>
|
||||
string(%d) %s
|
||||
["basename"]=>
|
||||
string(17) "test_ext_file.txt"
|
||||
["extension"]=>
|
||||
string(3) "txt"
|
||||
["filename"]=>
|
||||
string(13) "test_ext_file"
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
<?php
|
||||
|
||||
$tempfile = tempnam('/tmp', 'vmextfiletest');
|
||||
|
||||
$f = fopen($tempfile, 'w');
|
||||
fputs($f, 'testing popen');
|
||||
fclose($f);
|
||||
|
||||
var_dump(file_exists($tempfile));
|
||||
var_dump(file_exists('somethingthatdoesntexist'));
|
||||
|
||||
$f = popen("cat $tempfile", 'r');
|
||||
var_dump(fread($f, 20));
|
||||
pclose($f);
|
||||
|
||||
unlink($tempfile);
|
||||
@@ -0,0 +1,3 @@
|
||||
bool(true)
|
||||
bool(false)
|
||||
string(13) "testing popen"
|
||||
@@ -0,0 +1,21 @@
|
||||
<?php
|
||||
|
||||
$tempfile = tempnam('/tmp', 'vmextfiletest');
|
||||
var_dump(is_file($tempfile));
|
||||
var_dump(is_dir($tempfile));
|
||||
var_dump(is_dir('/tmp'));
|
||||
var_dump(is_link($tempfile));
|
||||
var_dump(is_executable($tempfile));
|
||||
chmod($tempfile, 0777);
|
||||
var_dump(is_executable($tempfile));
|
||||
var_dump(is_writable($tempfile));
|
||||
var_dump(is_readable($tempfile));
|
||||
var_dump(is_uploaded_file($tempfile));
|
||||
var_dump(filetype($tempfile));
|
||||
|
||||
unlink($tempfile);
|
||||
|
||||
mkdir($tempfile);
|
||||
var_dump(is_dir($tempfile));
|
||||
rmdir($tempfile);
|
||||
var_dump(is_dir($tempfile));
|
||||
@@ -0,0 +1,12 @@
|
||||
bool(true)
|
||||
bool(false)
|
||||
bool(true)
|
||||
bool(false)
|
||||
bool(false)
|
||||
bool(true)
|
||||
bool(true)
|
||||
bool(true)
|
||||
bool(false)
|
||||
string(4) "file"
|
||||
bool(true)
|
||||
bool(false)
|
||||
@@ -0,0 +1,15 @@
|
||||
<?php
|
||||
|
||||
$tempfile = tempnam('/tmp', 'vmextfiletest');
|
||||
|
||||
$f = fopen($tempfile, 'w');
|
||||
fwrite($f, "testing read/write", 7);
|
||||
fclose($f);
|
||||
|
||||
$f = fopen($tempfile, "r+");
|
||||
fseek($f, 8);
|
||||
fwrite($f, "succeeds");
|
||||
fseek($f, 8);
|
||||
var_dump(fread($f, 8));
|
||||
|
||||
unlink($tempfile);
|
||||
@@ -0,0 +1 @@
|
||||
string(8) "succeeds"
|
||||
@@ -0,0 +1,33 @@
|
||||
<?php
|
||||
|
||||
$d = dir(__DIR__);
|
||||
while ($ent = readdir($d->handle)) {
|
||||
if ($ent == 'test_ext_file.txt') {
|
||||
var_dump($ent);
|
||||
}
|
||||
}
|
||||
closedir($d);
|
||||
|
||||
$d = opendir(__DIR__);
|
||||
while ($ent = readdir($d)) {
|
||||
if ($ent == 'test_ext_file.txt') {
|
||||
var_dump($ent);
|
||||
}
|
||||
}
|
||||
|
||||
rewinddir($d);
|
||||
|
||||
while ($ent = readdir($d)) {
|
||||
if ($ent == 'test_ext_file.txt') {
|
||||
var_dump($ent);
|
||||
}
|
||||
}
|
||||
|
||||
closedir($d);
|
||||
|
||||
foreach (scandir(__DIR__) as $x) {
|
||||
if ($x == 'test_ext_file.txt') {
|
||||
var_dump($x);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,4 @@
|
||||
string(17) "test_ext_file.txt"
|
||||
string(17) "test_ext_file.txt"
|
||||
string(17) "test_ext_file.txt"
|
||||
string(17) "test_ext_file.txt"
|
||||
@@ -0,0 +1,3 @@
|
||||
<?php
|
||||
|
||||
readfile(__DIR__.'/test_ext_file.txt', 17);
|
||||
@@ -0,0 +1 @@
|
||||
Testing Ext File
|
||||
@@ -0,0 +1,17 @@
|
||||
<?php
|
||||
|
||||
$tempfile = tempnam('/tmp', 'vmextfiletest');
|
||||
|
||||
$f = fopen($tempfile, 'w');
|
||||
fputs($f, 'testing rewind');
|
||||
fclose($f);
|
||||
|
||||
$f = fopen($tempfile, 'r');
|
||||
var_dump(fread($f, 7));
|
||||
var_dump(fread($f, 100));
|
||||
var_dump(fread($f, 7));
|
||||
rewind($f);
|
||||
var_dump(fread($f, 7));
|
||||
var_dump(fread($f, 100));
|
||||
|
||||
unlink($tempfile);
|
||||
@@ -0,0 +1,5 @@
|
||||
string(7) "testing"
|
||||
string(7) " rewind"
|
||||
string(0) ""
|
||||
string(7) "testing"
|
||||
string(7) " rewind"
|
||||
Arquivo executável
+1
@@ -0,0 +1 @@
|
||||
Testing Ext File
|
||||
@@ -0,0 +1,24 @@
|
||||
<?php
|
||||
|
||||
$tempfile = tempnam('/tmp', 'vmextfiletest');
|
||||
|
||||
touch($tempfile);
|
||||
var_dump(file_exists($tempfile));
|
||||
|
||||
$tempfile2 = tempnam('/tmp', 'vmextfiletest');
|
||||
|
||||
var_dump(file_exists($tempfile2));
|
||||
copy($tempfile, $tempfile2);
|
||||
var_dump(file_exists($tempfile2));
|
||||
|
||||
$tempfile3 = tempnam('/tmp', 'vmextfiletest');
|
||||
|
||||
var_dump(file_exists($tempfile2));
|
||||
rename($tempfile2, $tempfile3);
|
||||
var_dump(file_exists($tempfile2));
|
||||
|
||||
var_dump(file_exists($tempfile3));
|
||||
|
||||
unlink($tempfile);
|
||||
unlink($tempfile2);
|
||||
unlink($tempfile3);
|
||||
@@ -0,0 +1,6 @@
|
||||
bool(true)
|
||||
bool(true)
|
||||
bool(true)
|
||||
bool(true)
|
||||
bool(false)
|
||||
bool(true)
|
||||
@@ -0,0 +1,13 @@
|
||||
<?php
|
||||
|
||||
$tempfile = tempnam('/tmp', 'vmextfiletest');
|
||||
|
||||
$f = fopen($tempfile, 'w');
|
||||
vfprintf($f, "%s %s", array("testing", "vfprintf"));
|
||||
fclose($f);
|
||||
|
||||
$f = fopen($tempfile, "r");
|
||||
fpassthru($f);
|
||||
echo "\n";
|
||||
|
||||
unlink($tempfile);
|
||||
@@ -0,0 +1 @@
|
||||
testing vfprintf
|
||||
@@ -0,0 +1,9 @@
|
||||
<?php
|
||||
|
||||
$hdf = array(
|
||||
'bool' => false,
|
||||
'string' => 'asd',
|
||||
'num' => 12345,
|
||||
'arr' => array('bool' => false, 'string' => 'blah', 'num2' => 6789)
|
||||
);
|
||||
var_dump(write_hdf_string($hdf));
|
||||
@@ -0,0 +1,9 @@
|
||||
string(91) "bool = false
|
||||
string = asd
|
||||
num = 12345
|
||||
arr {
|
||||
bool = false
|
||||
string = blah
|
||||
num2 = 6789
|
||||
}
|
||||
"
|
||||
Referência em uma Nova Issue
Bloquear um usuário