mirror of
https://github.com/php/php-src.git
synced 2025-08-15 21:48:51 +02:00
Fixed the UTF-8 and long path support in the streams on Windows.
Since long the default PHP charset is UTF-8, however the Windows part is
out of step with this important point. The current implementation in PHP
doesn't technically permit to handle UTF-8 filepath and several other
things. Till now, only the ANSI compatible APIs are being used. Here is more
about it
dd317752
%28v=vs.85%29.aspx
The patch fixes not only issues with multibyte filenames under
incompatible codepages, but indirectly also issues with some other multibyte
encodings like BIG5, Shift-JIS, etc. by providing a clean way to access
filenames in UTF-8. Below is a small list of issues from the bug tracker,
that are getting fixed:
https://bugs.php.net/63401
https://bugs.php.net/41199
https://bugs.php.net/50203
https://bugs.php.net/71509
https://bugs.php.net/64699
https://bugs.php.net/64506
https://bugs.php.net/30195
https://bugs.php.net/65358
https://bugs.php.net/61315
https://bugs.php.net/70943
https://bugs.php.net/70903
https://bugs.php.net/63593
https://bugs.php.net/54977
https://bugs.php.net/54028
https://bugs.php.net/43148
https://bugs.php.net/30730
https://bugs.php.net/33350
https://bugs.php.net/35300
https://bugs.php.net/46990
https://bugs.php.net/61309
https://bugs.php.net/69333
https://bugs.php.net/45517
https://bugs.php.net/70551
https://bugs.php.net/50197
https://bugs.php.net/72200
https://bugs.php.net/37672
Yet more related tickets can for sure be found - on bugs.php.net, Stackoverflow
and Github. Some of the bugs are pretty recent, some descend to early
2000th, but the user comments in there last even till today. Just for example,
bug #30195 was opened in 2004, the latest comment in there was made in 2014. It
is certain, that these bugs descend not only to pure PHP use cases, but get also
redirected from the popular PHP based projects. Given the modern systems (and
those supported by PHP) are always based on NTFS, there is no excuse to keep
these issues unresolved.
The internalization approach on Windows is in many ways different from
UNIX and Linux, while it supports and is based on Unicode. It depends on the
current system code page, APIs used and exact kind how the binary was compiled
The locale doesn't affect the way Unicode or ANSI API work. PHP in particular
is being compiled without _UNICODE defined and this is conditioned by the
way we handle strings. Here is more about it
https://msdn.microsoft.com/en-us/library/tsbaswba.aspx
However, with any system code page ANSI functions automatically convert
paths to UTF-16. Paths in some encodings incompatible with the
current system code page, won't work correctly with ANSI APIs. PHP
till now only uses the ANSI Windows APIs.
For example, on a system with the current code page 1252, the paths
in cp1252 are supported and transparently converted to UTF-16 by the
ANSI functions. Once one wants to handle a filepath encoded with cp932 on
that particular system, an ANSI or a POSIX compatible function used in
PHP will produce an erroneous result. When trying to convert that cp932 path
to UTF-8 and passing to the ANSI functions, an ANSI function would
likely interpret the UTF-8 string as some string in the current code page and
create a filepath that represents every single byte of the UTF-8 string.
These behaviors are not only broken but also disregard the documented
INI settings.
This patch solves the issies with the multibyte paths on Windows by
intelligently enforcing the usage of the Unicode aware APIs. For
functions expect Unicode (fe CreateFileW, FindFirstFileW, etc.), arguments
will be converted to UTF-16 wide chars. For functions returning Unicode
aware data (fe GetCurrentDirectoryW, etc.), resulting wide string is
converted back to char's depending on the current PHP charset settings,
either to the current ANSI codepage (this is the behavior prior to this patch)
or to UTF-8 (the default behavior).
In a particular case, users might have to explicitly set
internal_encoding or default_charset, if filenames in ANSI codepage are
necessary. Current tests show no regressions and witness that this will be an
exotic case, the current default UTF-8 encoding is compatible with any
supported system. The dependency libraries are long switching to Unicode APIs,
so some tests were also added for extensions not directly related to streams.
At large, the patch brings over 150 related tests into the core. Those target
and was run on various environments with European, Asian, etc. codepages.
General PHP frameworks was tested and showed no regressions.
The impact on the current C code base is low, the most places affected
are the Windows only places in the three files tsrm_win32.c, zend_virtual_cwd.c
and plain_wrapper.c. The actual implementation of the most of the wide
char supporting functionality is in win32/ioutil.* and win32/codepage.*,
several low level functionsare extended in place to avoid reimplementation for
now. No performance impact was sighted. As previously mentioned, the ANSI APIs
used prior the patch perform Unicode conversions internally. Using the
Unicode APIs directly while doing custom conversions just retains the status
quo. The ways to optimize it are open (fe. by implementing caching for the
strings converted to wide variants).
The long path implementation is user transparent. If a path exceeds the
length of _MAX_PATH, it'll be automatically prefixed with \\?\. The MAXPATHLEN
is set to 2048 bytes.
Appreciation to Pierre Joye, Matt Ficken, @algo13 and others for tips, ideas
and testing.
Thanks.
This commit is contained in:
parent
3abd9c34c1
commit
3d3f11ede4
266 changed files with 1045298 additions and 212 deletions
|
@ -42,7 +42,10 @@ char *alloca ();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef MAXPATHLEN
|
#ifndef MAXPATHLEN
|
||||||
# ifdef PATH_MAX
|
# if _WIN32
|
||||||
|
# include "win32/ioutil.h"
|
||||||
|
# define MAXPATHLEN PHP_WIN32_IOUTIL_MAXPATHLEN
|
||||||
|
# elif PATH_MAX
|
||||||
# define MAXPATHLEN PATH_MAX
|
# define MAXPATHLEN PATH_MAX
|
||||||
# elif defined(MAX_PATH)
|
# elif defined(MAX_PATH)
|
||||||
# define MAXPATHLEN MAX_PATH
|
# define MAXPATHLEN MAX_PATH
|
||||||
|
|
|
@ -33,6 +33,7 @@
|
||||||
#include <Sddl.h>
|
#include <Sddl.h>
|
||||||
#include "tsrm_win32.h"
|
#include "tsrm_win32.h"
|
||||||
#include "zend_virtual_cwd.h"
|
#include "zend_virtual_cwd.h"
|
||||||
|
#include "win32/ioutil.h"
|
||||||
|
|
||||||
#ifdef ZTS
|
#ifdef ZTS
|
||||||
static ts_rsrc_id win32_globals_id;
|
static ts_rsrc_id win32_globals_id;
|
||||||
|
@ -208,28 +209,42 @@ TSRM_API int tsrm_win32_access(const char *pathname, int mode)
|
||||||
BYTE * psec_desc = NULL;
|
BYTE * psec_desc = NULL;
|
||||||
BOOL fAccess = FALSE;
|
BOOL fAccess = FALSE;
|
||||||
|
|
||||||
|
PHP_WIN32_IOUTIL_INIT_W(pathname)
|
||||||
|
if (!pathw) {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
realpath_cache_bucket * bucket = NULL;
|
realpath_cache_bucket * bucket = NULL;
|
||||||
char * real_path = NULL;
|
char * real_path = NULL;
|
||||||
|
|
||||||
if (mode == 1 /*X_OK*/) {
|
if (mode == 1 /*X_OK*/) {
|
||||||
DWORD type;
|
DWORD type;
|
||||||
return GetBinaryType(pathname, &type) ? 0 : -1;
|
int ret;
|
||||||
|
|
||||||
|
ret = GetBinaryTypeW(pathw, &type) ? 0 : -1;
|
||||||
|
|
||||||
|
PHP_WIN32_IOUTIL_CLEANUP_W()
|
||||||
|
|
||||||
|
return ret;
|
||||||
} else {
|
} else {
|
||||||
if(!IS_ABSOLUTE_PATH(pathname, strlen(pathname)+1)) {
|
if(!IS_ABSOLUTE_PATH(pathname, strlen(pathname)+1)) {
|
||||||
real_path = (char *)malloc(MAX_PATH);
|
real_path = (char *)malloc(MAXPATHLEN);
|
||||||
if(tsrm_realpath(pathname, real_path) == NULL) {
|
if(tsrm_realpath(pathname, real_path) == NULL) {
|
||||||
goto Finished;
|
goto Finished;
|
||||||
}
|
}
|
||||||
pathname = real_path;
|
pathname = real_path;
|
||||||
|
PHP_WIN32_IOUTIL_REINIT_W(pathname);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(access(pathname, mode)) {
|
if(php_win32_ioutil_access(pathname, mode)) {
|
||||||
|
PHP_WIN32_IOUTIL_CLEANUP_W()
|
||||||
free(real_path);
|
free(real_path);
|
||||||
return errno;
|
return errno;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* If only existence check is made, return now */
|
/* If only existence check is made, return now */
|
||||||
if (mode == 0) {
|
if (mode == 0) {
|
||||||
|
PHP_WIN32_IOUTIL_CLEANUP_W()
|
||||||
free(real_path);
|
free(real_path);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -285,10 +300,11 @@ TSRM_API int tsrm_win32_access(const char *pathname, int mode)
|
||||||
if(bucket == NULL && real_path == NULL) {
|
if(bucket == NULL && real_path == NULL) {
|
||||||
/* We used the pathname directly. Call tsrm_realpath */
|
/* We used the pathname directly. Call tsrm_realpath */
|
||||||
/* so that entry is created in realpath cache */
|
/* so that entry is created in realpath cache */
|
||||||
real_path = (char *)malloc(MAX_PATH);
|
real_path = (char *)malloc(MAXPATHLEN);
|
||||||
if(tsrm_realpath(pathname, real_path) != NULL) {
|
if(tsrm_realpath(pathname, real_path) != NULL) {
|
||||||
pathname = real_path;
|
pathname = real_path;
|
||||||
bucket = realpath_cache_lookup(pathname, (int)strlen(pathname), t);
|
bucket = realpath_cache_lookup(pathname, (int)strlen(pathname), t);
|
||||||
|
PHP_WIN32_IOUTIL_REINIT_W(pathname);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -325,13 +341,13 @@ TSRM_API int tsrm_win32_access(const char *pathname, int mode)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Get size of security buffer. Call is expected to fail */
|
/* Get size of security buffer. Call is expected to fail */
|
||||||
if(GetFileSecurity(pathname, sec_info, NULL, 0, &sec_desc_length)) {
|
if(GetFileSecurityW(pathw, sec_info, NULL, 0, &sec_desc_length)) {
|
||||||
goto Finished;
|
goto Finished;
|
||||||
}
|
}
|
||||||
|
|
||||||
psec_desc = (BYTE *)malloc(sec_desc_length);
|
psec_desc = (BYTE *)malloc(sec_desc_length);
|
||||||
if(psec_desc == NULL ||
|
if(psec_desc == NULL ||
|
||||||
!GetFileSecurity(pathname, sec_info, (PSECURITY_DESCRIPTOR)psec_desc, sec_desc_length, &sec_desc_length)) {
|
!GetFileSecurityW(pathw, sec_info, (PSECURITY_DESCRIPTOR)psec_desc, sec_desc_length, &sec_desc_length)) {
|
||||||
goto Finished;
|
goto Finished;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -373,6 +389,7 @@ Finished:
|
||||||
real_path = NULL;
|
real_path = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
PHP_WIN32_IOUTIL_CLEANUP_W()
|
||||||
if(fAccess == FALSE) {
|
if(fAccess == FALSE) {
|
||||||
errno = EACCES;
|
errno = EACCES;
|
||||||
return errno;
|
return errno;
|
||||||
|
@ -459,14 +476,15 @@ TSRM_API FILE *popen_ex(const char *command, const char *type, const char *cwd,
|
||||||
{
|
{
|
||||||
FILE *stream = NULL;
|
FILE *stream = NULL;
|
||||||
int fno, type_len, read, mode;
|
int fno, type_len, read, mode;
|
||||||
STARTUPINFO startup;
|
STARTUPINFOW startup;
|
||||||
PROCESS_INFORMATION process;
|
PROCESS_INFORMATION process;
|
||||||
SECURITY_ATTRIBUTES security;
|
SECURITY_ATTRIBUTES security;
|
||||||
HANDLE in, out;
|
HANDLE in, out;
|
||||||
DWORD dwCreateFlags = 0;
|
DWORD dwCreateFlags = 0;
|
||||||
BOOL res;
|
BOOL res;
|
||||||
process_pair *proc;
|
process_pair *proc;
|
||||||
char *cmd;
|
char *cmd = NULL;
|
||||||
|
wchar_t *cmdw = NULL, *cwdw = NULL, *envw = NULL;
|
||||||
int i;
|
int i;
|
||||||
char *ptype = (char *)type;
|
char *ptype = (char *)type;
|
||||||
HANDLE thread_token = NULL;
|
HANDLE thread_token = NULL;
|
||||||
|
@ -490,18 +508,42 @@ TSRM_API FILE *popen_ex(const char *command, const char *type, const char *cwd,
|
||||||
ptype++;
|
ptype++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
cmd = (char*)malloc(strlen(command)+strlen(TWG(comspec))+sizeof(" /c ")+2);
|
||||||
|
if (!cmd) {
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
sprintf(cmd, "%s /c \"%s\"", TWG(comspec), command);
|
||||||
|
cmdw = php_win32_cp_any_to_w(cmd);
|
||||||
|
if (!cmdw) {
|
||||||
|
free(cmd);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (cwd) {
|
||||||
|
cwdw = php_win32_ioutil_any_to_w(cwd);
|
||||||
|
if (!cwdw) {
|
||||||
|
free(cmd);
|
||||||
|
free(cmdw);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
security.nLength = sizeof(SECURITY_ATTRIBUTES);
|
security.nLength = sizeof(SECURITY_ATTRIBUTES);
|
||||||
security.bInheritHandle = TRUE;
|
security.bInheritHandle = TRUE;
|
||||||
security.lpSecurityDescriptor = NULL;
|
security.lpSecurityDescriptor = NULL;
|
||||||
|
|
||||||
if (!type_len || !CreatePipe(&in, &out, &security, 2048L)) {
|
if (!type_len || !CreatePipe(&in, &out, &security, 2048L)) {
|
||||||
|
free(cmdw);
|
||||||
|
free(cwdw);
|
||||||
|
free(cmd);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
memset(&startup, 0, sizeof(STARTUPINFO));
|
memset(&startup, 0, sizeof(STARTUPINFOW));
|
||||||
memset(&process, 0, sizeof(PROCESS_INFORMATION));
|
memset(&process, 0, sizeof(PROCESS_INFORMATION));
|
||||||
|
|
||||||
startup.cb = sizeof(STARTUPINFO);
|
startup.cb = sizeof(STARTUPINFOW);
|
||||||
startup.dwFlags = STARTF_USESTDHANDLES;
|
startup.dwFlags = STARTF_USESTDHANDLES;
|
||||||
startup.hStdError = GetStdHandle(STD_ERROR_HANDLE);
|
startup.hStdError = GetStdHandle(STD_ERROR_HANDLE);
|
||||||
|
|
||||||
|
@ -533,19 +575,28 @@ TSRM_API FILE *popen_ex(const char *command, const char *type, const char *cwd,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
cmd = (char*)malloc(strlen(command)+strlen(TWG(comspec))+sizeof(" /c ")+2);
|
envw = php_win32_cp_env_any_to_w(env);
|
||||||
if (!cmd) {
|
if (envw) {
|
||||||
|
dwCreateFlags |= CREATE_UNICODE_ENVIRONMENT;
|
||||||
|
} else {
|
||||||
|
if (env) {
|
||||||
|
free(cmd);
|
||||||
|
free(cmdw);
|
||||||
|
free(cwdw);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
sprintf(cmd, "%s /c \"%s\"", TWG(comspec), command);
|
|
||||||
if (asuser) {
|
if (asuser) {
|
||||||
res = CreateProcessAsUser(token_user, NULL, cmd, &security, &security, security.bInheritHandle, dwCreateFlags, env, cwd, &startup, &process);
|
res = CreateProcessAsUserW(token_user, NULL, cmdw, &security, &security, security.bInheritHandle, dwCreateFlags, envw, cwdw, &startup, &process);
|
||||||
CloseHandle(token_user);
|
CloseHandle(token_user);
|
||||||
} else {
|
} else {
|
||||||
res = CreateProcess(NULL, cmd, &security, &security, security.bInheritHandle, dwCreateFlags, env, cwd, &startup, &process);
|
res = CreateProcessW(NULL, cmdw, &security, &security, security.bInheritHandle, dwCreateFlags, envw, cwdw, &startup, &process);
|
||||||
}
|
}
|
||||||
free(cmd);
|
free(cmd);
|
||||||
|
free(cmdw);
|
||||||
|
free(cwdw);
|
||||||
|
free(envw);
|
||||||
|
|
||||||
if (!res) {
|
if (!res) {
|
||||||
return NULL;
|
return NULL;
|
||||||
|
@ -749,10 +800,17 @@ TSRM_API int win32_utime(const char *filename, struct utimbuf *buf) /* {{{ */
|
||||||
{
|
{
|
||||||
FILETIME mtime, atime;
|
FILETIME mtime, atime;
|
||||||
HANDLE hFile;
|
HANDLE hFile;
|
||||||
|
PHP_WIN32_IOUTIL_INIT_W(filename)
|
||||||
|
|
||||||
hFile = CreateFile(filename, GENERIC_WRITE, FILE_SHARE_WRITE|FILE_SHARE_READ, NULL,
|
if (!pathw) {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
hFile = CreateFileW(pathw, GENERIC_WRITE, FILE_SHARE_WRITE|FILE_SHARE_READ, NULL,
|
||||||
OPEN_ALWAYS, FILE_FLAG_BACKUP_SEMANTICS, NULL);
|
OPEN_ALWAYS, FILE_FLAG_BACKUP_SEMANTICS, NULL);
|
||||||
|
|
||||||
|
PHP_WIN32_IOUTIL_CLEANUP_W()
|
||||||
|
|
||||||
/* OPEN_ALWAYS mode sets the last error to ERROR_ALREADY_EXISTS but
|
/* OPEN_ALWAYS mode sets the last error to ERROR_ALREADY_EXISTS but
|
||||||
the CreateFile operation succeeds */
|
the CreateFile operation succeeds */
|
||||||
if (GetLastError() == ERROR_ALREADY_EXISTS) {
|
if (GetLastError() == ERROR_ALREADY_EXISTS) {
|
||||||
|
|
|
@ -759,6 +759,11 @@ int zend_startup(zend_utility_functions *utility_functions, char **extensions) /
|
||||||
|
|
||||||
zend_ini_startup();
|
zend_ini_startup();
|
||||||
|
|
||||||
|
#ifdef ZEND_WIN32
|
||||||
|
/* Uses INI settings, so needs to be run after it. */
|
||||||
|
php_win32_cp_setup();
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifdef ZTS
|
#ifdef ZTS
|
||||||
tsrm_set_new_thread_end_handler(zend_new_thread_end_handler);
|
tsrm_set_new_thread_end_handler(zend_new_thread_end_handler);
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -67,6 +67,7 @@ static int dummy_internal_encoding_setter(const zend_encoding *encoding)
|
||||||
return FAILURE;
|
return FAILURE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static zend_multibyte_functions multibyte_functions_dummy;
|
||||||
static zend_multibyte_functions multibyte_functions = {
|
static zend_multibyte_functions multibyte_functions = {
|
||||||
NULL,
|
NULL,
|
||||||
dummy_encoding_fetcher,
|
dummy_encoding_fetcher,
|
||||||
|
@ -108,6 +109,7 @@ ZEND_API int zend_multibyte_set_functions(const zend_multibyte_functions *functi
|
||||||
return FAILURE;
|
return FAILURE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
multibyte_functions_dummy = multibyte_functions;
|
||||||
multibyte_functions = *functions;
|
multibyte_functions = *functions;
|
||||||
|
|
||||||
/* As zend_multibyte_set_functions() gets called after ini settings were
|
/* As zend_multibyte_set_functions() gets called after ini settings were
|
||||||
|
@ -120,6 +122,11 @@ ZEND_API int zend_multibyte_set_functions(const zend_multibyte_functions *functi
|
||||||
return SUCCESS;
|
return SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ZEND_API void zend_multibyte_restore_functions(void)
|
||||||
|
{
|
||||||
|
multibyte_functions = multibyte_functions_dummy;
|
||||||
|
}
|
||||||
|
|
||||||
ZEND_API const zend_multibyte_functions *zend_multibyte_get_functions(void)
|
ZEND_API const zend_multibyte_functions *zend_multibyte_get_functions(void)
|
||||||
{
|
{
|
||||||
return multibyte_functions.provider_name ? &multibyte_functions: NULL;
|
return multibyte_functions.provider_name ? &multibyte_functions: NULL;
|
||||||
|
|
|
@ -60,6 +60,7 @@ ZEND_API extern const zend_encoding *zend_multibyte_encoding_utf8;
|
||||||
|
|
||||||
/* multibyte utility functions */
|
/* multibyte utility functions */
|
||||||
ZEND_API int zend_multibyte_set_functions(const zend_multibyte_functions *functions);
|
ZEND_API int zend_multibyte_set_functions(const zend_multibyte_functions *functions);
|
||||||
|
ZEND_API void zend_multibyte_restore_functions(void);
|
||||||
ZEND_API const zend_multibyte_functions *zend_multibyte_get_functions(void);
|
ZEND_API const zend_multibyte_functions *zend_multibyte_get_functions(void);
|
||||||
|
|
||||||
ZEND_API const zend_encoding *zend_multibyte_fetch_encoding(const char *name);
|
ZEND_API const zend_encoding *zend_multibyte_fetch_encoding(const char *name);
|
||||||
|
|
|
@ -218,37 +218,30 @@ static inline time_t FileTimeToUnixTime(const FILETIME *FileTime)
|
||||||
}
|
}
|
||||||
|
|
||||||
CWD_API int php_sys_readlink(const char *link, char *target, size_t target_len){ /* {{{ */
|
CWD_API int php_sys_readlink(const char *link, char *target, size_t target_len){ /* {{{ */
|
||||||
HINSTANCE kernel32;
|
|
||||||
HANDLE hFile;
|
HANDLE hFile;
|
||||||
DWORD dwRet;
|
DWORD dwRet;
|
||||||
|
wchar_t *linkw = php_win32_ioutil_any_to_w(link), targetw[MAXPATHLEN];
|
||||||
|
size_t _tmp_len;
|
||||||
|
char *_tmp;
|
||||||
|
|
||||||
typedef BOOL (WINAPI *gfpnh_func)(HANDLE, LPTSTR, DWORD, DWORD);
|
if (!linkw) {
|
||||||
gfpnh_func pGetFinalPathNameByHandle;
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
if (!target_len) {
|
if (!target_len) {
|
||||||
|
free(linkw);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
kernel32 = LoadLibrary("kernel32.dll");
|
hFile = CreateFileW(linkw, // file to open
|
||||||
|
|
||||||
if (kernel32) {
|
|
||||||
pGetFinalPathNameByHandle = (gfpnh_func)GetProcAddress(kernel32, "GetFinalPathNameByHandleA");
|
|
||||||
if (pGetFinalPathNameByHandle == NULL) {
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
hFile = CreateFile(link, // file to open
|
|
||||||
GENERIC_READ, // open for reading
|
GENERIC_READ, // open for reading
|
||||||
FILE_SHARE_READ, // share for reading
|
FILE_SHARE_READ, // share for reading
|
||||||
NULL, // default security
|
NULL, // default security
|
||||||
OPEN_EXISTING, // existing file only
|
OPEN_EXISTING, // existing file only
|
||||||
FILE_FLAG_BACKUP_SEMANTICS, // normal file
|
FILE_FLAG_BACKUP_SEMANTICS, // normal file
|
||||||
NULL); // no attr. template
|
NULL); // no attr. template
|
||||||
|
|
||||||
if( hFile == INVALID_HANDLE_VALUE) {
|
if( hFile == INVALID_HANDLE_VALUE) {
|
||||||
|
free(linkw);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -258,12 +251,24 @@ CWD_API int php_sys_readlink(const char *link, char *target, size_t target_len){
|
||||||
with VS2012 and earlier, and seems not to be fixed till
|
with VS2012 and earlier, and seems not to be fixed till
|
||||||
now. Thus, correcting target_len so it's suddenly don't
|
now. Thus, correcting target_len so it's suddenly don't
|
||||||
overflown. */
|
overflown. */
|
||||||
dwRet = pGetFinalPathNameByHandle(hFile, target, target_len - 1, VOLUME_NAME_DOS);
|
dwRet = GetFinalPathNameByHandleW(hFile, targetw, MAXPATHLEN, VOLUME_NAME_DOS);
|
||||||
if(dwRet >= target_len || dwRet >= MAXPATHLEN || dwRet == 0) {
|
if(dwRet >= target_len || dwRet >= MAXPATHLEN || dwRet == 0) {
|
||||||
|
free(linkw);
|
||||||
|
CloseHandle(hFile);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
_tmp = php_win32_ioutil_conv_w_to_any(targetw, dwRet, &_tmp_len);
|
||||||
|
if (!_tmp || _tmp_len >= MAXPATHLEN) {
|
||||||
CloseHandle(hFile);
|
CloseHandle(hFile);
|
||||||
|
free(linkw);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
memcpy(target, _tmp, _tmp_len);
|
||||||
|
free(_tmp);
|
||||||
|
|
||||||
|
CloseHandle(hFile);
|
||||||
|
free(linkw);
|
||||||
|
|
||||||
if(dwRet > 4) {
|
if(dwRet > 4) {
|
||||||
/* Skip first 4 characters if they are "\??\" */
|
/* Skip first 4 characters if they are "\??\" */
|
||||||
|
@ -295,9 +300,22 @@ CWD_API int php_sys_stat_ex(const char *path, zend_stat_t *buf, int lstat) /* {{
|
||||||
LARGE_INTEGER t;
|
LARGE_INTEGER t;
|
||||||
const size_t path_len = strlen(path);
|
const size_t path_len = strlen(path);
|
||||||
ALLOCA_FLAG(use_heap_large);
|
ALLOCA_FLAG(use_heap_large);
|
||||||
|
wchar_t *pathw = php_win32_ioutil_any_to_w(path);
|
||||||
|
|
||||||
if (!GetFileAttributesEx(path, GetFileExInfoStandard, &data)) {
|
if (!pathw) {
|
||||||
return zend_stat(path, buf);
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!GetFileAttributesExW(pathw, GetFileExInfoStandard, &data)) {
|
||||||
|
int ret;
|
||||||
|
#if ZEND_ENABLE_ZVAL_LONG64
|
||||||
|
ret = _wstat64(pathw, buf);
|
||||||
|
#else
|
||||||
|
ret = _wstat(pathw, buf);
|
||||||
|
#endif
|
||||||
|
free(pathw);
|
||||||
|
|
||||||
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (path_len >= 1 && path[1] == ':') {
|
if (path_len >= 1 && path[1] == ':') {
|
||||||
|
@ -309,18 +327,18 @@ CWD_API int php_sys_stat_ex(const char *path, zend_stat_t *buf, int lstat) /* {{
|
||||||
} else if (IS_UNC_PATH(path, path_len)) {
|
} else if (IS_UNC_PATH(path, path_len)) {
|
||||||
buf->st_dev = buf->st_rdev = 0;
|
buf->st_dev = buf->st_rdev = 0;
|
||||||
} else {
|
} else {
|
||||||
char cur_path[MAXPATHLEN+1];
|
wchar_t cur_path[MAXPATHLEN+1];
|
||||||
DWORD len = sizeof(cur_path);
|
DWORD len = sizeof(cur_path);
|
||||||
char *tmp = cur_path;
|
wchar_t *tmp = cur_path;
|
||||||
|
|
||||||
while(1) {
|
while(1) {
|
||||||
DWORD r = GetCurrentDirectory(len, tmp);
|
DWORD r = GetCurrentDirectoryW(len, tmp);
|
||||||
if (r < len) {
|
if (r < len) {
|
||||||
if (tmp[1] == ':') {
|
if (tmp[1] == L':') {
|
||||||
if (path[0] >= 'A' && path[0] <= 'Z') {
|
if (pathw[0] >= L'A' && pathw[0] <= L'Z') {
|
||||||
buf->st_dev = buf->st_rdev = path[0] - 'A';
|
buf->st_dev = buf->st_rdev = pathw[0] - L'A';
|
||||||
} else {
|
} else {
|
||||||
buf->st_dev = buf->st_rdev = path[0] - 'a';
|
buf->st_dev = buf->st_rdev = pathw[0] - L'a';
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
buf->st_dev = buf->st_rdev = -1;
|
buf->st_dev = buf->st_rdev = -1;
|
||||||
|
@ -331,7 +349,7 @@ CWD_API int php_sys_stat_ex(const char *path, zend_stat_t *buf, int lstat) /* {{
|
||||||
break;
|
break;
|
||||||
} else {
|
} else {
|
||||||
len = r+1;
|
len = r+1;
|
||||||
tmp = (char*)malloc(len);
|
tmp = (wchar_t*)malloc(len*sizeof(wchar_t));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (tmp != cur_path) {
|
if (tmp != cur_path) {
|
||||||
|
@ -347,8 +365,9 @@ CWD_API int php_sys_stat_ex(const char *path, zend_stat_t *buf, int lstat) /* {{
|
||||||
REPARSE_DATA_BUFFER * pbuffer;
|
REPARSE_DATA_BUFFER * pbuffer;
|
||||||
DWORD retlength = 0;
|
DWORD retlength = 0;
|
||||||
|
|
||||||
hLink = CreateFile(path, GENERIC_READ, 0, NULL, OPEN_EXISTING, FILE_FLAG_OPEN_REPARSE_POINT|FILE_FLAG_BACKUP_SEMANTICS, NULL);
|
hLink = CreateFileW(pathw, GENERIC_READ, 0, NULL, OPEN_EXISTING, FILE_FLAG_OPEN_REPARSE_POINT|FILE_FLAG_BACKUP_SEMANTICS, NULL);
|
||||||
if(hLink == INVALID_HANDLE_VALUE) {
|
if(hLink == INVALID_HANDLE_VALUE) {
|
||||||
|
free(pathw);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -356,6 +375,7 @@ CWD_API int php_sys_stat_ex(const char *path, zend_stat_t *buf, int lstat) /* {{
|
||||||
if(!DeviceIoControl(hLink, FSCTL_GET_REPARSE_POINT, NULL, 0, pbuffer, MAXIMUM_REPARSE_DATA_BUFFER_SIZE, &retlength, NULL)) {
|
if(!DeviceIoControl(hLink, FSCTL_GET_REPARSE_POINT, NULL, 0, pbuffer, MAXIMUM_REPARSE_DATA_BUFFER_SIZE, &retlength, NULL)) {
|
||||||
free_alloca(pbuffer, use_heap_large);
|
free_alloca(pbuffer, use_heap_large);
|
||||||
CloseHandle(hLink);
|
CloseHandle(hLink);
|
||||||
|
free(pathw);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -399,6 +419,9 @@ CWD_API int php_sys_stat_ex(const char *path, zend_stat_t *buf, int lstat) /* {{
|
||||||
buf->st_atime = FileTimeToUnixTime(&data.ftLastAccessTime);
|
buf->st_atime = FileTimeToUnixTime(&data.ftLastAccessTime);
|
||||||
buf->st_ctime = FileTimeToUnixTime(&data.ftCreationTime);
|
buf->st_ctime = FileTimeToUnixTime(&data.ftCreationTime);
|
||||||
buf->st_mtime = FileTimeToUnixTime(&data.ftLastWriteTime);
|
buf->st_mtime = FileTimeToUnixTime(&data.ftLastWriteTime);
|
||||||
|
|
||||||
|
free(pathw);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
/* }}} */
|
/* }}} */
|
||||||
|
@ -778,9 +801,13 @@ static int tsrm_realpath_r(char *path, int start, int len, int *ll, time_t *t, i
|
||||||
int i, j, save;
|
int i, j, save;
|
||||||
int directory = 0;
|
int directory = 0;
|
||||||
#ifdef ZEND_WIN32
|
#ifdef ZEND_WIN32
|
||||||
WIN32_FIND_DATA data;
|
WIN32_FIND_DATAW dataw;
|
||||||
HANDLE hFind;
|
HANDLE hFind = INVALID_HANDLE_VALUE;
|
||||||
ALLOCA_FLAG(use_heap_large)
|
ALLOCA_FLAG(use_heap_large)
|
||||||
|
wchar_t *pathw = NULL;
|
||||||
|
#define FREE_PATHW() \
|
||||||
|
do { free(pathw); } while(0);
|
||||||
|
|
||||||
#else
|
#else
|
||||||
zend_stat_t st;
|
zend_stat_t st;
|
||||||
#endif
|
#endif
|
||||||
|
@ -873,25 +900,32 @@ static int tsrm_realpath_r(char *path, int start, int len, int *ll, time_t *t, i
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef ZEND_WIN32
|
#ifdef ZEND_WIN32
|
||||||
if (save && (hFind = FindFirstFile(path, &data)) == INVALID_HANDLE_VALUE) {
|
if (save) {
|
||||||
|
pathw = php_win32_ioutil_any_to_w(path);
|
||||||
|
if (!pathw) {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
hFind = FindFirstFileW(pathw, &dataw);
|
||||||
|
if (INVALID_HANDLE_VALUE == hFind) {
|
||||||
if (use_realpath == CWD_REALPATH) {
|
if (use_realpath == CWD_REALPATH) {
|
||||||
/* file not found */
|
/* file not found */
|
||||||
|
FREE_PATHW()
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
/* continue resolution anyway but don't save result in the cache */
|
/* continue resolution anyway but don't save result in the cache */
|
||||||
save = 0;
|
save = 0;
|
||||||
}
|
} else {
|
||||||
|
|
||||||
if (save) {
|
|
||||||
FindClose(hFind);
|
FindClose(hFind);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
tmp = do_alloca(len+1, use_heap);
|
tmp = do_alloca(len+1, use_heap);
|
||||||
memcpy(tmp, path, len+1);
|
memcpy(tmp, path, len+1);
|
||||||
|
|
||||||
if(save &&
|
if(save &&
|
||||||
!(IS_UNC_PATH(path, len) && len >= 3 && path[2] != '?') &&
|
!(IS_UNC_PATH(path, len) && len >= 3 && path[2] != '?') &&
|
||||||
(data.dwFileAttributes & FILE_ATTRIBUTE_REPARSE_POINT)) {
|
(dataw.dwFileAttributes & FILE_ATTRIBUTE_REPARSE_POINT)
|
||||||
|
) {
|
||||||
/* File is a reparse point. Get the target */
|
/* File is a reparse point. Get the target */
|
||||||
HANDLE hLink = NULL;
|
HANDLE hLink = NULL;
|
||||||
REPARSE_DATA_BUFFER * pbuffer;
|
REPARSE_DATA_BUFFER * pbuffer;
|
||||||
|
@ -899,28 +933,35 @@ static int tsrm_realpath_r(char *path, int start, int len, int *ll, time_t *t, i
|
||||||
int bufindex = 0, isabsolute = 0;
|
int bufindex = 0, isabsolute = 0;
|
||||||
wchar_t * reparsetarget;
|
wchar_t * reparsetarget;
|
||||||
BOOL isVolume = FALSE;
|
BOOL isVolume = FALSE;
|
||||||
char printname[MAX_PATH];
|
char *printname = NULL, *substitutename = NULL;
|
||||||
char substitutename[MAX_PATH];
|
|
||||||
int printname_len, substitutename_len;
|
int printname_len, substitutename_len;
|
||||||
int substitutename_off = 0;
|
int substitutename_off = 0;
|
||||||
|
|
||||||
if(++(*ll) > LINK_MAX) {
|
if(++(*ll) > LINK_MAX) {
|
||||||
|
free_alloca(tmp, use_heap);
|
||||||
|
FREE_PATHW()
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
hLink = CreateFile(path, GENERIC_READ, 0, NULL, OPEN_EXISTING, FILE_FLAG_OPEN_REPARSE_POINT|FILE_FLAG_BACKUP_SEMANTICS, NULL);
|
hLink = CreateFileW(pathw, GENERIC_READ, 0, NULL, OPEN_EXISTING, FILE_FLAG_OPEN_REPARSE_POINT|FILE_FLAG_BACKUP_SEMANTICS, NULL);
|
||||||
if(hLink == INVALID_HANDLE_VALUE) {
|
if(hLink == INVALID_HANDLE_VALUE) {
|
||||||
|
free_alloca(tmp, use_heap);
|
||||||
|
FREE_PATHW()
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
pbuffer = (REPARSE_DATA_BUFFER *)do_alloca(MAXIMUM_REPARSE_DATA_BUFFER_SIZE, use_heap_large);
|
pbuffer = (REPARSE_DATA_BUFFER *)do_alloca(MAXIMUM_REPARSE_DATA_BUFFER_SIZE, use_heap_large);
|
||||||
if (pbuffer == NULL) {
|
if (pbuffer == NULL) {
|
||||||
CloseHandle(hLink);
|
CloseHandle(hLink);
|
||||||
|
free_alloca(tmp, use_heap);
|
||||||
|
FREE_PATHW()
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
if(!DeviceIoControl(hLink, FSCTL_GET_REPARSE_POINT, NULL, 0, pbuffer, MAXIMUM_REPARSE_DATA_BUFFER_SIZE, &retlength, NULL)) {
|
if(!DeviceIoControl(hLink, FSCTL_GET_REPARSE_POINT, NULL, 0, pbuffer, MAXIMUM_REPARSE_DATA_BUFFER_SIZE, &retlength, NULL)) {
|
||||||
free_alloca(pbuffer, use_heap_large);
|
free_alloca(pbuffer, use_heap_large);
|
||||||
|
free_alloca(tmp, use_heap);
|
||||||
CloseHandle(hLink);
|
CloseHandle(hLink);
|
||||||
|
FREE_PATHW()
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -930,60 +971,63 @@ static int tsrm_realpath_r(char *path, int start, int len, int *ll, time_t *t, i
|
||||||
reparsetarget = pbuffer->SymbolicLinkReparseBuffer.ReparseTarget;
|
reparsetarget = pbuffer->SymbolicLinkReparseBuffer.ReparseTarget;
|
||||||
printname_len = pbuffer->MountPointReparseBuffer.PrintNameLength / sizeof(WCHAR);
|
printname_len = pbuffer->MountPointReparseBuffer.PrintNameLength / sizeof(WCHAR);
|
||||||
isabsolute = (pbuffer->SymbolicLinkReparseBuffer.Flags == 0) ? 1 : 0;
|
isabsolute = (pbuffer->SymbolicLinkReparseBuffer.Flags == 0) ? 1 : 0;
|
||||||
if (!WideCharToMultiByte(CP_THREAD_ACP, 0,
|
printname = php_win32_ioutil_w_to_any(reparsetarget + pbuffer->MountPointReparseBuffer.PrintNameOffset / sizeof(WCHAR));
|
||||||
reparsetarget + pbuffer->MountPointReparseBuffer.PrintNameOffset / sizeof(WCHAR),
|
if (!printname) {
|
||||||
printname_len + 1,
|
|
||||||
printname, MAX_PATH, NULL, NULL
|
|
||||||
)) {
|
|
||||||
free_alloca(pbuffer, use_heap_large);
|
free_alloca(pbuffer, use_heap_large);
|
||||||
|
free_alloca(tmp, use_heap);
|
||||||
|
FREE_PATHW()
|
||||||
return -1;
|
return -1;
|
||||||
};
|
}
|
||||||
printname_len = pbuffer->MountPointReparseBuffer.PrintNameLength / sizeof(WCHAR);
|
|
||||||
printname[printname_len] = 0;
|
|
||||||
|
|
||||||
substitutename_len = pbuffer->MountPointReparseBuffer.SubstituteNameLength / sizeof(WCHAR);
|
substitutename_len = pbuffer->MountPointReparseBuffer.SubstituteNameLength / sizeof(WCHAR);
|
||||||
if (!WideCharToMultiByte(CP_THREAD_ACP, 0,
|
substitutename = php_win32_ioutil_w_to_any(reparsetarget + pbuffer->MountPointReparseBuffer.SubstituteNameOffset / sizeof(WCHAR));
|
||||||
reparsetarget + pbuffer->MountPointReparseBuffer.SubstituteNameOffset / sizeof(WCHAR),
|
if (!substitutename) {
|
||||||
substitutename_len + 1,
|
|
||||||
substitutename, MAX_PATH, NULL, NULL
|
|
||||||
)) {
|
|
||||||
free_alloca(pbuffer, use_heap_large);
|
free_alloca(pbuffer, use_heap_large);
|
||||||
|
free_alloca(tmp, use_heap);
|
||||||
|
free(printname);
|
||||||
|
FREE_PATHW()
|
||||||
return -1;
|
return -1;
|
||||||
};
|
}
|
||||||
substitutename[substitutename_len] = 0;
|
|
||||||
}
|
}
|
||||||
else if(pbuffer->ReparseTag == IO_REPARSE_TAG_MOUNT_POINT) {
|
else if(pbuffer->ReparseTag == IO_REPARSE_TAG_MOUNT_POINT) {
|
||||||
isabsolute = 1;
|
isabsolute = 1;
|
||||||
reparsetarget = pbuffer->MountPointReparseBuffer.ReparseTarget;
|
reparsetarget = pbuffer->MountPointReparseBuffer.ReparseTarget;
|
||||||
printname_len = pbuffer->MountPointReparseBuffer.PrintNameLength / sizeof(WCHAR);
|
printname_len = pbuffer->MountPointReparseBuffer.PrintNameLength / sizeof(WCHAR);
|
||||||
if (!WideCharToMultiByte(CP_THREAD_ACP, 0,
|
printname = php_win32_ioutil_w_to_any(reparsetarget + pbuffer->MountPointReparseBuffer.PrintNameOffset / sizeof(WCHAR));
|
||||||
reparsetarget + pbuffer->MountPointReparseBuffer.PrintNameOffset / sizeof(WCHAR),
|
if (!printname) {
|
||||||
printname_len + 1,
|
|
||||||
printname, MAX_PATH, NULL, NULL
|
|
||||||
)) {
|
|
||||||
free_alloca(pbuffer, use_heap_large);
|
free_alloca(pbuffer, use_heap_large);
|
||||||
|
free_alloca(tmp, use_heap);
|
||||||
|
FREE_PATHW()
|
||||||
return -1;
|
return -1;
|
||||||
};
|
}
|
||||||
printname[pbuffer->MountPointReparseBuffer.PrintNameLength / sizeof(WCHAR)] = 0;
|
|
||||||
|
|
||||||
substitutename_len = pbuffer->MountPointReparseBuffer.SubstituteNameLength / sizeof(WCHAR);
|
substitutename_len = pbuffer->MountPointReparseBuffer.SubstituteNameLength / sizeof(WCHAR);
|
||||||
if (!WideCharToMultiByte(CP_THREAD_ACP, 0,
|
substitutename = php_win32_ioutil_w_to_any(reparsetarget + pbuffer->MountPointReparseBuffer.SubstituteNameOffset / sizeof(WCHAR));
|
||||||
reparsetarget + pbuffer->MountPointReparseBuffer.SubstituteNameOffset / sizeof(WCHAR),
|
if (!substitutename) {
|
||||||
substitutename_len + 1,
|
|
||||||
substitutename, MAX_PATH, NULL, NULL
|
|
||||||
)) {
|
|
||||||
free_alloca(pbuffer, use_heap_large);
|
free_alloca(pbuffer, use_heap_large);
|
||||||
|
free_alloca(tmp, use_heap);
|
||||||
|
free(printname);
|
||||||
|
FREE_PATHW()
|
||||||
return -1;
|
return -1;
|
||||||
};
|
}
|
||||||
substitutename[substitutename_len] = 0;
|
|
||||||
}
|
}
|
||||||
else if (pbuffer->ReparseTag == IO_REPARSE_TAG_DEDUP) {
|
else if (pbuffer->ReparseTag == IO_REPARSE_TAG_DEDUP) {
|
||||||
isabsolute = 1;
|
isabsolute = 1;
|
||||||
|
substitutename = malloc((len + 1) * sizeof(char));
|
||||||
|
if (!substitutename) {
|
||||||
|
free_alloca(pbuffer, use_heap_large);
|
||||||
|
free_alloca(tmp, use_heap);
|
||||||
|
FREE_PATHW()
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
memcpy(substitutename, path, len + 1);
|
memcpy(substitutename, path, len + 1);
|
||||||
substitutename_len = len;
|
substitutename_len = len;
|
||||||
} else {
|
} else {
|
||||||
/* XXX this might be not the end, restart handling with REPARSE_GUID_DATA_BUFFER should be implemented. */
|
/* XXX this might be not the end, restart handling with REPARSE_GUID_DATA_BUFFER should be implemented. */
|
||||||
free_alloca(pbuffer, use_heap_large);
|
free_alloca(pbuffer, use_heap_large);
|
||||||
|
free_alloca(tmp, use_heap);
|
||||||
|
FREE_PATHW()
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1028,6 +1072,8 @@ static int tsrm_realpath_r(char *path, int start, int len, int *ll, time_t *t, i
|
||||||
fprintf(stderr, "resolved: %s ", path);
|
fprintf(stderr, "resolved: %s ", path);
|
||||||
#endif
|
#endif
|
||||||
free_alloca(pbuffer, use_heap_large);
|
free_alloca(pbuffer, use_heap_large);
|
||||||
|
free(printname);
|
||||||
|
free(substitutename);
|
||||||
|
|
||||||
if(isabsolute == 1) {
|
if(isabsolute == 1) {
|
||||||
if (!((j == 3) && (path[1] == ':') && (path[2] == '\\'))) {
|
if (!((j == 3) && (path[1] == ':') && (path[2] == '\\'))) {
|
||||||
|
@ -1035,6 +1081,7 @@ static int tsrm_realpath_r(char *path, int start, int len, int *ll, time_t *t, i
|
||||||
j = tsrm_realpath_r(path, 0, j, ll, t, 0, is_dir, &directory);
|
j = tsrm_realpath_r(path, 0, j, ll, t, 0, is_dir, &directory);
|
||||||
if(j < 0) {
|
if(j < 0) {
|
||||||
free_alloca(tmp, use_heap);
|
free_alloca(tmp, use_heap);
|
||||||
|
FREE_PATHW()
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1042,6 +1089,7 @@ static int tsrm_realpath_r(char *path, int start, int len, int *ll, time_t *t, i
|
||||||
else {
|
else {
|
||||||
if(i + j >= MAXPATHLEN - 1) {
|
if(i + j >= MAXPATHLEN - 1) {
|
||||||
free_alloca(tmp, use_heap);
|
free_alloca(tmp, use_heap);
|
||||||
|
FREE_PATHW()
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1051,10 +1099,11 @@ static int tsrm_realpath_r(char *path, int start, int len, int *ll, time_t *t, i
|
||||||
j = tsrm_realpath_r(path, start, i + j, ll, t, use_realpath, is_dir, &directory);
|
j = tsrm_realpath_r(path, start, i + j, ll, t, use_realpath, is_dir, &directory);
|
||||||
if(j < 0) {
|
if(j < 0) {
|
||||||
free_alloca(tmp, use_heap);
|
free_alloca(tmp, use_heap);
|
||||||
|
FREE_PATHW()
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
directory = (data.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY);
|
directory = (dataw.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY);
|
||||||
|
|
||||||
if(link_is_dir) {
|
if(link_is_dir) {
|
||||||
*link_is_dir = directory;
|
*link_is_dir = directory;
|
||||||
|
@ -1062,9 +1111,11 @@ static int tsrm_realpath_r(char *path, int start, int len, int *ll, time_t *t, i
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if (save) {
|
if (save) {
|
||||||
directory = (data.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) != 0;
|
directory = (dataw.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) != 0;
|
||||||
if (is_dir && !directory) {
|
if (is_dir && !directory) {
|
||||||
/* not a directory */
|
/* not a directory */
|
||||||
|
free_alloca(tmp, use_heap);
|
||||||
|
FREE_PATHW()
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1141,11 +1192,20 @@ static int tsrm_realpath_r(char *path, int start, int len, int *ll, time_t *t, i
|
||||||
#ifdef ZEND_WIN32
|
#ifdef ZEND_WIN32
|
||||||
if (j < 0 || j + len - i >= MAXPATHLEN-1) {
|
if (j < 0 || j + len - i >= MAXPATHLEN-1) {
|
||||||
free_alloca(tmp, use_heap);
|
free_alloca(tmp, use_heap);
|
||||||
|
FREE_PATHW()
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
if (save) {
|
if (save) {
|
||||||
i = (int)strlen(data.cFileName);
|
size_t sz;
|
||||||
memcpy(path+j, data.cFileName, i+1);
|
char *tmp_path = php_win32_ioutil_conv_w_to_any(dataw.cFileName, PHP_WIN32_CP_IGNORE_LEN, &sz);
|
||||||
|
if (!tmp_path) {
|
||||||
|
free_alloca(tmp, use_heap);
|
||||||
|
FREE_PATHW()
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
i = (int)sz;
|
||||||
|
memcpy(path+j, tmp_path, i+1);
|
||||||
|
free(tmp_path);
|
||||||
j += i;
|
j += i;
|
||||||
} else {
|
} else {
|
||||||
/* use the original file or directory name as it wasn't found */
|
/* use the original file or directory name as it wasn't found */
|
||||||
|
@ -1169,6 +1229,10 @@ static int tsrm_realpath_r(char *path, int start, int len, int *ll, time_t *t, i
|
||||||
}
|
}
|
||||||
|
|
||||||
free_alloca(tmp, use_heap);
|
free_alloca(tmp, use_heap);
|
||||||
|
#ifdef ZEND_WIN32
|
||||||
|
FREE_PATHW()
|
||||||
|
#undef FREE_PATHW
|
||||||
|
#endif
|
||||||
return j;
|
return j;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1502,7 +1566,11 @@ CWD_API FILE *virtual_fopen(const char *path, const char *mode) /* {{{ */
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef ZEND_WIN32
|
||||||
|
f = php_win32_ioutil_fopen(new_state.cwd, mode);
|
||||||
|
#else
|
||||||
f = fopen(new_state.cwd, mode);
|
f = fopen(new_state.cwd, mode);
|
||||||
|
#endif
|
||||||
|
|
||||||
CWD_STATE_FREE_ERR(&new_state);
|
CWD_STATE_FREE_ERR(&new_state);
|
||||||
|
|
||||||
|
@ -1580,9 +1648,11 @@ CWD_API int virtual_chmod(const char *filename, mode_t mode) /* {{{ */
|
||||||
if (_tmp & _S_IWRITE) {
|
if (_tmp & _S_IWRITE) {
|
||||||
mode |= _S_IWRITE;
|
mode |= _S_IWRITE;
|
||||||
}
|
}
|
||||||
|
ret = php_win32_ioutil_chmod(new_state.cwd, mode);
|
||||||
}
|
}
|
||||||
#endif
|
#else
|
||||||
ret = chmod(new_state.cwd, mode);
|
ret = chmod(new_state.cwd, mode);
|
||||||
|
#endif
|
||||||
|
|
||||||
CWD_STATE_FREE_ERR(&new_state);
|
CWD_STATE_FREE_ERR(&new_state);
|
||||||
return ret;
|
return ret;
|
||||||
|
@ -1636,9 +1706,17 @@ CWD_API int virtual_open(const char *path, int flags, ...) /* {{{ */
|
||||||
mode = (mode_t) va_arg(arg, int);
|
mode = (mode_t) va_arg(arg, int);
|
||||||
va_end(arg);
|
va_end(arg);
|
||||||
|
|
||||||
|
#ifdef ZEND_WIN32
|
||||||
|
f = php_win32_ioutil_open(new_state.cwd, flags, mode);
|
||||||
|
#else
|
||||||
f = open(new_state.cwd, flags, mode);
|
f = open(new_state.cwd, flags, mode);
|
||||||
|
#endif
|
||||||
} else {
|
} else {
|
||||||
|
#ifdef ZEND_WIN32
|
||||||
|
f = php_win32_ioutil_open(new_state.cwd, flags);
|
||||||
|
#else
|
||||||
f = open(new_state.cwd, flags);
|
f = open(new_state.cwd, flags);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
CWD_STATE_FREE_ERR(&new_state);
|
CWD_STATE_FREE_ERR(&new_state);
|
||||||
return f;
|
return f;
|
||||||
|
@ -1688,7 +1766,7 @@ CWD_API int virtual_rename(const char *oldname, const char *newname) /* {{{ */
|
||||||
MoveFileEx has to be used */
|
MoveFileEx has to be used */
|
||||||
#ifdef ZEND_WIN32
|
#ifdef ZEND_WIN32
|
||||||
/* MoveFileEx returns 0 on failure, other way 'round for this function */
|
/* MoveFileEx returns 0 on failure, other way 'round for this function */
|
||||||
retval = (MoveFileEx(oldname, newname, MOVEFILE_REPLACE_EXISTING|MOVEFILE_COPY_ALLOWED) == 0) ? -1 : 0;
|
retval = php_win32_ioutil_rename(oldname, newname);
|
||||||
#else
|
#else
|
||||||
retval = rename(oldname, newname);
|
retval = rename(oldname, newname);
|
||||||
#endif
|
#endif
|
||||||
|
@ -1747,7 +1825,11 @@ CWD_API int virtual_unlink(const char *path) /* {{{ */
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef ZEND_WIN32
|
||||||
|
retval = php_win32_ioutil_unlink(new_state.cwd);
|
||||||
|
#else
|
||||||
retval = unlink(new_state.cwd);
|
retval = unlink(new_state.cwd);
|
||||||
|
#endif
|
||||||
|
|
||||||
CWD_STATE_FREE_ERR(&new_state);
|
CWD_STATE_FREE_ERR(&new_state);
|
||||||
return retval;
|
return retval;
|
||||||
|
@ -1766,7 +1848,7 @@ CWD_API int virtual_mkdir(const char *pathname, mode_t mode) /* {{{ */
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef ZEND_WIN32
|
#ifdef ZEND_WIN32
|
||||||
retval = mkdir(new_state.cwd);
|
retval = php_win32_ioutil_mkdir(new_state.cwd, mode);
|
||||||
#else
|
#else
|
||||||
retval = mkdir(new_state.cwd, mode);
|
retval = mkdir(new_state.cwd, mode);
|
||||||
#endif
|
#endif
|
||||||
|
@ -1786,8 +1868,11 @@ CWD_API int virtual_rmdir(const char *pathname) /* {{{ */
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef ZEND_WIN32
|
||||||
|
retval = php_win32_ioutil_rmdir(new_state.cwd);
|
||||||
|
#else
|
||||||
retval = rmdir(new_state.cwd);
|
retval = rmdir(new_state.cwd);
|
||||||
|
#endif
|
||||||
CWD_STATE_FREE_ERR(&new_state);
|
CWD_STATE_FREE_ERR(&new_state);
|
||||||
return retval;
|
return retval;
|
||||||
}
|
}
|
||||||
|
|
|
@ -55,6 +55,7 @@
|
||||||
#ifdef ZEND_WIN32
|
#ifdef ZEND_WIN32
|
||||||
#include "readdir.h"
|
#include "readdir.h"
|
||||||
#include <sys/utime.h>
|
#include <sys/utime.h>
|
||||||
|
#include "win32/ioutil.h"
|
||||||
/* mode_t isn't defined on Windows */
|
/* mode_t isn't defined on Windows */
|
||||||
typedef unsigned short mode_t;
|
typedef unsigned short mode_t;
|
||||||
|
|
||||||
|
@ -289,33 +290,41 @@ CWD_API realpath_cache_bucket** realpath_cache_get_buckets(void);
|
||||||
|
|
||||||
#else
|
#else
|
||||||
|
|
||||||
#define VCWD_GETCWD(buff, size) getcwd(buff, size)
|
|
||||||
#define VCWD_FOPEN(path, mode) fopen(path, mode)
|
|
||||||
#define VCWD_OPEN(path, flags) open(path, flags)
|
|
||||||
#define VCWD_OPEN_MODE(path, flags, mode) open(path, flags, mode)
|
|
||||||
#define VCWD_CREAT(path, mode) creat(path, mode)
|
#define VCWD_CREAT(path, mode) creat(path, mode)
|
||||||
/* rename on windows will fail if newname already exists.
|
/* rename on windows will fail if newname already exists.
|
||||||
MoveFileEx has to be used */
|
MoveFileEx has to be used */
|
||||||
#if defined(ZEND_WIN32)
|
#if defined(ZEND_WIN32)
|
||||||
# define VCWD_RENAME(oldname, newname) (MoveFileEx(oldname, newname, MOVEFILE_REPLACE_EXISTING|MOVEFILE_COPY_ALLOWED) == 0 ? -1 : 0)
|
#define VCWD_FOPEN(path, mode) php_win32_ioutil_fopen(path, mode)
|
||||||
|
#define VCWD_OPEN(path, flags) php_win32_ioutil_open(path, flags)
|
||||||
|
#define VCWD_OPEN_MODE(path, flags, mode) php_win32_ioutil_open(path, flags, mode)
|
||||||
|
# define VCWD_RENAME(oldname, newname) php_win32_ioutil_rename(oldname, newname)
|
||||||
|
#define VCWD_MKDIR(pathname, mode) php_win32_ioutil_mkdir(pathname, mode)
|
||||||
|
#define VCWD_RMDIR(pathname) php_win32_ioutil_rmdir(pathname)
|
||||||
|
#define VCWD_UNLINK(path) php_win32_ioutil_unlink(path)
|
||||||
|
#define VCWD_CHDIR(path) php_win32_ioutil_chdir(path)
|
||||||
|
#define VCWD_ACCESS(pathname, mode) tsrm_win32_access(pathname, mode)
|
||||||
|
#define VCWD_GETCWD(buff, size) php_win32_ioutil_getcwd(buff, size)
|
||||||
|
#define VCWD_CHMOD(path, mode) php_win32_ioutil_chmod(path, mode)
|
||||||
#else
|
#else
|
||||||
|
#define VCWD_FOPEN(path, mode) fopen(path, mode)
|
||||||
|
#define VCWD_OPEN(path, flags) open(path, flags)
|
||||||
|
#define VCWD_OPEN_MODE(path, flags, mode) open(path, flags, mode)
|
||||||
# define VCWD_RENAME(oldname, newname) rename(oldname, newname)
|
# define VCWD_RENAME(oldname, newname) rename(oldname, newname)
|
||||||
#endif
|
#define VCWD_MKDIR(pathname, mode) mkdir(pathname, mode)
|
||||||
|
#define VCWD_RMDIR(pathname) rmdir(pathname)
|
||||||
|
#define VCWD_UNLINK(path) unlink(path)
|
||||||
#define VCWD_CHDIR(path) chdir(path)
|
#define VCWD_CHDIR(path) chdir(path)
|
||||||
|
#define VCWD_ACCESS(pathname, mode) access(pathname, mode)
|
||||||
|
#define VCWD_GETCWD(buff, size) getcwd(buff, size)
|
||||||
|
#define VCWD_CHMOD(path, mode) chmod(path, mode)
|
||||||
|
#endif
|
||||||
|
|
||||||
#define VCWD_CHDIR_FILE(path) virtual_chdir_file(path, chdir)
|
#define VCWD_CHDIR_FILE(path) virtual_chdir_file(path, chdir)
|
||||||
#define VCWD_GETWD(buf) getwd(buf)
|
#define VCWD_GETWD(buf) getwd(buf)
|
||||||
#define VCWD_STAT(path, buff) php_sys_stat(path, buff)
|
#define VCWD_STAT(path, buff) php_sys_stat(path, buff)
|
||||||
#define VCWD_LSTAT(path, buff) lstat(path, buff)
|
#define VCWD_LSTAT(path, buff) lstat(path, buff)
|
||||||
#define VCWD_UNLINK(path) unlink(path)
|
|
||||||
#define VCWD_MKDIR(pathname, mode) mkdir(pathname, mode)
|
|
||||||
#define VCWD_RMDIR(pathname) rmdir(pathname)
|
|
||||||
#define VCWD_OPENDIR(pathname) opendir(pathname)
|
#define VCWD_OPENDIR(pathname) opendir(pathname)
|
||||||
#define VCWD_POPEN(command, type) popen(command, type)
|
#define VCWD_POPEN(command, type) popen(command, type)
|
||||||
#if defined(ZEND_WIN32)
|
|
||||||
#define VCWD_ACCESS(pathname, mode) tsrm_win32_access(pathname, mode)
|
|
||||||
#else
|
|
||||||
#define VCWD_ACCESS(pathname, mode) access(pathname, mode)
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#define VCWD_REALPATH(path, real_path) tsrm_realpath(path, real_path)
|
#define VCWD_REALPATH(path, real_path) tsrm_realpath(path, real_path)
|
||||||
|
|
||||||
|
@ -327,7 +336,6 @@ CWD_API realpath_cache_bucket** realpath_cache_get_buckets(void);
|
||||||
# endif
|
# endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define VCWD_CHMOD(path, mode) chmod(path, mode)
|
|
||||||
#if !defined(ZEND_WIN32) && !defined(NETWARE)
|
#if !defined(ZEND_WIN32) && !defined(NETWARE)
|
||||||
#define VCWD_CHOWN(path, owner, group) chown(path, owner, group)
|
#define VCWD_CHOWN(path, owner, group) chown(path, owner, group)
|
||||||
#if HAVE_LCHOWN
|
#if HAVE_LCHOWN
|
||||||
|
|
40
ext/bz2/tests/003-mb.phpt
Normal file
40
ext/bz2/tests/003-mb.phpt
Normal file
|
@ -0,0 +1,40 @@
|
||||||
|
--TEST--
|
||||||
|
bzread() tests
|
||||||
|
--SKIPIF--
|
||||||
|
<?php if (!extension_loaded("bz2")) print "skip"; ?>
|
||||||
|
--FILE--
|
||||||
|
<?php
|
||||||
|
|
||||||
|
$fd = bzopen(dirname(__FILE__)."/003私はガラスを食べられます.txt.bz2","r");
|
||||||
|
var_dump(bzread());
|
||||||
|
var_dump(bzread($fd, 1 ,0));
|
||||||
|
var_dump(bzread($fd, 0));
|
||||||
|
var_dump(bzread($fd, -10));
|
||||||
|
var_dump(bzread($fd, 1));
|
||||||
|
var_dump(bzread($fd, 2));
|
||||||
|
var_dump(bzread($fd, 100000));
|
||||||
|
|
||||||
|
echo "Done\n";
|
||||||
|
?>
|
||||||
|
--EXPECTF--
|
||||||
|
Warning: bzread() expects at least 1 parameter, 0 given in %s on line %d
|
||||||
|
bool(false)
|
||||||
|
|
||||||
|
Warning: bzread() expects at most 2 parameters, 3 given in %s on line %d
|
||||||
|
bool(false)
|
||||||
|
string(0) ""
|
||||||
|
|
||||||
|
Warning: bzread(): length may not be negative in %s on line %d
|
||||||
|
bool(false)
|
||||||
|
string(1) "R"
|
||||||
|
string(2) "is"
|
||||||
|
string(251) "ing up from the heart of the desert
|
||||||
|
Rising up for Jerusalem
|
||||||
|
Rising up from the heat of the desert
|
||||||
|
Building up Old Jerusalem
|
||||||
|
Rising up from the heart of the desert
|
||||||
|
Rising up for Jerusalem
|
||||||
|
Rising up from the heat of the desert
|
||||||
|
Heading out for Jerusalem
|
||||||
|
"
|
||||||
|
Done
|
BIN
ext/bz2/tests/003私はガラスを食べられます.txt.bz2
Normal file
BIN
ext/bz2/tests/003私はガラスを食べられます.txt.bz2
Normal file
Binary file not shown.
42
ext/exif/tests/bug34704-mb.phpt
Normal file
42
ext/exif/tests/bug34704-mb.phpt
Normal file
|
@ -0,0 +1,42 @@
|
||||||
|
--TEST--
|
||||||
|
Bug #34704 (Infinite recursion due to corrupt JPEG)
|
||||||
|
--SKIPIF--
|
||||||
|
<?php if (!extension_loaded('exif')) print 'skip exif extension not available';?>
|
||||||
|
--INI--
|
||||||
|
output_handler=
|
||||||
|
zlib.output_compression=0
|
||||||
|
--FILE--
|
||||||
|
<?php
|
||||||
|
$infile = dirname(__FILE__).'/bug34704私はガラスを食べられます.jpg';
|
||||||
|
var_dump(exif_read_data($infile));
|
||||||
|
?>
|
||||||
|
===DONE===
|
||||||
|
--EXPECTF--
|
||||||
|
array(7) {
|
||||||
|
["FileName"]=>
|
||||||
|
string(48) "bug34704私はガラスを食べられます.jpg"
|
||||||
|
["FileDateTime"]=>
|
||||||
|
int(%d)
|
||||||
|
["FileSize"]=>
|
||||||
|
int(9976)
|
||||||
|
["FileType"]=>
|
||||||
|
int(2)
|
||||||
|
["MimeType"]=>
|
||||||
|
string(10) "image/jpeg"
|
||||||
|
["SectionsFound"]=>
|
||||||
|
string(4) "IFD0"
|
||||||
|
["COMPUTED"]=>
|
||||||
|
array(5) {
|
||||||
|
["html"]=>
|
||||||
|
string(24) "width="386" height="488""
|
||||||
|
["Height"]=>
|
||||||
|
int(488)
|
||||||
|
["Width"]=>
|
||||||
|
int(386)
|
||||||
|
["IsColor"]=>
|
||||||
|
int(1)
|
||||||
|
["ByteOrderMotorola"]=>
|
||||||
|
int(0)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
===DONE===
|
BIN
ext/exif/tests/bug34704私はガラスを食べられます.jpg
Normal file
BIN
ext/exif/tests/bug34704私はガラスを食べられます.jpg
Normal file
Binary file not shown.
After Width: | Height: | Size: 9.7 KiB |
17
ext/exif/tests/bug68113-mb.phpt
Normal file
17
ext/exif/tests/bug68113-mb.phpt
Normal file
|
@ -0,0 +1,17 @@
|
||||||
|
--TEST--
|
||||||
|
Bug #68113 (Heap corruption in exif_thumbnail())
|
||||||
|
--SKIPIF--
|
||||||
|
<?php
|
||||||
|
extension_loaded("exif") or die("skip need exif");
|
||||||
|
?>
|
||||||
|
--FILE--
|
||||||
|
<?php
|
||||||
|
var_dump(exif_thumbnail(__DIR__."/bug68113私はガラスを食べられます.jpg"));
|
||||||
|
?>
|
||||||
|
Done
|
||||||
|
--EXPECTF--
|
||||||
|
Warning: exif_thumbnail(bug68113私はガラスを食べられます.jpg): File structure corrupted in %s%ebug68113-mb.php on line 2
|
||||||
|
|
||||||
|
Warning: exif_thumbnail(bug68113私はガラスを食べられます.jpg): Invalid JPEG file in %s%ebug68113-mb.php on line 2
|
||||||
|
bool(false)
|
||||||
|
Done
|
BIN
ext/exif/tests/bug68113私はガラスを食べられます.jpg
Normal file
BIN
ext/exif/tests/bug68113私はガラスを食べられます.jpg
Normal file
Binary file not shown.
After Width: | Height: | Size: 368 B |
23
ext/exif/tests/exif_imagetype_basic-mb.phpt
Normal file
23
ext/exif/tests/exif_imagetype_basic-mb.phpt
Normal file
|
@ -0,0 +1,23 @@
|
||||||
|
--TEST--
|
||||||
|
Check for exif_imagetype default behaviour
|
||||||
|
--SKIPIF--
|
||||||
|
<?php if (!extension_loaded('exif')) print 'skip exif extension not available';?>
|
||||||
|
--INI--
|
||||||
|
output_handler=
|
||||||
|
zlib.output_compression=0
|
||||||
|
--FILE--
|
||||||
|
<?php
|
||||||
|
|
||||||
|
/* Prototype : int exif_imagetype ( string $filename )
|
||||||
|
* Description: Determine the type of an image
|
||||||
|
* Source code: ext/exif/exif.c
|
||||||
|
*/
|
||||||
|
echo "*** Testing exif_imagetype() : basic functionality ***\n";
|
||||||
|
|
||||||
|
var_dump(exif_imagetype(dirname(__FILE__).'/test2私はガラスを食べられます.jpg'));
|
||||||
|
?>
|
||||||
|
===Done===
|
||||||
|
--EXPECT--
|
||||||
|
*** Testing exif_imagetype() : basic functionality ***
|
||||||
|
int(2)
|
||||||
|
===Done===
|
62
ext/exif/tests/exif_read_exif_data_basic-mb.phpt
Normal file
62
ext/exif/tests/exif_read_exif_data_basic-mb.phpt
Normal file
|
@ -0,0 +1,62 @@
|
||||||
|
--TEST--
|
||||||
|
Check for read_exif_data default behaviour
|
||||||
|
--SKIPIF--
|
||||||
|
<?php if (!extension_loaded('exif')) print 'skip exif extension not available';?>
|
||||||
|
--INI--
|
||||||
|
output_handler=
|
||||||
|
zlib.output_compression=0
|
||||||
|
--FILE--
|
||||||
|
<?php
|
||||||
|
|
||||||
|
/* Prototype : array read_exif_data ( string $filename [, string $sections [, bool $arrays [, bool $thumbnail ]]] )
|
||||||
|
* Description: Alias of exif_read_data()
|
||||||
|
* Source code: ext/exif/exif.c
|
||||||
|
*/
|
||||||
|
echo "*** Testing read_exif_data() : basic functionality ***\n";
|
||||||
|
|
||||||
|
print_r(read_exif_data(dirname(__FILE__).'/test2私はガラスを食べられます.jpg'));
|
||||||
|
?>
|
||||||
|
===Done===
|
||||||
|
--EXPECTF--
|
||||||
|
*** Testing read_exif_data() : basic functionality ***
|
||||||
|
Array
|
||||||
|
(
|
||||||
|
[FileName] => test2私はガラスを食べられます.jpg
|
||||||
|
[FileDateTime] => %d
|
||||||
|
[FileSize] => 1240
|
||||||
|
[FileType] => 2
|
||||||
|
[MimeType] => image/jpeg
|
||||||
|
[SectionsFound] => ANY_TAG, IFD0, THUMBNAIL, COMMENT
|
||||||
|
[COMPUTED] => Array
|
||||||
|
(
|
||||||
|
[html] => width="1" height="1"
|
||||||
|
[Height] => 1
|
||||||
|
[Width] => 1
|
||||||
|
[IsColor] => 1
|
||||||
|
[ByteOrderMotorola] => 1
|
||||||
|
[UserComment] => Exif test image.
|
||||||
|
[UserCommentEncoding] => ASCII
|
||||||
|
[Copyright] => Photo (c) M.Boerger, Edited by M.Boerger.
|
||||||
|
[Copyright.Photographer] => Photo (c) M.Boerger
|
||||||
|
[Copyright.Editor] => Edited by M.Boerger.
|
||||||
|
[Thumbnail.FileType] => 2
|
||||||
|
[Thumbnail.MimeType] => image/jpeg
|
||||||
|
)
|
||||||
|
|
||||||
|
[Copyright] => Photo (c) M.Boerger
|
||||||
|
[UserComment] => ASCII
|
||||||
|
[THUMBNAIL] => Array
|
||||||
|
(
|
||||||
|
[JPEGInterchangeFormat] => 134
|
||||||
|
[JPEGInterchangeFormatLength] => 523
|
||||||
|
)
|
||||||
|
|
||||||
|
[COMMENT] => Array
|
||||||
|
(
|
||||||
|
[0] => Comment #1.
|
||||||
|
[1] => Comment #2.
|
||||||
|
[2] => Comment #3end
|
||||||
|
)
|
||||||
|
|
||||||
|
)
|
||||||
|
===Done===
|
BIN
ext/exif/tests/test2私はガラスを食べられます.jpg
Normal file
BIN
ext/exif/tests/test2私はガラスを食べられます.jpg
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.2 KiB |
BIN
ext/fileinfo/tests/67647私はガラスを食べられます.mov
Normal file
BIN
ext/fileinfo/tests/67647私はガラスを食べられます.mov
Normal file
Binary file not shown.
73
ext/fileinfo/tests/bug61964-mb.phpt
Normal file
73
ext/fileinfo/tests/bug61964-mb.phpt
Normal file
|
@ -0,0 +1,73 @@
|
||||||
|
--TEST--
|
||||||
|
Bug #61964 (finfo_open with directory cause invalid free)
|
||||||
|
--SKIPIF--
|
||||||
|
<?php require_once(dirname(__FILE__) . '/skipif.inc'); ?>
|
||||||
|
--FILE--
|
||||||
|
<?php
|
||||||
|
|
||||||
|
$magic_file = dirname(__FILE__) . DIRECTORY_SEPARATOR . 'magic私はガラスを食べられます';
|
||||||
|
|
||||||
|
$ret = @finfo_open(FILEINFO_NONE, $magic_file . ".non-exits私はガラスを食べられます");
|
||||||
|
var_dump($ret);
|
||||||
|
|
||||||
|
$dir = __DIR__ . "/test-folder";
|
||||||
|
@mkdir($dir);
|
||||||
|
|
||||||
|
$magic_file_copy = $dir . "/magic私はガラスを食べられます.copy";
|
||||||
|
$magic_file_copy2 = $magic_file_copy . "2";
|
||||||
|
copy($magic_file, $magic_file_copy);
|
||||||
|
copy($magic_file, $magic_file_copy2);
|
||||||
|
|
||||||
|
$ret = finfo_open(FILEINFO_NONE, $dir);
|
||||||
|
var_dump($ret);
|
||||||
|
|
||||||
|
$ret = @finfo_open(FILEINFO_NONE, $dir);
|
||||||
|
var_dump($ret);
|
||||||
|
|
||||||
|
$ret = @finfo_open(FILEINFO_NONE, $dir. "/non-exits-dir私はガラスを食べられます");
|
||||||
|
var_dump($ret);
|
||||||
|
|
||||||
|
// write some test files to test folder
|
||||||
|
file_put_contents($dir . "/test1.txt", "string\n> Core\n> Me");
|
||||||
|
file_put_contents($dir . "/test2.txt", "a\nb\n");
|
||||||
|
@mkdir($dir . "/test-inner-folder私はガラスを食べられます");
|
||||||
|
|
||||||
|
finfo_open(FILEINFO_NONE, $dir);
|
||||||
|
echo "DONE: testing dir with files\n";
|
||||||
|
|
||||||
|
rmdir($dir . "/test-inner-folder私はガラスを食べられます");
|
||||||
|
unlink($dir . "/test1.txt");
|
||||||
|
unlink($dir . "/test2.txt");
|
||||||
|
|
||||||
|
unlink($magic_file_copy);
|
||||||
|
unlink($magic_file_copy2);
|
||||||
|
rmdir($dir);
|
||||||
|
?>
|
||||||
|
===DONE===
|
||||||
|
--EXPECTF--
|
||||||
|
bool(false)
|
||||||
|
resource(%d) of type (file_info)
|
||||||
|
resource(%d) of type (file_info)
|
||||||
|
bool(false)
|
||||||
|
|
||||||
|
Notice: finfo_open(): Warning: offset `string' invalid in %sbug61964-mb.php on line %d
|
||||||
|
|
||||||
|
Notice: finfo_open(): Warning: offset ` Core' invalid in %sbug61964-mb.php on line %d
|
||||||
|
|
||||||
|
Notice: finfo_open(): Warning: type `Core' invalid in %sbug61964-mb.php on line %d
|
||||||
|
|
||||||
|
Notice: finfo_open(): Warning: offset ` Me' invalid in %sbug61964-mb.php on line %d
|
||||||
|
|
||||||
|
Notice: finfo_open(): Warning: type `Me' invalid in %sbug61964-mb.php on line %d
|
||||||
|
|
||||||
|
Notice: finfo_open(): Warning: offset `a' invalid in %sbug61964-mb.php on line %d
|
||||||
|
|
||||||
|
Notice: finfo_open(): Warning: type `a' invalid in %sbug61964-mb.php on line %d
|
||||||
|
|
||||||
|
Notice: finfo_open(): Warning: offset `b' invalid in %sbug61964-mb.php on line %d
|
||||||
|
|
||||||
|
Notice: finfo_open(): Warning: type `b' invalid in %sbug61964-mb.php on line %d
|
||||||
|
|
||||||
|
Warning: finfo_open(): Failed to load magic database at '%stest-folder'. in %sbug61964-mb.php on line %d
|
||||||
|
DONE: testing dir with files
|
||||||
|
===DONE===
|
17
ext/fileinfo/tests/bug67647-mb.phpt
Normal file
17
ext/fileinfo/tests/bug67647-mb.phpt
Normal file
|
@ -0,0 +1,17 @@
|
||||||
|
--TEST--
|
||||||
|
Bug #67647: Bundled libmagic 5.17 does not detect quicktime files correctly
|
||||||
|
--SKIPIF--
|
||||||
|
<?php require_once(dirname(__FILE__) . '/skipif.inc'); ?>
|
||||||
|
--FILE--
|
||||||
|
<?php
|
||||||
|
|
||||||
|
$f = dirname(__FILE__) . DIRECTORY_SEPARATOR . "67647私はガラスを食べられます.mov";
|
||||||
|
|
||||||
|
$fi = new finfo(FILEINFO_MIME_TYPE);
|
||||||
|
var_dump($fi->file($f));
|
||||||
|
?>
|
||||||
|
+++DONE+++
|
||||||
|
--EXPECT--
|
||||||
|
string(15) "video/quicktime"
|
||||||
|
+++DONE+++
|
||||||
|
|
19
ext/fileinfo/tests/bug71527-mb.phpt
Normal file
19
ext/fileinfo/tests/bug71527-mb.phpt
Normal file
|
@ -0,0 +1,19 @@
|
||||||
|
--TEST--
|
||||||
|
Bug #71527 Buffer over-write in finfo_open with malformed magic file
|
||||||
|
--SKIPIF--
|
||||||
|
<?php
|
||||||
|
if (!class_exists('finfo'))
|
||||||
|
die('skip no fileinfo extension');
|
||||||
|
--ENV--
|
||||||
|
USE_ZEND_ALLOC=0
|
||||||
|
--FILE--
|
||||||
|
<?php
|
||||||
|
$finfo = finfo_open(FILEINFO_NONE, dirname(__FILE__) . DIRECTORY_SEPARATOR . "bug71527私はガラスを食べられます.magic");
|
||||||
|
$info = finfo_file($finfo, __FILE__);
|
||||||
|
var_dump($info);
|
||||||
|
?>
|
||||||
|
--EXPECTF--
|
||||||
|
Warning: finfo_open(): Failed to load magic database at '%sbug71527私はガラスを食べられます.magic'. in %sbug71527-mb.php on line %d
|
||||||
|
|
||||||
|
Warning: finfo_file() expects parameter 1 to be resource, boolean given in %sbug71527-mb.php on line %d
|
||||||
|
bool(false)
|
1
ext/fileinfo/tests/bug71527私はガラスを食べられます.magic
Normal file
1
ext/fileinfo/tests/bug71527私はガラスを食べられます.magic
Normal file
|
@ -0,0 +1 @@
|
||||||
|
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
|
39
ext/fileinfo/tests/cve-2014-1943-mb.phpt
Normal file
39
ext/fileinfo/tests/cve-2014-1943-mb.phpt
Normal file
|
@ -0,0 +1,39 @@
|
||||||
|
--TEST--
|
||||||
|
Bug #66731: file: infinite recursion
|
||||||
|
--SKIPIF--
|
||||||
|
<?php
|
||||||
|
if (!class_exists('finfo'))
|
||||||
|
die('skip no fileinfo extension');
|
||||||
|
--FILE--
|
||||||
|
<?php
|
||||||
|
$fd = __DIR__.'/cve-2014-1943私はガラスを食べられます.data';
|
||||||
|
$fm = __DIR__.'/cve-2014-1943私はガラスを食べられます.magic';
|
||||||
|
|
||||||
|
$a = "\105\122\000\000\000\000\000";
|
||||||
|
$b = str_repeat("\001", 250000);
|
||||||
|
$m = "0 byte x\n".
|
||||||
|
">(1.b) indirect x\n";
|
||||||
|
|
||||||
|
file_put_contents($fd, $a);
|
||||||
|
$fi = finfo_open(FILEINFO_NONE);
|
||||||
|
var_dump(finfo_file($fi, $fd));
|
||||||
|
finfo_close($fi);
|
||||||
|
|
||||||
|
file_put_contents($fd, $b);
|
||||||
|
file_put_contents($fm, $m);
|
||||||
|
$fi = finfo_open(FILEINFO_NONE, $fm);
|
||||||
|
var_dump(finfo_file($fi, $fd));
|
||||||
|
finfo_close($fi);
|
||||||
|
?>
|
||||||
|
Done
|
||||||
|
--CLEAN--
|
||||||
|
<?php
|
||||||
|
@unlink(__DIR__.'/cve-2014-1943.data');
|
||||||
|
@unlink(__DIR__.'/cve-2014-1943.magic');
|
||||||
|
?>
|
||||||
|
--EXPECTF--
|
||||||
|
string(%d) "%s"
|
||||||
|
|
||||||
|
Warning: finfo_file(): Failed identify data 0:indirect recursion nesting (%d) exceeded in %s on line %d
|
||||||
|
bool(false)
|
||||||
|
Done
|
1
ext/fileinfo/tests/cve-2014-1943私はガラスを食べられます.data
Normal file
1
ext/fileinfo/tests/cve-2014-1943私はガラスを食べられます.data
Normal file
File diff suppressed because one or more lines are too long
2
ext/fileinfo/tests/cve-2014-1943私はガラスを食べられます.magic
Normal file
2
ext/fileinfo/tests/cve-2014-1943私はガラスを食べられます.magic
Normal file
|
@ -0,0 +1,2 @@
|
||||||
|
0 byte x
|
||||||
|
>(1.b) indirect x
|
35
ext/fileinfo/tests/cve-2014-3538-mb.phpt
Normal file
35
ext/fileinfo/tests/cve-2014-3538-mb.phpt
Normal file
|
@ -0,0 +1,35 @@
|
||||||
|
--TEST--
|
||||||
|
Bug #66731: file: extensive backtraking
|
||||||
|
--SKIPIF--
|
||||||
|
<?php
|
||||||
|
if (!class_exists('finfo'))
|
||||||
|
die('skip no fileinfo extension');
|
||||||
|
--FILE--
|
||||||
|
<?php
|
||||||
|
$fd = __DIR__.'/cve-2014-3538私はガラスを食べられます.data';
|
||||||
|
|
||||||
|
file_put_contents($fd,
|
||||||
|
'try:' .
|
||||||
|
str_repeat("\n", 1000000));
|
||||||
|
|
||||||
|
$fi = finfo_open(FILEINFO_NONE);
|
||||||
|
$t = microtime(true);
|
||||||
|
var_dump(finfo_file($fi, $fd));
|
||||||
|
$t = microtime(true) - $t;
|
||||||
|
finfo_close($fi);
|
||||||
|
if ($t < 1) {
|
||||||
|
echo "Ok\n";
|
||||||
|
} else {
|
||||||
|
printf("Failed, time=%.2f\n", $t);
|
||||||
|
}
|
||||||
|
|
||||||
|
?>
|
||||||
|
Done
|
||||||
|
--CLEAN--
|
||||||
|
<?php
|
||||||
|
@unlink(__DIR__.'/cve-2014-3538.data');
|
||||||
|
?>
|
||||||
|
--EXPECTF--
|
||||||
|
string(%d) "%s"
|
||||||
|
Ok
|
||||||
|
Done
|
1000000
ext/fileinfo/tests/cve-2014-3538私はガラスを食べられます.data
Normal file
1000000
ext/fileinfo/tests/cve-2014-3538私はガラスを食べられます.data
Normal file
File diff suppressed because it is too large
Load diff
55
ext/fileinfo/tests/finfo_buffer_basic-mb.phpt
Normal file
55
ext/fileinfo/tests/finfo_buffer_basic-mb.phpt
Normal file
|
@ -0,0 +1,55 @@
|
||||||
|
--TEST--
|
||||||
|
Test finfo_buffer() function : basic functionality
|
||||||
|
--SKIPIF--
|
||||||
|
<?php require_once(dirname(__FILE__) . '/skipif.inc'); ?>
|
||||||
|
--FILE--
|
||||||
|
<?php
|
||||||
|
/* Prototype : string finfo_buffer(resource finfo, char *string [, int options [, resource context]])
|
||||||
|
* Description: Return infromation about a string buffer.
|
||||||
|
* Source code: ext/fileinfo/fileinfo.c
|
||||||
|
* Alias to functions:
|
||||||
|
*/
|
||||||
|
|
||||||
|
$magicFile = dirname(__FILE__) . DIRECTORY_SEPARATOR . 'magic私はガラスを食べられます';
|
||||||
|
|
||||||
|
$options = array(
|
||||||
|
FILEINFO_NONE,
|
||||||
|
FILEINFO_MIME,
|
||||||
|
);
|
||||||
|
|
||||||
|
$buffers = array(
|
||||||
|
"Regular string here",
|
||||||
|
"\177ELF",
|
||||||
|
"\000\000\0001\000\000\0000\000\000\0000\000\000\0002\000\000\0000\000\000\0000\000\000\0003",
|
||||||
|
"\x55\x7A\x6E\x61",
|
||||||
|
"id=ImageMagick",
|
||||||
|
"RIFFüîò^BAVI LISTv",
|
||||||
|
);
|
||||||
|
|
||||||
|
echo "*** Testing finfo_buffer() : basic functionality ***\n";
|
||||||
|
|
||||||
|
foreach( $options as $option ) {
|
||||||
|
$finfo = finfo_open( $option, $magicFile );
|
||||||
|
foreach( $buffers as $string ) {
|
||||||
|
var_dump( finfo_buffer( $finfo, $string, $option ) );
|
||||||
|
}
|
||||||
|
finfo_close( $finfo );
|
||||||
|
}
|
||||||
|
|
||||||
|
?>
|
||||||
|
===DONE===
|
||||||
|
--EXPECTF--
|
||||||
|
*** Testing finfo_buffer() : basic functionality ***
|
||||||
|
string(36) "ASCII text, with no line terminators"
|
||||||
|
string(3) "ELF"
|
||||||
|
string(22) "old ACE/gr binary file"
|
||||||
|
string(12) "xo65 object,"
|
||||||
|
string(15) "MIFF image data"
|
||||||
|
string(25) "RIFF (little-endian) data"
|
||||||
|
string(28) "text/plain; charset=us-ascii"
|
||||||
|
string(26) "text/plain; charset=ebcdic"
|
||||||
|
string(40) "application/octet-stream; charset=binary"
|
||||||
|
string(28) "text/plain; charset=us-ascii"
|
||||||
|
string(28) "text/plain; charset=us-ascii"
|
||||||
|
string(25) "text/plain; charset=utf-8"
|
||||||
|
===DONE===
|
54
ext/fileinfo/tests/finfo_buffer_variation1-mb.phpt
Normal file
54
ext/fileinfo/tests/finfo_buffer_variation1-mb.phpt
Normal file
|
@ -0,0 +1,54 @@
|
||||||
|
--TEST--
|
||||||
|
Test finfo_buffer() function : basic functionality
|
||||||
|
--SKIPIF--
|
||||||
|
<?php require_once(dirname(__FILE__) . '/skipif.inc'); ?>
|
||||||
|
--FILE--
|
||||||
|
<?php
|
||||||
|
/* Prototype : string finfo_buffer(resource finfo, char *string [, int options [, resource context]])
|
||||||
|
* Description: Return infromation about a string buffer.
|
||||||
|
* Source code: ext/fileinfo/fileinfo.c
|
||||||
|
* Alias to functions:
|
||||||
|
*/
|
||||||
|
|
||||||
|
$magicFile = dirname(__FILE__) . DIRECTORY_SEPARATOR . 'magic私はガラスを食べられます';
|
||||||
|
|
||||||
|
$options = array(
|
||||||
|
FILEINFO_NONE,
|
||||||
|
FILEINFO_MIME,
|
||||||
|
);
|
||||||
|
|
||||||
|
$buffers = array(
|
||||||
|
"Regular string here",
|
||||||
|
"\177ELF",
|
||||||
|
"\000\000\0001\000\000\0000\000\000\0000\000\000\0002\000\000\0000\000\000\0000\000\000\0003",
|
||||||
|
"\x55\x7A\x6E\x61",
|
||||||
|
"id=ImageMagick",
|
||||||
|
"RIFFüîò^BAVI LISTv",
|
||||||
|
);
|
||||||
|
|
||||||
|
echo "*** Testing finfo_buffer() : variation functionality with oo interface ***\n";
|
||||||
|
|
||||||
|
foreach( $options as $option ) {
|
||||||
|
$finfo = new finfo( $option, $magicFile );
|
||||||
|
foreach( $buffers as $string ) {
|
||||||
|
var_dump( $finfo->buffer( $string, $option ) );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
?>
|
||||||
|
===DONE===
|
||||||
|
--EXPECTF--
|
||||||
|
*** Testing finfo_buffer() : variation functionality with oo interface ***
|
||||||
|
string(36) "ASCII text, with no line terminators"
|
||||||
|
string(3) "ELF"
|
||||||
|
string(22) "old ACE/gr binary file"
|
||||||
|
string(12) "xo65 object,"
|
||||||
|
string(15) "MIFF image data"
|
||||||
|
string(25) "RIFF (little-endian) data"
|
||||||
|
string(28) "text/plain; charset=us-ascii"
|
||||||
|
string(26) "text/plain; charset=ebcdic"
|
||||||
|
string(40) "application/octet-stream; charset=binary"
|
||||||
|
string(28) "text/plain; charset=us-ascii"
|
||||||
|
string(28) "text/plain; charset=us-ascii"
|
||||||
|
string(25) "text/plain; charset=utf-8"
|
||||||
|
===DONE===
|
42
ext/fileinfo/tests/finfo_set_flags_basic-mb.phpt
Normal file
42
ext/fileinfo/tests/finfo_set_flags_basic-mb.phpt
Normal file
|
@ -0,0 +1,42 @@
|
||||||
|
--TEST--
|
||||||
|
Test finfo_set_flags() function : basic functionality
|
||||||
|
--SKIPIF--
|
||||||
|
<?php require_once(dirname(__FILE__) . '/skipif.inc'); ?>
|
||||||
|
--FILE--
|
||||||
|
<?php
|
||||||
|
/* Prototype : bool finfo_set_flags(resource finfo, int options)
|
||||||
|
* Description: Set libmagic configuration options.
|
||||||
|
* Source code: ext/fileinfo/fileinfo.c
|
||||||
|
* Alias to functions:
|
||||||
|
*/
|
||||||
|
|
||||||
|
$magicFile = dirname(__FILE__) . DIRECTORY_SEPARATOR . 'magic私はガラスを食べられます';
|
||||||
|
$finfo = finfo_open( FILEINFO_MIME, $magicFile );
|
||||||
|
|
||||||
|
echo "*** Testing finfo_set_flags() : basic functionality ***\n";
|
||||||
|
|
||||||
|
var_dump( finfo_set_flags( $finfo, FILEINFO_NONE ) );
|
||||||
|
var_dump( finfo_set_flags( $finfo, FILEINFO_SYMLINK ) );
|
||||||
|
var_dump( finfo_set_flags() );
|
||||||
|
|
||||||
|
finfo_close( $finfo );
|
||||||
|
|
||||||
|
// OO way
|
||||||
|
$finfo = new finfo( FILEINFO_NONE, $magicFile );
|
||||||
|
var_dump( $finfo->set_flags( FILEINFO_MIME ) );
|
||||||
|
var_dump( $finfo->set_flags() );
|
||||||
|
|
||||||
|
?>
|
||||||
|
===DONE===
|
||||||
|
--EXPECTF--
|
||||||
|
*** Testing finfo_set_flags() : basic functionality ***
|
||||||
|
bool(true)
|
||||||
|
bool(true)
|
||||||
|
|
||||||
|
Warning: finfo_set_flags() expects exactly 2 parameters, 0 given in %s on line %d
|
||||||
|
bool(false)
|
||||||
|
bool(true)
|
||||||
|
|
||||||
|
Warning: finfo::set_flags() expects exactly 1 parameter, 0 given in %s on line %d
|
||||||
|
bool(false)
|
||||||
|
===DONE===
|
21766
ext/fileinfo/tests/magic私はガラスを食べられます
Normal file
21766
ext/fileinfo/tests/magic私はガラスを食べられます
Normal file
File diff suppressed because it is too large
Load diff
25
ext/gd/tests/001-mb.phpt
Normal file
25
ext/gd/tests/001-mb.phpt
Normal file
|
@ -0,0 +1,25 @@
|
||||||
|
--TEST--
|
||||||
|
imagecreatefrompng() and empty/missing file
|
||||||
|
--SKIPIF--
|
||||||
|
<?php if (!function_exists("imagecreatefrompng")) print "skip"; ?>
|
||||||
|
--FILE--
|
||||||
|
<?php
|
||||||
|
|
||||||
|
$file = dirname(__FILE__)."/001私はガラスを食べられます.test";
|
||||||
|
@unlink($file);
|
||||||
|
|
||||||
|
var_dump(imagecreatefrompng($file));
|
||||||
|
touch($file);
|
||||||
|
var_dump(imagecreatefrompng($file));
|
||||||
|
|
||||||
|
@unlink($file);
|
||||||
|
|
||||||
|
echo "Done\n";
|
||||||
|
?>
|
||||||
|
--EXPECTF--
|
||||||
|
Warning: imagecreatefrompng(%s001私はガラスを食べられます.test): failed to open stream: No such file or directory in %s on line %d
|
||||||
|
bool(false)
|
||||||
|
|
||||||
|
Warning: imagecreatefrompng(): '%s001私はガラスを食べられます.test' is not a valid PNG file in %s on line %d
|
||||||
|
bool(false)
|
||||||
|
Done
|
BIN
ext/gd/tests/Tuffy私はガラスを食べられます.ttf
Normal file
BIN
ext/gd/tests/Tuffy私はガラスを食べられます.ttf
Normal file
Binary file not shown.
23
ext/gd/tests/bug22544-mb.phpt
Normal file
23
ext/gd/tests/bug22544-mb.phpt
Normal file
|
@ -0,0 +1,23 @@
|
||||||
|
--TEST--
|
||||||
|
Bug #22544 (TrueColor transparency in PNG images).
|
||||||
|
--SKIPIF--
|
||||||
|
<?php
|
||||||
|
if (!extension_loaded('gd')) {
|
||||||
|
die("skip gd extension not available\n");
|
||||||
|
}
|
||||||
|
?>
|
||||||
|
--FILE--
|
||||||
|
<?php
|
||||||
|
$dest = dirname(realpath(__FILE__)) . '/bug22544私はガラスを食べられます.png';
|
||||||
|
@unlink($dest);
|
||||||
|
$image = imageCreateTruecolor(640, 100);
|
||||||
|
$transparent = imageColorAllocate($image, 0, 0, 0);
|
||||||
|
$red = imageColorAllocate($image, 255, 50, 50);
|
||||||
|
imageColorTransparent($image, $transparent);
|
||||||
|
imageFilledRectangle($image, 0, 0, 640-1, 100-1, $transparent);
|
||||||
|
imagePng($image, $dest);
|
||||||
|
echo md5_file($dest) . "\n";
|
||||||
|
@unlink($dest);
|
||||||
|
?>
|
||||||
|
--EXPECT--
|
||||||
|
10a57d09a2c63fad87b85b38d6b258d6
|
28
ext/gd/tests/bug36697-mb.phpt
Normal file
28
ext/gd/tests/bug36697-mb.phpt
Normal file
|
@ -0,0 +1,28 @@
|
||||||
|
--TEST--
|
||||||
|
Bug #36697 (TrueColor transparency with GIF palette output).
|
||||||
|
--SKIPIF--
|
||||||
|
<?php
|
||||||
|
if (!extension_loaded('gd')) {
|
||||||
|
die("skip gd extension not available\n");
|
||||||
|
}
|
||||||
|
?>
|
||||||
|
--FILE--
|
||||||
|
<?php
|
||||||
|
$dest = dirname(__FILE__) . "/36697私はガラスを食べられます.gif";
|
||||||
|
|
||||||
|
$im = imagecreatetruecolor(192, 36);
|
||||||
|
$trans_color = imagecolorallocate($im, 255, 0, 0);
|
||||||
|
$color = imagecolorallocate($im, 255, 255, 255);
|
||||||
|
imagecolortransparent($im, $trans_color);
|
||||||
|
imagefilledrectangle($im, 0,0, 192,36, $trans_color);
|
||||||
|
$c = imagecolorat($im, 191,35);
|
||||||
|
imagegif($im, $dest);
|
||||||
|
imagedestroy($im);
|
||||||
|
$im = imagecreatefromgif($dest);
|
||||||
|
$c = imagecolorat($im, 191, 35);
|
||||||
|
$colors = imagecolorsforindex($im, $c);
|
||||||
|
echo $colors['red'] . ' ' . $colors['green'] . ' ' . $colors['blue'];
|
||||||
|
@unlink($dest);
|
||||||
|
?>
|
||||||
|
--EXPECT--
|
||||||
|
255 0 0
|
12
ext/gd/tests/bug37346-mb.phpt
Normal file
12
ext/gd/tests/bug37346-mb.phpt
Normal file
|
@ -0,0 +1,12 @@
|
||||||
|
--TEST--
|
||||||
|
Bug #37346 (gdimagecreatefromgif, bad colormap)
|
||||||
|
--SKIPIF--
|
||||||
|
<?php
|
||||||
|
if (!extension_loaded('gd')) die("skip gd extension not available\n");
|
||||||
|
?>
|
||||||
|
--FILE--
|
||||||
|
<?php
|
||||||
|
$im = imagecreatefromgif(dirname(__FILE__) . '/bug37346私はガラスを食べられます.gif');
|
||||||
|
?>
|
||||||
|
--EXPECTF--
|
||||||
|
Warning: imagecreatefromgif(): '%sbug37346私はガラスを食べられます.gif' is not a valid GIF file in %sbug37346-mb.php on line %d
|
4
ext/gd/tests/bug37346私はガラスを食べられます.gif
Normal file
4
ext/gd/tests/bug37346私はガラスを食べられます.gif
Normal file
|
@ -0,0 +1,4 @@
|
||||||
|
GIF89a
|
||||||
|
<
|
||||||
|
|
||||||
|
看吧, 我都说过滤不严了
|
After Width: | Height: | Size: 32 B |
18
ext/gd/tests/bug38212-mb.phpt
Normal file
18
ext/gd/tests/bug38212-mb.phpt
Normal file
|
@ -0,0 +1,18 @@
|
||||||
|
--TEST--
|
||||||
|
Bug #38212 (Seg Fault on invalid imagecreatefromgd2part() parameters)
|
||||||
|
--SKIPIF--
|
||||||
|
<?php
|
||||||
|
if (!function_exists('imagecopy')) die("skip gd extension not available\n");
|
||||||
|
?>
|
||||||
|
--FILE--
|
||||||
|
<?php
|
||||||
|
$file = dirname(__FILE__) . '/bug38212私はガラスを食べられます.gd2';
|
||||||
|
$im1 = imagecreatetruecolor(10,100);
|
||||||
|
imagefill($im1, 0,0, 0xffffff);
|
||||||
|
imagegd2($im1, $file);
|
||||||
|
$im = imagecreatefromgd2part($file, 0,0, -25,10);
|
||||||
|
unlink($file);
|
||||||
|
?>
|
||||||
|
--EXPECTF--
|
||||||
|
|
||||||
|
Warning: imagecreatefromgd2part(): Zero width or height not allowed in %s on line %d
|
13
ext/gd/tests/bug39286-mb.phpt
Normal file
13
ext/gd/tests/bug39286-mb.phpt
Normal file
|
@ -0,0 +1,13 @@
|
||||||
|
--TEST--
|
||||||
|
Bug #39508 (imagefill crashes with small images 3 pixels or less)
|
||||||
|
--SKIPIF--
|
||||||
|
<?php
|
||||||
|
if (!extension_loaded('gd')) die("skip gd extension not available\n");
|
||||||
|
?>
|
||||||
|
--FILE--
|
||||||
|
<?php
|
||||||
|
$img =imagecreatefromgd2part("foo私はガラスを食べられます.png",0, 100, 0, 100);
|
||||||
|
?>
|
||||||
|
--EXPECTF--
|
||||||
|
|
||||||
|
Warning: imagecreatefromgd2part(): Zero width or height not allowed in %s on line %d
|
27
ext/gd/tests/bug48732-mb.phpt
Normal file
27
ext/gd/tests/bug48732-mb.phpt
Normal file
|
@ -0,0 +1,27 @@
|
||||||
|
--TEST--
|
||||||
|
Bug #48732 (TTF Bounding box wrong for letters below baseline)
|
||||||
|
--SKIPIF--
|
||||||
|
<?php
|
||||||
|
if(!extension_loaded('gd')){ die('skip gd extension not available'); }
|
||||||
|
if(!function_exists('imagefttext')) die('skip imagefttext() not available');
|
||||||
|
if (substr(PHP_OS, 0, 3) != 'WIN') {
|
||||||
|
die('skip.. only for Windows');
|
||||||
|
}
|
||||||
|
?>
|
||||||
|
--XFAIL--
|
||||||
|
seems freetype issue, to investigate
|
||||||
|
--FILE--
|
||||||
|
<?php
|
||||||
|
$cwd = dirname(__FILE__);
|
||||||
|
$font = "$cwd/Tuffy私はガラスを食べられます.ttf";
|
||||||
|
$g = imagecreate(100, 50);
|
||||||
|
$bgnd = imagecolorallocate($g, 255, 255, 255);
|
||||||
|
$black = imagecolorallocate($g, 0, 0, 0);
|
||||||
|
$bbox = imagettftext($g, 12, 0, 0, 20, $black, $font, "ABCEDFGHIJKLMN\nopqrstu\n");
|
||||||
|
imagepng($g, "$cwd/bug48732私はガラスを食べられます.png");
|
||||||
|
echo 'Left Bottom: (' . $bbox[0] . ', ' . $bbox[1] . ')';
|
||||||
|
?>
|
||||||
|
--CLEAN--
|
||||||
|
<?php @unlink(dirname(__FILE__) . '/bug48732私はガラスを食べられます.png'); ?>
|
||||||
|
--EXPECTF--
|
||||||
|
Left Bottom: (0, 47)
|
25
ext/gd/tests/bug48801-mb.phpt
Normal file
25
ext/gd/tests/bug48801-mb.phpt
Normal file
|
@ -0,0 +1,25 @@
|
||||||
|
--TEST--
|
||||||
|
Bug #48801 (Problem with imagettfbbox) freetype < 2.4.10
|
||||||
|
--SKIPIF--
|
||||||
|
<?php
|
||||||
|
if(!extension_loaded('gd')){ die('skip gd extension not available'); }
|
||||||
|
if(!function_exists('imageftbbox')) die('skip imageftbbox() not available');
|
||||||
|
|
||||||
|
include dirname(__FILE__) . '/func.inc';
|
||||||
|
if(version_compare(get_freetype_version(), '2.4.10') >= 0) die('skip for freetype < 2.4.10');
|
||||||
|
?>
|
||||||
|
--FILE--
|
||||||
|
<?php
|
||||||
|
$cwd = dirname(__FILE__);
|
||||||
|
$font = "$cwd/Tuffy私はガラスを食べられます.ttf";
|
||||||
|
$bbox = imageftbbox(50, 0, $font, "image");
|
||||||
|
echo '(' . $bbox[0] . ', ' . $bbox[1] . ")\n";
|
||||||
|
echo '(' . $bbox[2] . ', ' . $bbox[3] . ")\n";
|
||||||
|
echo '(' . $bbox[4] . ', ' . $bbox[5] . ")\n";
|
||||||
|
echo '(' . $bbox[6] . ', ' . $bbox[7] . ")\n";
|
||||||
|
?>
|
||||||
|
--EXPECTF--
|
||||||
|
(-1, 15)
|
||||||
|
(15%d, 15)
|
||||||
|
(15%d, -48)
|
||||||
|
(-1, -48)
|
33
ext/gd/tests/bug66339-mb.phpt
Normal file
33
ext/gd/tests/bug66339-mb.phpt
Normal file
|
@ -0,0 +1,33 @@
|
||||||
|
--TEST--
|
||||||
|
Bug #66339 (PHP segfaults in imagexbm)
|
||||||
|
--SKIPIF--
|
||||||
|
<?php
|
||||||
|
if (!extension_loaded('gd')) die('skip gd extension not available');
|
||||||
|
?>
|
||||||
|
--XFAIL--
|
||||||
|
libxpbm works different way linux an dwindows, to investigate
|
||||||
|
--FILE--
|
||||||
|
<?php
|
||||||
|
$im = imagecreate(8, 8);
|
||||||
|
imagecolorallocate($im, 0, 0, 0); // background
|
||||||
|
$white = imagecolorallocate($im, 255, 255, 255);
|
||||||
|
imagefilledrectangle($im, 2, 2, 6, 6, $white);
|
||||||
|
imagexbm($im, NULL);
|
||||||
|
echo "------------\n";
|
||||||
|
imagexbm($im, './bug66339私はガラスを食べられます.xbm');
|
||||||
|
echo file_get_contents('./bug66339私はガラスを食べられます.xbm');
|
||||||
|
?>
|
||||||
|
--CLEAN--
|
||||||
|
<?php
|
||||||
|
unlink('./bug66339私はガラスを食べられます.xbm');
|
||||||
|
?>
|
||||||
|
--EXPECT--
|
||||||
|
#define image_width 8
|
||||||
|
#define image_height 8
|
||||||
|
static unsigned char image_bits[] = {
|
||||||
|
0xFF, 0xFF, 0x83, 0x83, 0x83, 0x83, 0x83, 0xFF};
|
||||||
|
------------
|
||||||
|
#define bug66339_width 8
|
||||||
|
#define bug66339_height 8
|
||||||
|
static unsigned char bug66339_bits[] = {
|
||||||
|
0xFF, 0xFF, 0x83, 0x83, 0x83, 0x83, 0x83, 0xFF};
|
16
ext/gd/tests/bug71912-mb.phpt
Normal file
16
ext/gd/tests/bug71912-mb.phpt
Normal file
|
@ -0,0 +1,16 @@
|
||||||
|
--TEST--
|
||||||
|
Bug #71912 (libgd: signedness vulnerability)
|
||||||
|
--SKIPIF--
|
||||||
|
<?php
|
||||||
|
if(!extension_loaded('gd')){ die('skip gd extension not available'); }
|
||||||
|
if(!function_exists('imagecreatefromgd2')) die('skip imagecreatefromgd2() not available');
|
||||||
|
?>
|
||||||
|
--FILE--
|
||||||
|
<?php
|
||||||
|
imagecreatefromgd2(__DIR__ . DIRECTORY_SEPARATOR . "invalid_neg_size私はガラスを食べられます.gd2");
|
||||||
|
?>
|
||||||
|
OK
|
||||||
|
--EXPECTF--
|
||||||
|
|
||||||
|
Warning: imagecreatefromgd2(): '%s%einvalid_neg_size私はガラスを食べられます.gd2' is not a valid GD2 file in %s%ebug71912-mb.php on line %d
|
||||||
|
OK
|
BIN
ext/gd/tests/conv_test私はガラスを食べられます.jpeg
Normal file
BIN
ext/gd/tests/conv_test私はガラスを食べられます.jpeg
Normal file
Binary file not shown.
After Width: | Height: | Size: 2.3 KiB |
17
ext/gd/tests/createfromwbmp-mb.phpt
Normal file
17
ext/gd/tests/createfromwbmp-mb.phpt
Normal file
|
@ -0,0 +1,17 @@
|
||||||
|
--TEST--
|
||||||
|
imagecreatefromwbmp
|
||||||
|
--SKIPIF--
|
||||||
|
<?php
|
||||||
|
if (!function_exists('imagecreatefromwbmp')) die("skip gd extension not available\n");
|
||||||
|
?>
|
||||||
|
--FILE--
|
||||||
|
<?php
|
||||||
|
$file = dirname(__FILE__) . '/src私はガラスを食べられます.wbmp';
|
||||||
|
|
||||||
|
$im2 = imagecreatefromwbmp($file);
|
||||||
|
echo 'test create from wbmp: ';
|
||||||
|
echo imagecolorat($im2, 3,3) == 0x0 ? 'ok' : 'failed';
|
||||||
|
echo "\n";
|
||||||
|
?>
|
||||||
|
--EXPECT--
|
||||||
|
test create from wbmp: ok
|
30
ext/gd/tests/imagewbmp-mb.phpt
Normal file
30
ext/gd/tests/imagewbmp-mb.phpt
Normal file
|
@ -0,0 +1,30 @@
|
||||||
|
--TEST--
|
||||||
|
imagewbmp
|
||||||
|
--SKIPIF--
|
||||||
|
<?php
|
||||||
|
if (!function_exists('imagecreatefromwbmp')) die("skip gd extension not available\n");
|
||||||
|
?>
|
||||||
|
--FILE--
|
||||||
|
<?php
|
||||||
|
$file = dirname(__FILE__) . '/im私はガラスを食べられます.wbmp';
|
||||||
|
|
||||||
|
$im = imagecreatetruecolor(6,6);
|
||||||
|
imagefill($im, 0,0, 0xffffff);
|
||||||
|
imagesetpixel($im, 3,3, 0x0);
|
||||||
|
imagewbmp($im, $file);
|
||||||
|
|
||||||
|
$im2 = imagecreatefromwbmp($file);
|
||||||
|
echo 'test create wbmp: ';
|
||||||
|
$c = imagecolorsforindex($im2, imagecolorat($im2, 3,3));
|
||||||
|
$failed = false;
|
||||||
|
foreach ($c as $v) {
|
||||||
|
if ($v != 0) {
|
||||||
|
$failed = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
echo !$failed ? 'ok' : 'failed';
|
||||||
|
echo "\n";
|
||||||
|
unlink($file);
|
||||||
|
?>
|
||||||
|
--EXPECT--
|
||||||
|
test create wbmp: ok
|
BIN
ext/gd/tests/invalid_neg_size私はガラスを食べられます.gd2
Normal file
BIN
ext/gd/tests/invalid_neg_size私はガラスを食べられます.gd2
Normal file
Binary file not shown.
31
ext/gd/tests/jpeg2wbmp_error2-mb.phpt
Normal file
31
ext/gd/tests/jpeg2wbmp_error2-mb.phpt
Normal file
|
@ -0,0 +1,31 @@
|
||||||
|
--TEST--
|
||||||
|
Test jpeg2wbmp() function : wrong origin filename param
|
||||||
|
--CREDITS--
|
||||||
|
Levi Fukumori <levi [at] fukumori [dot] com [dot] br>
|
||||||
|
#testfest PHPSP on 2009-06-20
|
||||||
|
--SKIPIF--
|
||||||
|
<?php
|
||||||
|
if(!extension_loaded('gd')) {
|
||||||
|
die('skip gd extension is not loaded');
|
||||||
|
}
|
||||||
|
if(!function_exists('jpeg2wbmp')) {
|
||||||
|
die('skip jpeg2wbmp function is not available');
|
||||||
|
}
|
||||||
|
?>
|
||||||
|
--FILE--
|
||||||
|
<?php
|
||||||
|
$file = dirname(__FILE__) .'/simpletext私はガラスを食べられます.wbmp';
|
||||||
|
jpeg2wbmp('', $file, 20, 120, 8);
|
||||||
|
jpeg2wbmp(null, $file, 20, 120, 8);
|
||||||
|
jpeg2wbmp(false, $file, 20, 120, 8);
|
||||||
|
?>
|
||||||
|
--EXPECTF--
|
||||||
|
Warning: jpeg2wbmp(): Unable to open '' for reading in %s on line %d
|
||||||
|
|
||||||
|
Warning: jpeg2wbmp(): Unable to open '' for reading in %s on line %d
|
||||||
|
|
||||||
|
Warning: jpeg2wbmp(): Unable to open '' for reading in %s on line %d
|
||||||
|
--CLEAN--
|
||||||
|
<?php
|
||||||
|
unlink(dirname(__FILE__) .'/simpletext私はガラスを食べられます.wbmp');
|
||||||
|
?>
|
42
ext/gd/tests/jpg2gd-mb.phpt
Normal file
42
ext/gd/tests/jpg2gd-mb.phpt
Normal file
|
@ -0,0 +1,42 @@
|
||||||
|
--TEST--
|
||||||
|
jpeg <--> gd1/gd2 conversion test
|
||||||
|
--SKIPIF--
|
||||||
|
<?php
|
||||||
|
if (!extension_loaded('gd')) {
|
||||||
|
die("skip gd extension not available.");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!function_exists("imagecreatefromjpeg") || !function_exists("imagejpeg")) {
|
||||||
|
die("skip jpeg support unavailable");
|
||||||
|
}
|
||||||
|
?>
|
||||||
|
--FILE--
|
||||||
|
<?php
|
||||||
|
$cwd = dirname(__FILE__);
|
||||||
|
|
||||||
|
echo "JPEG to GD1 conversion: ";
|
||||||
|
echo imagegd(imagecreatefromjpeg($cwd . "/conv_test私はガラスを食べられます.jpeg"), $cwd . "/test私はガラスを食べられます.gd1") ? 'ok' : 'failed';
|
||||||
|
echo "\n";
|
||||||
|
|
||||||
|
echo "JPEG to GD2 conversion: ";
|
||||||
|
echo imagegd2(imagecreatefromjpeg($cwd . "/conv_test私はガラスを食べられます.jpeg"), $cwd . "/test私はガラスを食べられます.gd2") ? 'ok' : 'failed';
|
||||||
|
echo "\n";
|
||||||
|
|
||||||
|
echo "GD1 to JPEG conversion: ";
|
||||||
|
echo imagejpeg(imagecreatefromgd($cwd . "/test私はガラスを食べられます.gd1"), $cwd . "/test_gd1.jpeg") ? 'ok' : 'failed';
|
||||||
|
echo "\n";
|
||||||
|
|
||||||
|
echo "GD2 to JPEG conversion: ";
|
||||||
|
echo imagejpeg(imagecreatefromgd2($cwd . "/test私はガラスを食べられます.gd2"), $cwd . "/test_gd2.jpeg") ? 'ok' : 'failed';
|
||||||
|
echo "\n";
|
||||||
|
|
||||||
|
@unlink($cwd . "/test私はガラスを食べられます.gd1");
|
||||||
|
@unlink($cwd . "/test私はガラスを食べられます.gd2");
|
||||||
|
@unlink($cwd . "/test_gd1.jpeg");
|
||||||
|
@unlink($cwd . "/test_gd2.jpeg");
|
||||||
|
?>
|
||||||
|
--EXPECT--
|
||||||
|
JPEG to GD1 conversion: ok
|
||||||
|
JPEG to GD2 conversion: ok
|
||||||
|
GD1 to JPEG conversion: ok
|
||||||
|
GD2 to JPEG conversion: ok
|
19
ext/gd/tests/libgd00094-mb.phpt
Normal file
19
ext/gd/tests/libgd00094-mb.phpt
Normal file
|
@ -0,0 +1,19 @@
|
||||||
|
--TEST--
|
||||||
|
libgd #94 (imagecreatefromxbm can crash if gdImageCreate fails)
|
||||||
|
--SKIPIF--
|
||||||
|
<?php
|
||||||
|
if (!extension_loaded('gd')) die("skip gd extension not available\n");
|
||||||
|
if (!GD_BUNDLED) die("skip requires bundled GD library\n");
|
||||||
|
?>
|
||||||
|
--FILE--
|
||||||
|
<?php
|
||||||
|
$im = imagecreatefromxbm(dirname(__FILE__) . '/libgd00094私はガラスを食べられます.xbm');
|
||||||
|
var_dump($im);
|
||||||
|
?>
|
||||||
|
--EXPECTF--
|
||||||
|
Warning: imagecreatefromxbm(): gd warning: product of memory allocation multiplication would exceed INT_MAX, failing operation gracefully
|
||||||
|
in %slibgd00094-mb.php on line %d
|
||||||
|
|
||||||
|
Warning: imagecreatefromxbm(): '%slibgd00094私はガラスを食べられます.xbm' is not a valid XBM file in %slibgd00094-mb.php on line %d
|
||||||
|
bool(false)
|
||||||
|
|
3
ext/gd/tests/libgd00094私はガラスを食べられます.xbm
Normal file
3
ext/gd/tests/libgd00094私はガラスを食べられます.xbm
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
#define width 255
|
||||||
|
#define height 1073741824
|
||||||
|
static unsigned char bla = {
|
42
ext/gd/tests/png2wbmp_error1-mb.phpt
Normal file
42
ext/gd/tests/png2wbmp_error1-mb.phpt
Normal file
|
@ -0,0 +1,42 @@
|
||||||
|
--TEST--
|
||||||
|
Test png2wbmp() function : wrong threshold value param
|
||||||
|
--CREDITS--
|
||||||
|
Levi Fukumori <levi [at] fukumori [dot] com [dot] br>
|
||||||
|
#testfest PHPSP on 2009-06-20
|
||||||
|
--SKIPIF--
|
||||||
|
<?php
|
||||||
|
if(!extension_loaded('gd')) {
|
||||||
|
die('skip gd extension is not loaded');
|
||||||
|
}
|
||||||
|
if(!function_exists('png2wbmp')) {
|
||||||
|
die('skip png2wbmp function is not available');
|
||||||
|
}
|
||||||
|
?>
|
||||||
|
--FILE--
|
||||||
|
<?php
|
||||||
|
// Create a blank image and add some text
|
||||||
|
$im = imagecreatetruecolor(120, 20);
|
||||||
|
$text_color = imagecolorallocate($im, 255, 255, 255);
|
||||||
|
imagestring($im, 1, 5, 5, 'A Simple Text String', $text_color);
|
||||||
|
|
||||||
|
$file = dirname(__FILE__) .'/simpletext私はガラスを食べられます.png';
|
||||||
|
$file2 = dirname(__FILE__) .'/simpletext私はガラスを食べられます.wbmp';
|
||||||
|
|
||||||
|
// Save the image as 'simpletext.png'
|
||||||
|
imagepng($im, $file);
|
||||||
|
|
||||||
|
// Free up memory
|
||||||
|
imagedestroy($im);
|
||||||
|
|
||||||
|
png2wbmp($file, $file2, 20, 120, 9);
|
||||||
|
png2wbmp($file, $file2, 20, 120, -1);
|
||||||
|
?>
|
||||||
|
--EXPECTF--
|
||||||
|
Warning: png2wbmp(): Invalid threshold value '9' in %s on line %d
|
||||||
|
|
||||||
|
Warning: png2wbmp(): Invalid threshold value '-1' in %s on line %d
|
||||||
|
--CLEAN--
|
||||||
|
<?php
|
||||||
|
unlink(dirname(__FILE__) .'/simpletext私はガラスを食べられます.png');
|
||||||
|
unlink(dirname(__FILE__) .'/simpletext私はガラスを食べられます.wbmp');
|
||||||
|
?>
|
BIN
ext/gd/tests/simpletext私はガラスを食べられます.jpg
Normal file
BIN
ext/gd/tests/simpletext私はガラスを食べられます.jpg
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.5 KiB |
BIN
ext/gd/tests/src私はガラスを食べられます.wbmp
Normal file
BIN
ext/gd/tests/src私はガラスを食べられます.wbmp
Normal file
Binary file not shown.
19
ext/libxml/tests/bug69753-mb.phpt
Normal file
19
ext/libxml/tests/bug69753-mb.phpt
Normal file
|
@ -0,0 +1,19 @@
|
||||||
|
--TEST--
|
||||||
|
Bug #69753 - libXMLError::file contains invalid URI
|
||||||
|
--XFAIL--
|
||||||
|
Awaiting upstream fix: https://bugzilla.gnome.org/show_bug.cgi?id=750365
|
||||||
|
--SKIPIF--
|
||||||
|
<?php
|
||||||
|
if (substr(PHP_OS, 0, 3) != 'WIN') die("skip this test is for Windows platforms only");
|
||||||
|
if (!extension_loaded('dom')) die('skip dom extension not available');
|
||||||
|
?>
|
||||||
|
--FILE--
|
||||||
|
<?php
|
||||||
|
libxml_use_internal_errors(true);
|
||||||
|
$doc = new DomDocument();
|
||||||
|
$doc->load(__DIR__ . DIRECTORY_SEPARATOR . 'bug69753私はガラスを食べられます.xml');
|
||||||
|
$error = libxml_get_last_error();
|
||||||
|
var_dump($error->file);
|
||||||
|
?>
|
||||||
|
--EXPECTF--
|
||||||
|
string(%d) "file:///%s/ext/libxml/tests/bug69753.xml"
|
4
ext/libxml/tests/bug69753私はガラスを食べられます.xml
Normal file
4
ext/libxml/tests/bug69753私はガラスを食べられます.xml
Normal file
|
@ -0,0 +1,4 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<root>
|
||||||
|
<sub>
|
||||||
|
</root>
|
|
@ -1594,6 +1594,8 @@ PHP_MSHUTDOWN_FUNCTION(mbstring)
|
||||||
{
|
{
|
||||||
UNREGISTER_INI_ENTRIES();
|
UNREGISTER_INI_ENTRIES();
|
||||||
|
|
||||||
|
zend_multibyte_restore_functions();
|
||||||
|
|
||||||
#if HAVE_MBREGEX
|
#if HAVE_MBREGEX
|
||||||
PHP_MSHUTDOWN(mb_regex) (INIT_FUNC_ARGS_PASSTHRU);
|
PHP_MSHUTDOWN(mb_regex) (INIT_FUNC_ARGS_PASSTHRU);
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -75,7 +75,8 @@
|
||||||
|
|
||||||
#ifdef ZEND_WIN32
|
#ifdef ZEND_WIN32
|
||||||
# ifndef MAXPATHLEN
|
# ifndef MAXPATHLEN
|
||||||
# define MAXPATHLEN _MAX_PATH
|
# include "win32/ioutil.h"
|
||||||
|
# define MAXPATHLEN PHP_WIN32_IOUTIL_MAXPATHLEN
|
||||||
# endif
|
# endif
|
||||||
# include <direct.h>
|
# include <direct.h>
|
||||||
#else
|
#else
|
||||||
|
|
|
@ -77,25 +77,35 @@ static void zend_win_error_message(int type, char *msg, int err)
|
||||||
static char *create_name_with_username(char *name)
|
static char *create_name_with_username(char *name)
|
||||||
{
|
{
|
||||||
static char newname[MAXPATHLEN + UNLEN + 4 + 1 + 32];
|
static char newname[MAXPATHLEN + UNLEN + 4 + 1 + 32];
|
||||||
char uname[UNLEN + 1];
|
char *uname;
|
||||||
DWORD unsize = UNLEN;
|
|
||||||
|
|
||||||
GetUserName(uname, &unsize);
|
uname = php_win32_get_username();
|
||||||
|
if (!uname) {
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
snprintf(newname, sizeof(newname) - 1, "%s@%s@%.32s", name, uname, ZCG(system_id));
|
snprintf(newname, sizeof(newname) - 1, "%s@%s@%.32s", name, uname, ZCG(system_id));
|
||||||
|
|
||||||
|
free(uname);
|
||||||
|
|
||||||
return newname;
|
return newname;
|
||||||
}
|
}
|
||||||
|
|
||||||
static char *get_mmap_base_file(void)
|
static char *get_mmap_base_file(void)
|
||||||
{
|
{
|
||||||
static char windir[MAXPATHLEN+UNLEN + 3 + sizeof("\\\\@") + 1 + 32];
|
static char windir[MAXPATHLEN+UNLEN + 3 + sizeof("\\\\@") + 1 + 32];
|
||||||
char uname[UNLEN + 1];
|
char *uname;
|
||||||
DWORD unsize = UNLEN;
|
|
||||||
int l;
|
int l;
|
||||||
|
|
||||||
|
uname = php_win32_get_username();
|
||||||
|
if (!uname) {
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
GetTempPath(MAXPATHLEN, windir);
|
GetTempPath(MAXPATHLEN, windir);
|
||||||
GetUserName(uname, &unsize);
|
|
||||||
l = strlen(windir);
|
l = strlen(windir);
|
||||||
snprintf(windir + l, sizeof(windir) - l - 1, "\\%s@%s@%.32s", ACCEL_FILEMAP_BASE, uname, ZCG(system_id));
|
snprintf(windir + l, sizeof(windir) - l - 1, "\\%s@%s@%.32s", ACCEL_FILEMAP_BASE, uname, ZCG(system_id));
|
||||||
|
|
||||||
|
free(uname);
|
||||||
|
|
||||||
return windir;
|
return windir;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
43
ext/simplexml/tests/001-mb.phpt
Normal file
43
ext/simplexml/tests/001-mb.phpt
Normal file
|
@ -0,0 +1,43 @@
|
||||||
|
--TEST--
|
||||||
|
SimpleXML: Simple document
|
||||||
|
--SKIPIF--
|
||||||
|
<?php if (!extension_loaded("simplexml")) print "skip"; ?>
|
||||||
|
--FILE--
|
||||||
|
<?php
|
||||||
|
|
||||||
|
var_dump(simplexml_load_file(dirname(__FILE__).'/sxe私はガラスを食べられます.xml'));
|
||||||
|
|
||||||
|
?>
|
||||||
|
===DONE===
|
||||||
|
--EXPECTF--
|
||||||
|
object(SimpleXMLElement)#%d (2) {
|
||||||
|
["@attributes"]=>
|
||||||
|
array(1) {
|
||||||
|
["id"]=>
|
||||||
|
string(5) "elem1"
|
||||||
|
}
|
||||||
|
["elem1"]=>
|
||||||
|
object(SimpleXMLElement)#%d (3) {
|
||||||
|
["@attributes"]=>
|
||||||
|
array(1) {
|
||||||
|
["attr1"]=>
|
||||||
|
string(5) "first"
|
||||||
|
}
|
||||||
|
["comment"]=>
|
||||||
|
object(SimpleXMLElement)#%d (0) {
|
||||||
|
}
|
||||||
|
["elem2"]=>
|
||||||
|
object(SimpleXMLElement)#%d (1) {
|
||||||
|
["elem3"]=>
|
||||||
|
object(SimpleXMLElement)#%d (1) {
|
||||||
|
["elem4"]=>
|
||||||
|
object(SimpleXMLElement)#%d (1) {
|
||||||
|
["test"]=>
|
||||||
|
object(SimpleXMLElement)#%d (0) {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
===DONE===
|
17
ext/simplexml/tests/sxe私はガラスを食べられます.xml
Normal file
17
ext/simplexml/tests/sxe私はガラスを食べられます.xml
Normal file
|
@ -0,0 +1,17 @@
|
||||||
|
<?xml version='1.0'?>
|
||||||
|
<!DOCTYPE sxe SYSTEM "notfound.dtd" [
|
||||||
|
<!ENTITY % incent SYSTEM "sxe.ent">
|
||||||
|
%incent;
|
||||||
|
]>
|
||||||
|
<sxe id="elem1">
|
||||||
|
<elem1 attr1='first'>
|
||||||
|
<!-- comment -->
|
||||||
|
<elem2>
|
||||||
|
<elem3>
|
||||||
|
<elem4>
|
||||||
|
<?test processing instruction ?>
|
||||||
|
</elem4>
|
||||||
|
</elem3>
|
||||||
|
</elem2>
|
||||||
|
</elem1>
|
||||||
|
</sxe>
|
22
ext/sqlite3/tests/sqlite3_01_open-mb.phpt
Normal file
22
ext/sqlite3/tests/sqlite3_01_open-mb.phpt
Normal file
|
@ -0,0 +1,22 @@
|
||||||
|
--TEST--
|
||||||
|
SQLite3::open/close tests
|
||||||
|
--SKIPIF--
|
||||||
|
<?php require_once(dirname(__FILE__) . '/skipif.inc'); ?>
|
||||||
|
--FILE--
|
||||||
|
<?php
|
||||||
|
|
||||||
|
$db_file = dirname(__FILE__) . DIRECTORY_SEPARATOR . '私はガラスを食べられます.db';
|
||||||
|
$db = new SQLite3($db_file);
|
||||||
|
//require_once(dirname(__FILE__) . '/new_db.inc');
|
||||||
|
|
||||||
|
var_dump($db);
|
||||||
|
var_dump($db->close());
|
||||||
|
|
||||||
|
unlink($db_file);
|
||||||
|
echo "Done\n";
|
||||||
|
?>
|
||||||
|
--EXPECTF--
|
||||||
|
object(SQLite3)#%d (0) {
|
||||||
|
}
|
||||||
|
bool(true)
|
||||||
|
Done
|
|
@ -2675,6 +2675,23 @@ ZEND_BEGIN_ARG_INFO_EX(arginfo_version_compare, 0, 0, 2)
|
||||||
ZEND_ARG_INFO(0, oper)
|
ZEND_ARG_INFO(0, oper)
|
||||||
ZEND_END_ARG_INFO()
|
ZEND_END_ARG_INFO()
|
||||||
/* }}} */
|
/* }}} */
|
||||||
|
/* {{{ win32/codepage.c */
|
||||||
|
ZEND_BEGIN_ARG_INFO_EX(arginfo_sapi_windows_cp_set, 0, 0, 1)
|
||||||
|
ZEND_ARG_TYPE_INFO(0, code_page, IS_LONG, 0)
|
||||||
|
ZEND_END_ARG_INFO()
|
||||||
|
|
||||||
|
ZEND_BEGIN_ARG_INFO_EX(arginfo_sapi_windows_cp_get, 0, 0, 0)
|
||||||
|
ZEND_END_ARG_INFO()
|
||||||
|
|
||||||
|
ZEND_BEGIN_ARG_INFO_EX(arginfo_sapi_windows_cp_is_utf8, 0, 0, 0)
|
||||||
|
ZEND_END_ARG_INFO()
|
||||||
|
|
||||||
|
ZEND_BEGIN_ARG_INFO_EX(arginfo_sapi_windows_cp_conv, 0, 0, 3)
|
||||||
|
ZEND_ARG_INFO(0, in_codepage)
|
||||||
|
ZEND_ARG_INFO(0, out_codepage)
|
||||||
|
ZEND_ARG_TYPE_INFO(0, subject, IS_STRING, 0)
|
||||||
|
ZEND_END_ARG_INFO()
|
||||||
|
/* }}} */
|
||||||
/* }}} */
|
/* }}} */
|
||||||
|
|
||||||
const zend_function_entry basic_functions[] = { /* {{{ */
|
const zend_function_entry basic_functions[] = { /* {{{ */
|
||||||
|
@ -3368,6 +3385,12 @@ const zend_function_entry basic_functions[] = { /* {{{ */
|
||||||
|
|
||||||
PHP_FE(sys_get_temp_dir, arginfo_sys_get_temp_dir)
|
PHP_FE(sys_get_temp_dir, arginfo_sys_get_temp_dir)
|
||||||
|
|
||||||
|
#ifdef PHP_WIN32
|
||||||
|
PHP_FE(sapi_windows_cp_set, arginfo_sapi_windows_cp_set)
|
||||||
|
PHP_FE(sapi_windows_cp_get, arginfo_sapi_windows_cp_get)
|
||||||
|
PHP_FE(sapi_windows_cp_is_utf8, arginfo_sapi_windows_cp_is_utf8)
|
||||||
|
PHP_FE(sapi_windows_cp_conv, arginfo_sapi_windows_cp_conv)
|
||||||
|
#endif
|
||||||
PHP_FE_END
|
PHP_FE_END
|
||||||
};
|
};
|
||||||
/* }}} */
|
/* }}} */
|
||||||
|
|
|
@ -133,6 +133,13 @@ PHP_FUNCTION(parse_ini_string);
|
||||||
PHP_FUNCTION(config_get_hash);
|
PHP_FUNCTION(config_get_hash);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if defined(PHP_WIN32)
|
||||||
|
PHP_FUNCTION(sapi_windows_cp_set);
|
||||||
|
PHP_FUNCTION(sapi_windows_cp_get);
|
||||||
|
PHP_FUNCTION(sapi_windows_cp_is_utf8);
|
||||||
|
PHP_FUNCTION(sapi_windows_cp_conv);
|
||||||
|
#endif
|
||||||
|
|
||||||
PHP_FUNCTION(str_rot13);
|
PHP_FUNCTION(str_rot13);
|
||||||
PHP_FUNCTION(stream_get_filters);
|
PHP_FUNCTION(stream_get_filters);
|
||||||
PHP_FUNCTION(stream_filter_register);
|
PHP_FUNCTION(stream_filter_register);
|
||||||
|
|
|
@ -429,13 +429,14 @@ PHP_FUNCTION(proc_open)
|
||||||
#ifdef PHP_WIN32
|
#ifdef PHP_WIN32
|
||||||
PROCESS_INFORMATION pi;
|
PROCESS_INFORMATION pi;
|
||||||
HANDLE childHandle;
|
HANDLE childHandle;
|
||||||
STARTUPINFO si;
|
STARTUPINFOW si;
|
||||||
BOOL newprocok;
|
BOOL newprocok;
|
||||||
SECURITY_ATTRIBUTES security;
|
SECURITY_ATTRIBUTES security;
|
||||||
DWORD dwCreateFlags = 0;
|
DWORD dwCreateFlags = 0;
|
||||||
char *command_with_cmd;
|
|
||||||
UINT old_error_mode;
|
UINT old_error_mode;
|
||||||
char cur_cwd[MAXPATHLEN];
|
char cur_cwd[MAXPATHLEN];
|
||||||
|
wchar_t *cmdw = NULL, *cwdw = NULL, *envpw = NULL;
|
||||||
|
size_t tmp_len;
|
||||||
#endif
|
#endif
|
||||||
#ifdef NETWARE
|
#ifdef NETWARE
|
||||||
char** child_argv = NULL;
|
char** child_argv = NULL;
|
||||||
|
@ -685,6 +686,11 @@ PHP_FUNCTION(proc_open)
|
||||||
}
|
}
|
||||||
cwd = cur_cwd;
|
cwd = cur_cwd;
|
||||||
}
|
}
|
||||||
|
cwdw = php_win32_cp_any_to_w(cwd);
|
||||||
|
if (!cwdw) {
|
||||||
|
php_error_docref(NULL, E_WARNING, "CWD conversion failed");
|
||||||
|
goto exit_fail;
|
||||||
|
}
|
||||||
|
|
||||||
memset(&si, 0, sizeof(si));
|
memset(&si, 0, sizeof(si));
|
||||||
si.cb = sizeof(si);
|
si.cb = sizeof(si);
|
||||||
|
@ -721,15 +727,49 @@ PHP_FUNCTION(proc_open)
|
||||||
dwCreateFlags |= CREATE_NO_WINDOW;
|
dwCreateFlags |= CREATE_NO_WINDOW;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (bypass_shell) {
|
envpw = php_win32_cp_env_any_to_w(env.envp);
|
||||||
newprocok = CreateProcess(NULL, command, &security, &security, TRUE, dwCreateFlags, env.envp, cwd, &si, &pi);
|
if (envpw) {
|
||||||
|
dwCreateFlags |= CREATE_UNICODE_ENVIRONMENT;
|
||||||
} else {
|
} else {
|
||||||
spprintf(&command_with_cmd, 0, "%s /c %s", COMSPEC_NT, command);
|
if (env.envp) {
|
||||||
|
php_error_docref(NULL, E_WARNING, "ENV conversion failed");
|
||||||
newprocok = CreateProcess(NULL, command_with_cmd, &security, &security, TRUE, dwCreateFlags, env.envp, cwd, &si, &pi);
|
goto exit_fail;
|
||||||
|
|
||||||
efree(command_with_cmd);
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
cmdw = php_win32_cp_conv_any_to_w(command, command_len, &tmp_len);
|
||||||
|
if (!cmdw) {
|
||||||
|
php_error_docref(NULL, E_WARNING, "Command conversion failed");
|
||||||
|
goto exit_fail;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (bypass_shell) {
|
||||||
|
newprocok = CreateProcessW(NULL, cmdw, &security, &security, TRUE, dwCreateFlags, envpw, cwdw, &si, &pi);
|
||||||
|
} else {
|
||||||
|
int ret;
|
||||||
|
size_t len;
|
||||||
|
wchar_t *cmdw2;
|
||||||
|
|
||||||
|
|
||||||
|
len = (sizeof(COMSPEC_NT) + sizeof(" /c ") + tmp_len + 1);
|
||||||
|
cmdw2 = (wchar_t *)malloc(len * sizeof(wchar_t));
|
||||||
|
ret = _snwprintf(cmdw2, len, L"%hs /c %s", COMSPEC_NT, cmdw);
|
||||||
|
|
||||||
|
if (-1 == ret) {
|
||||||
|
php_error_docref(NULL, E_WARNING, "Command conversion failed");
|
||||||
|
goto exit_fail;
|
||||||
|
}
|
||||||
|
|
||||||
|
newprocok = CreateProcessW(NULL, cmdw2, &security, &security, TRUE, dwCreateFlags, envpw, cwdw, &si, &pi);
|
||||||
|
free(cmdw2);
|
||||||
|
}
|
||||||
|
|
||||||
|
free(cwdw);
|
||||||
|
cwdw = NULL;
|
||||||
|
free(cmdw);
|
||||||
|
cmdw = NULL;
|
||||||
|
free(envpw);
|
||||||
|
envpw = NULL;
|
||||||
|
|
||||||
if (suppress_errors) {
|
if (suppress_errors) {
|
||||||
SetErrorMode(old_error_mode);
|
SetErrorMode(old_error_mode);
|
||||||
|
@ -963,6 +1003,11 @@ exit_fail:
|
||||||
efree(descriptors);
|
efree(descriptors);
|
||||||
_php_free_envp(env, is_persistent);
|
_php_free_envp(env, is_persistent);
|
||||||
pefree(command, is_persistent);
|
pefree(command, is_persistent);
|
||||||
|
#ifdef PHP_WIN32
|
||||||
|
free(cwdw);
|
||||||
|
free(cmdw);
|
||||||
|
free(envpw);
|
||||||
|
#endif
|
||||||
#if PHP_CAN_DO_PTS
|
#if PHP_CAN_DO_PTS
|
||||||
if (dev_ptmx >= 0) {
|
if (dev_ptmx >= 0) {
|
||||||
close(dev_ptmx);
|
close(dev_ptmx);
|
||||||
|
|
|
@ -1670,7 +1670,11 @@ PHP_FUNCTION(dirname)
|
||||||
|
|
||||||
if (levels == 1) {
|
if (levels == 1) {
|
||||||
/* Defaut case */
|
/* Defaut case */
|
||||||
|
#ifdef PHP_WIN32
|
||||||
|
ZSTR_LEN(ret) = php_win32_ioutil_dirname(ZSTR_VAL(ret), str_len);
|
||||||
|
#else
|
||||||
ZSTR_LEN(ret) = zend_dirname(ZSTR_VAL(ret), str_len);
|
ZSTR_LEN(ret) = zend_dirname(ZSTR_VAL(ret), str_len);
|
||||||
|
#endif
|
||||||
} else if (levels < 1) {
|
} else if (levels < 1) {
|
||||||
php_error_docref(NULL, E_WARNING, "Invalid argument, levels must be >= 1");
|
php_error_docref(NULL, E_WARNING, "Invalid argument, levels must be >= 1");
|
||||||
zend_string_free(ret);
|
zend_string_free(ret);
|
||||||
|
@ -1678,7 +1682,11 @@ PHP_FUNCTION(dirname)
|
||||||
} else {
|
} else {
|
||||||
/* Some levels up */
|
/* Some levels up */
|
||||||
do {
|
do {
|
||||||
|
#ifdef PHP_WIN32
|
||||||
|
ZSTR_LEN(ret) = php_win32_ioutil_dirname(ZSTR_VAL(ret), str_len = ZSTR_LEN(ret));
|
||||||
|
#else
|
||||||
ZSTR_LEN(ret) = zend_dirname(ZSTR_VAL(ret), str_len = ZSTR_LEN(ret));
|
ZSTR_LEN(ret) = zend_dirname(ZSTR_VAL(ret), str_len = ZSTR_LEN(ret));
|
||||||
|
#endif
|
||||||
} while (ZSTR_LEN(ret) < str_len && --levels);
|
} while (ZSTR_LEN(ret) < str_len && --levels);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
54
ext/standard/tests/dir/chdir_basic-win32-mb.phpt
Normal file
54
ext/standard/tests/dir/chdir_basic-win32-mb.phpt
Normal file
|
@ -0,0 +1,54 @@
|
||||||
|
--TEST--
|
||||||
|
Test chdir() function : basic functionality
|
||||||
|
--FILE--
|
||||||
|
<?php
|
||||||
|
/* Prototype : bool chdir(string $directory)
|
||||||
|
* Description: Change the current directory
|
||||||
|
* Source code: ext/standard/dir.c
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Test basic functionality of chdir() with absolute and relative paths
|
||||||
|
*/
|
||||||
|
|
||||||
|
echo "*** Testing chdir() : basic functionality ***\n";
|
||||||
|
$base_dir_path = dirname(__FILE__);
|
||||||
|
|
||||||
|
$level_one_dir_name = "私はガラスを食べられますlevel_one";
|
||||||
|
$level_one_dir_path = "$base_dir_path/$level_one_dir_name";
|
||||||
|
|
||||||
|
$level_two_dir_name = "私はガラスを食べられますlevel_two";
|
||||||
|
$level_two_dir_path = "$base_dir_path/$level_one_dir_name/$level_two_dir_name";
|
||||||
|
|
||||||
|
// create directories
|
||||||
|
mkdir($level_one_dir_path);
|
||||||
|
mkdir($level_two_dir_path);
|
||||||
|
|
||||||
|
echo "\n-- Testing chdir() with absolute path: --\n";
|
||||||
|
chdir($base_dir_path);
|
||||||
|
var_dump(chdir($level_one_dir_path));
|
||||||
|
var_dump(getcwd());
|
||||||
|
|
||||||
|
echo "\n-- Testing chdir() with relative paths: --\n";
|
||||||
|
var_dump(chdir($level_two_dir_name));
|
||||||
|
var_dump(getcwd());
|
||||||
|
?>
|
||||||
|
===DONE===
|
||||||
|
--CLEAN--
|
||||||
|
<?php
|
||||||
|
$file_path = dirname(__FILE__);
|
||||||
|
chdir($file_path);
|
||||||
|
rmdir("$file_path/私はガラスを食べられますlevel_one/私はガラスを食べられますlevel_two");
|
||||||
|
rmdir("$file_path/私はガラスを食べられますlevel_one");
|
||||||
|
?>
|
||||||
|
--EXPECTF--
|
||||||
|
*** Testing chdir() : basic functionality ***
|
||||||
|
|
||||||
|
-- Testing chdir() with absolute path: --
|
||||||
|
bool(true)
|
||||||
|
string(%d) "%s私はガラスを食べられますlevel_one"
|
||||||
|
|
||||||
|
-- Testing chdir() with relative paths: --
|
||||||
|
bool(true)
|
||||||
|
string(%d) "%s私はガラスを食べられますlevel_one%e私はガラスを食べられますlevel_two"
|
||||||
|
===DONE===
|
26
ext/standard/tests/dir/chdir_error2-win32-mb.phpt
Normal file
26
ext/standard/tests/dir/chdir_error2-win32-mb.phpt
Normal file
|
@ -0,0 +1,26 @@
|
||||||
|
--TEST--
|
||||||
|
Test chdir() function : error conditions - Non-existent directory
|
||||||
|
--FILE--
|
||||||
|
<?php
|
||||||
|
/* Prototype : bool chdir(string $directory)
|
||||||
|
* Description: Change the current directory
|
||||||
|
* Source code: ext/standard/dir.c
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Pass a directory that does not exist as $directory to chdir() to test behaviour
|
||||||
|
*/
|
||||||
|
|
||||||
|
echo "*** Testing chdir() : error conditions ***\n";
|
||||||
|
|
||||||
|
$directory = __FILE__ . '/私はガラスを食べられますidonotexist';
|
||||||
|
|
||||||
|
var_dump(chdir($directory));
|
||||||
|
?>
|
||||||
|
===DONE===
|
||||||
|
--EXPECTF--
|
||||||
|
*** Testing chdir() : error conditions ***
|
||||||
|
|
||||||
|
Warning: chdir(): %s (errno %d) in %s on line %d
|
||||||
|
bool(false)
|
||||||
|
===DONE===
|
235
ext/standard/tests/dir/chdir_variation1-win32-mb.phpt
Normal file
235
ext/standard/tests/dir/chdir_variation1-win32-mb.phpt
Normal file
|
@ -0,0 +1,235 @@
|
||||||
|
--TEST--
|
||||||
|
Test chdir() function : usage variations - different data type as $directory arg
|
||||||
|
--FILE--
|
||||||
|
<?php
|
||||||
|
/* Prototype : bool chdir(string $directory)
|
||||||
|
* Description: Change the current directory
|
||||||
|
* Source code: ext/standard/dir.c
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Pass different data types as $directory argument to test behaviour
|
||||||
|
*/
|
||||||
|
|
||||||
|
echo "*** Testing chdir() : usage variations ***\n";
|
||||||
|
|
||||||
|
// create the temporary directory
|
||||||
|
$file_path = dirname(__FILE__);
|
||||||
|
$dir_path = $file_path."/私はガラスを食べられますchdir_basic";
|
||||||
|
@mkdir($dir_path);
|
||||||
|
|
||||||
|
//get an unset variable
|
||||||
|
$unset_var = 10;
|
||||||
|
unset ($unset_var);
|
||||||
|
|
||||||
|
// get a class
|
||||||
|
class classA {
|
||||||
|
var $dir_path;
|
||||||
|
|
||||||
|
function __construct($dir) {
|
||||||
|
$this->dir_path = $dir;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function __toString() {
|
||||||
|
return "$this->dir_path";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// heredoc string
|
||||||
|
$heredoc = <<<EOT
|
||||||
|
$dir_path
|
||||||
|
EOT;
|
||||||
|
|
||||||
|
// get a resource variable
|
||||||
|
$fp = fopen(__FILE__, "r");
|
||||||
|
|
||||||
|
// unexpected values to be passed to $directory argument
|
||||||
|
$inputs = array(
|
||||||
|
|
||||||
|
// int data
|
||||||
|
/*1*/ 0,
|
||||||
|
1,
|
||||||
|
12345,
|
||||||
|
-2345,
|
||||||
|
|
||||||
|
// float data
|
||||||
|
/*5*/ 10.5,
|
||||||
|
-10.5,
|
||||||
|
12.3456789000e10,
|
||||||
|
12.3456789000E-10,
|
||||||
|
.5,
|
||||||
|
|
||||||
|
// null data
|
||||||
|
/*10*/ NULL,
|
||||||
|
null,
|
||||||
|
|
||||||
|
// boolean data
|
||||||
|
/*12*/ true,
|
||||||
|
false,
|
||||||
|
TRUE,
|
||||||
|
FALSE,
|
||||||
|
|
||||||
|
// empty data
|
||||||
|
/*16*/ "",
|
||||||
|
'',
|
||||||
|
array(),
|
||||||
|
|
||||||
|
// string data
|
||||||
|
/*19*/ "$dir_path",
|
||||||
|
'string',
|
||||||
|
$heredoc,
|
||||||
|
|
||||||
|
// object data
|
||||||
|
/*22*/ new classA($dir_path),
|
||||||
|
|
||||||
|
// undefined data
|
||||||
|
/*23*/ @$undefined_var,
|
||||||
|
|
||||||
|
// unset data
|
||||||
|
/*24*/ @$unset_var,
|
||||||
|
|
||||||
|
// resource variable
|
||||||
|
/*25*/ $fp
|
||||||
|
);
|
||||||
|
|
||||||
|
// loop through each element of $inputs to check the behavior of chdir()
|
||||||
|
$iterator = 1;
|
||||||
|
foreach($inputs as $input) {
|
||||||
|
echo "\n-- Iteration $iterator --\n";
|
||||||
|
var_dump( chdir($input) );
|
||||||
|
$iterator++;
|
||||||
|
};
|
||||||
|
|
||||||
|
fclose($fp);
|
||||||
|
|
||||||
|
?>
|
||||||
|
===DONE===
|
||||||
|
--CLEAN--
|
||||||
|
<?php
|
||||||
|
$file_path = dirname(__FILE__);
|
||||||
|
$dir_path = $file_path."/私はガラスを食べられますchdir_basic";
|
||||||
|
|
||||||
|
rmdir($dir_path);
|
||||||
|
?>
|
||||||
|
--EXPECTF--
|
||||||
|
*** Testing chdir() : usage variations ***
|
||||||
|
|
||||||
|
-- Iteration 1 --
|
||||||
|
|
||||||
|
Warning: chdir(): %s (errno %d) in %s on line %d
|
||||||
|
bool(false)
|
||||||
|
|
||||||
|
-- Iteration 2 --
|
||||||
|
|
||||||
|
Warning: chdir(): %s (errno %d) in %s on line %d
|
||||||
|
bool(false)
|
||||||
|
|
||||||
|
-- Iteration 3 --
|
||||||
|
|
||||||
|
Warning: chdir(): %s (errno %d) in %s on line %d
|
||||||
|
bool(false)
|
||||||
|
|
||||||
|
-- Iteration 4 --
|
||||||
|
|
||||||
|
Warning: chdir(): %s (errno %d) in %s on line %d
|
||||||
|
bool(false)
|
||||||
|
|
||||||
|
-- Iteration 5 --
|
||||||
|
|
||||||
|
Warning: chdir(): %s (errno %d) in %s on line %d
|
||||||
|
bool(false)
|
||||||
|
|
||||||
|
-- Iteration 6 --
|
||||||
|
|
||||||
|
Warning: chdir(): %s (errno %d) in %s on line %d
|
||||||
|
bool(false)
|
||||||
|
|
||||||
|
-- Iteration 7 --
|
||||||
|
|
||||||
|
Warning: chdir(): %s (errno %d) in %s on line %d
|
||||||
|
bool(false)
|
||||||
|
|
||||||
|
-- Iteration 8 --
|
||||||
|
|
||||||
|
Warning: chdir(): %s (errno %d) in %s on line %d
|
||||||
|
bool(false)
|
||||||
|
|
||||||
|
-- Iteration 9 --
|
||||||
|
|
||||||
|
Warning: chdir(): %s (errno %d) in %s on line %d
|
||||||
|
bool(false)
|
||||||
|
|
||||||
|
-- Iteration 10 --
|
||||||
|
|
||||||
|
Warning: chdir(): %s (errno %d) in %s on line %d
|
||||||
|
bool(false)
|
||||||
|
|
||||||
|
-- Iteration 11 --
|
||||||
|
|
||||||
|
Warning: chdir(): %s (errno %d) in %s on line %d
|
||||||
|
bool(false)
|
||||||
|
|
||||||
|
-- Iteration 12 --
|
||||||
|
|
||||||
|
Warning: chdir(): %s (errno %d) in %s on line %d
|
||||||
|
bool(false)
|
||||||
|
|
||||||
|
-- Iteration 13 --
|
||||||
|
|
||||||
|
Warning: chdir(): %s (errno %d) in %s on line %d
|
||||||
|
bool(false)
|
||||||
|
|
||||||
|
-- Iteration 14 --
|
||||||
|
|
||||||
|
Warning: chdir(): %s (errno %d) in %s on line %d
|
||||||
|
bool(false)
|
||||||
|
|
||||||
|
-- Iteration 15 --
|
||||||
|
|
||||||
|
Warning: chdir(): %s (errno %d) in %s on line %d
|
||||||
|
bool(false)
|
||||||
|
|
||||||
|
-- Iteration 16 --
|
||||||
|
|
||||||
|
Warning: chdir(): %s (errno %d) in %s on line %d
|
||||||
|
bool(false)
|
||||||
|
|
||||||
|
-- Iteration 17 --
|
||||||
|
|
||||||
|
Warning: chdir(): %s (errno %d) in %s on line %d
|
||||||
|
bool(false)
|
||||||
|
|
||||||
|
-- Iteration 18 --
|
||||||
|
|
||||||
|
Warning: chdir() expects parameter 1 to be a valid path, array given in %s on line %d
|
||||||
|
bool(false)
|
||||||
|
|
||||||
|
-- Iteration 19 --
|
||||||
|
bool(true)
|
||||||
|
|
||||||
|
-- Iteration 20 --
|
||||||
|
|
||||||
|
Warning: chdir(): %s (errno %d) in %s on line %d
|
||||||
|
bool(false)
|
||||||
|
|
||||||
|
-- Iteration 21 --
|
||||||
|
bool(true)
|
||||||
|
|
||||||
|
-- Iteration 22 --
|
||||||
|
bool(true)
|
||||||
|
|
||||||
|
-- Iteration 23 --
|
||||||
|
|
||||||
|
Warning: chdir(): %s (errno %d) in %s on line %d
|
||||||
|
bool(false)
|
||||||
|
|
||||||
|
-- Iteration 24 --
|
||||||
|
|
||||||
|
Warning: chdir(): %s (errno %d) in %s on line %d
|
||||||
|
bool(false)
|
||||||
|
|
||||||
|
-- Iteration 25 --
|
||||||
|
|
||||||
|
Warning: chdir() expects parameter 1 to be a valid path, resource given in %s on line %d
|
||||||
|
bool(false)
|
||||||
|
===DONE===
|
109
ext/standard/tests/dir/chdir_variation2-win32-mb.phpt
Normal file
109
ext/standard/tests/dir/chdir_variation2-win32-mb.phpt
Normal file
|
@ -0,0 +1,109 @@
|
||||||
|
--TEST--
|
||||||
|
Test chdir() function : usage variations - relative paths
|
||||||
|
--FILE--
|
||||||
|
<?php
|
||||||
|
/* Prototype : bool chdir(string $directory)
|
||||||
|
* Description: Change the current directory
|
||||||
|
* Source code: ext/standard/dir.c
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Test chdir() with variations of relative paths
|
||||||
|
*/
|
||||||
|
|
||||||
|
echo "*** Testing chdir() : usage variations ***\n";
|
||||||
|
|
||||||
|
$base_dir_path = dirname(__FILE__);
|
||||||
|
|
||||||
|
$level_one_dir_name = "私はガラスを食べられますlevel_one";
|
||||||
|
$level_one_dir_path = "$base_dir_path/$level_one_dir_name";
|
||||||
|
|
||||||
|
$level_two_dir_name = "私はガラスを食べられますlevel_two";
|
||||||
|
$level_two_dir_path = "$base_dir_path/$level_one_dir_name/$level_two_dir_name";
|
||||||
|
|
||||||
|
// create directories
|
||||||
|
mkdir($level_one_dir_path);
|
||||||
|
mkdir($level_two_dir_path);
|
||||||
|
|
||||||
|
echo "\n-- \$directory = './私はガラスを食べられますlevel_one': --\n";
|
||||||
|
var_dump(chdir($base_dir_path));
|
||||||
|
var_dump(chdir("./$level_one_dir_name"));
|
||||||
|
var_dump(getcwd());
|
||||||
|
|
||||||
|
echo "\n-- \$directory = '私はガラスを食べられますlevel_one/私はガラスを食べられますlevel_two': --\n";
|
||||||
|
var_dump(chdir($base_dir_path));
|
||||||
|
var_dump(chdir("$level_one_dir_name/$level_two_dir_name"));
|
||||||
|
var_dump(getcwd());
|
||||||
|
|
||||||
|
echo "\n-- \$directory = '..': --\n";
|
||||||
|
var_dump(chdir('..'));
|
||||||
|
var_dump(getcwd());
|
||||||
|
|
||||||
|
echo "\n-- \$directory = '私はガラスを食べられますlevel_two', '.': --\n";
|
||||||
|
var_dump(chdir($level_two_dir_path));
|
||||||
|
var_dump(chdir('.'));
|
||||||
|
var_dump(getcwd());
|
||||||
|
|
||||||
|
echo "\n-- \$directory = '../': --\n";
|
||||||
|
var_dump(chdir('../'));
|
||||||
|
var_dump(getcwd());
|
||||||
|
|
||||||
|
echo "\n-- \$directory = './': --\n";
|
||||||
|
var_dump(chdir($level_two_dir_path));
|
||||||
|
var_dump(chdir('./'));
|
||||||
|
var_dump(getcwd());
|
||||||
|
|
||||||
|
echo "\n-- \$directory = '../../'私はガラスを食べられますlevel_one': --\n";
|
||||||
|
var_dump(chdir($level_two_dir_path));
|
||||||
|
var_dump(chdir("../../$level_one_dir_name"));
|
||||||
|
var_dump(getcwd());
|
||||||
|
|
||||||
|
$file_path = dirname(__FILE__);
|
||||||
|
chdir($file_path);/* not that PWD is accidentialy one of the dirs to be deleted. */
|
||||||
|
rmdir("$file_path/私はガラスを食べられますlevel_one/私はガラスを食べられますlevel_two");
|
||||||
|
rmdir("$file_path/私はガラスを食べられますlevel_one");
|
||||||
|
?>
|
||||||
|
===DONE===
|
||||||
|
--CLEAN--
|
||||||
|
<?php
|
||||||
|
$file_path = dirname(__FILE__);
|
||||||
|
chdir($file_path);/* not that PWD is accidentialy one of the dirs to be deleted. */
|
||||||
|
rmdir("$file_path/私はガラスを食べられますlevel_one/私はガラスを食べられますlevel_two");
|
||||||
|
rmdir("$file_path/私はガラスを食べられますlevel_one");
|
||||||
|
?>
|
||||||
|
--EXPECTF--
|
||||||
|
*** Testing chdir() : usage variations ***
|
||||||
|
|
||||||
|
-- $directory = './私はガラスを食べられますlevel_one': --
|
||||||
|
bool(true)
|
||||||
|
bool(true)
|
||||||
|
string(%d) "%slevel_one"
|
||||||
|
|
||||||
|
-- $directory = '私はガラスを食べられますlevel_one/私はガラスを食べられますlevel_two': --
|
||||||
|
bool(true)
|
||||||
|
bool(true)
|
||||||
|
string(%d) "%s私はガラスを食べられますlevel_one%e私はガラスを食べられますlevel_two"
|
||||||
|
|
||||||
|
-- $directory = '..': --
|
||||||
|
bool(true)
|
||||||
|
string(%d) "%s私はガラスを食べられますlevel_one"
|
||||||
|
|
||||||
|
-- $directory = '私はガラスを食べられますlevel_two', '.': --
|
||||||
|
bool(true)
|
||||||
|
bool(true)
|
||||||
|
string(%d) "%s私はガラスを食べられますlevel_one%e私はガラスを食べられますlevel_two"
|
||||||
|
|
||||||
|
-- $directory = '../': --
|
||||||
|
bool(true)
|
||||||
|
string(%d) "%slevel_one"
|
||||||
|
|
||||||
|
-- $directory = './': --
|
||||||
|
bool(true)
|
||||||
|
bool(true)
|
||||||
|
string(%d) "%s私はガラスを食べられますlevel_one%e私はガラスを食べられますlevel_two"
|
||||||
|
|
||||||
|
-- $directory = '../../'私はガラスを食べられますlevel_one': --
|
||||||
|
bool(true)
|
||||||
|
bool(true)
|
||||||
|
string(%d) "%s私はガラスを食べられますlevel_one"
|
||||||
|
===DONE===
|
56
ext/standard/tests/dir/closedir_basic-win32-mb.phpt
Normal file
56
ext/standard/tests/dir/closedir_basic-win32-mb.phpt
Normal file
|
@ -0,0 +1,56 @@
|
||||||
|
--TEST--
|
||||||
|
Test closedir() function : basic functionality
|
||||||
|
--FILE--
|
||||||
|
<?php
|
||||||
|
/* Prototype : void closedir([resource $dir_handle])
|
||||||
|
* Description: Close directory connection identified by the dir_handle
|
||||||
|
* Source code: ext/standard/dir.c
|
||||||
|
* Alias to functions: close
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Test basic functionality of closedir()
|
||||||
|
*/
|
||||||
|
|
||||||
|
echo "*** Testing closedir() : basic functionality ***\n";
|
||||||
|
|
||||||
|
$base_dir = dirname(__FILE__);
|
||||||
|
$dir_path = $base_dir . '/私はガラスを食べられますclosedir_basic';
|
||||||
|
mkdir($dir_path);
|
||||||
|
|
||||||
|
echo "\n-- Call closedir() with no arguments: --\n";
|
||||||
|
$dh1 = opendir($dir_path);
|
||||||
|
var_dump(closedir());
|
||||||
|
echo "-- Check Directory Handle: --\n";
|
||||||
|
var_dump($dh1);
|
||||||
|
|
||||||
|
echo "\n-- Call closedir() with \$dir_handle argument supplied: --\n";
|
||||||
|
$dh2 = opendir($dir_path);
|
||||||
|
|
||||||
|
if ((int)$dh1 === (int)$dh2) {
|
||||||
|
echo "\nNo new resource created\n";
|
||||||
|
}
|
||||||
|
var_dump(closedir($dh2));
|
||||||
|
echo "-- Check Directory Handle: --\n";
|
||||||
|
var_dump($dh2);
|
||||||
|
?>
|
||||||
|
===DONE===
|
||||||
|
--CLEAN--
|
||||||
|
<?php
|
||||||
|
$base_dir = dirname(__FILE__);
|
||||||
|
$dir_path = $base_dir . '/私はガラスを食べられますclosedir_basic';
|
||||||
|
rmdir($dir_path);
|
||||||
|
?>
|
||||||
|
--EXPECTF--
|
||||||
|
*** Testing closedir() : basic functionality ***
|
||||||
|
|
||||||
|
-- Call closedir() with no arguments: --
|
||||||
|
NULL
|
||||||
|
-- Check Directory Handle: --
|
||||||
|
resource(%d) of type (Unknown)
|
||||||
|
|
||||||
|
-- Call closedir() with $dir_handle argument supplied: --
|
||||||
|
NULL
|
||||||
|
-- Check Directory Handle: --
|
||||||
|
resource(%d) of type (Unknown)
|
||||||
|
===DONE===
|
45
ext/standard/tests/dir/closedir_error-win32-mb.phpt
Normal file
45
ext/standard/tests/dir/closedir_error-win32-mb.phpt
Normal file
|
@ -0,0 +1,45 @@
|
||||||
|
--TEST--
|
||||||
|
Test closedir() function : error conditions - Pass incorrect number of arguments
|
||||||
|
--FILE--
|
||||||
|
<?php
|
||||||
|
/* Prototype : void closedir([resource $dir_handle])
|
||||||
|
* Description: Close directory connection identified by the dir_handle
|
||||||
|
* Source code: ext/standard/dir.c
|
||||||
|
* Alias to functions: close
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Pass incorrect number of arguments to closedir() to test behaviour
|
||||||
|
*/
|
||||||
|
|
||||||
|
echo "*** Testing closedir() : error conditions ***\n";
|
||||||
|
|
||||||
|
|
||||||
|
//Test closedir with one more than the expected number of arguments
|
||||||
|
echo "\n-- Testing closedir() function with more than expected no. of arguments --\n";
|
||||||
|
|
||||||
|
$dir_path = dirname(__FILE__) . '\私はガラスを食べられますclosedir_error';
|
||||||
|
mkdir($dir_path);
|
||||||
|
$dir_handle = opendir($dir_path);
|
||||||
|
|
||||||
|
$extra_arg = 10;
|
||||||
|
var_dump( closedir($dir_handle, $extra_arg) );
|
||||||
|
|
||||||
|
//successfully close the directory handle so can delete in CLEAN section
|
||||||
|
closedir($dir_handle);
|
||||||
|
?>
|
||||||
|
===DONE===
|
||||||
|
--CLEAN--
|
||||||
|
<?php
|
||||||
|
$base_dir = dirname(__FILE__);
|
||||||
|
$dir_path = $base_dir . '\私はガラスを食べられますclosedir_error';
|
||||||
|
rmdir($dir_path);
|
||||||
|
?>
|
||||||
|
--EXPECTF--
|
||||||
|
*** Testing closedir() : error conditions ***
|
||||||
|
|
||||||
|
-- Testing closedir() function with more than expected no. of arguments --
|
||||||
|
|
||||||
|
Warning: closedir() expects at most 1 parameter, 2 given in %s on line %d
|
||||||
|
NULL
|
||||||
|
===DONE===
|
51
ext/standard/tests/dir/closedir_variation2-win32-mb.phpt
Normal file
51
ext/standard/tests/dir/closedir_variation2-win32-mb.phpt
Normal file
|
@ -0,0 +1,51 @@
|
||||||
|
--TEST--
|
||||||
|
Test closedir() function : usage variations - close directory handle twice
|
||||||
|
--FILE--
|
||||||
|
<?php
|
||||||
|
/* Prototype : void closedir([resource $dir_handle])
|
||||||
|
* Description: Close directory connection identified by the dir_handle
|
||||||
|
* Source code: ext/standard/dir.c
|
||||||
|
* Alias to functions: close
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
* close the directory handle twice using closedir() to test behaviour
|
||||||
|
*/
|
||||||
|
|
||||||
|
echo "*** Testing closedir() : usage variations ***\n";
|
||||||
|
|
||||||
|
//create temporary directory for test, removed in CLEAN section
|
||||||
|
$directory = dirname(__FILE__) . "/私はガラスを食べられますclosedir_variation2";
|
||||||
|
mkdir($directory);
|
||||||
|
|
||||||
|
$dh = opendir($directory);
|
||||||
|
|
||||||
|
echo "\n-- Close directory handle first time: --\n";
|
||||||
|
var_dump(closedir($dh));
|
||||||
|
echo "Directory Handle: ";
|
||||||
|
var_dump($dh);
|
||||||
|
|
||||||
|
echo "\n-- Close directory handle second time: --\n";
|
||||||
|
var_dump(closedir($dh));
|
||||||
|
echo "Directory Handle: ";
|
||||||
|
var_dump($dh);
|
||||||
|
?>
|
||||||
|
===DONE===
|
||||||
|
--CLEAN--
|
||||||
|
<?php
|
||||||
|
$directory = dirname(__FILE__) . "/私はガラスを食べられますclosedir_variation2";
|
||||||
|
rmdir($directory);
|
||||||
|
?>
|
||||||
|
--EXPECTF--
|
||||||
|
*** Testing closedir() : usage variations ***
|
||||||
|
|
||||||
|
-- Close directory handle first time: --
|
||||||
|
NULL
|
||||||
|
Directory Handle: resource(%d) of type (Unknown)
|
||||||
|
|
||||||
|
-- Close directory handle second time: --
|
||||||
|
|
||||||
|
Warning: closedir(): %s is not a valid Directory resource in %s on line %d
|
||||||
|
bool(false)
|
||||||
|
Directory Handle: resource(%d) of type (Unknown)
|
||||||
|
===DONE===
|
86
ext/standard/tests/dir/dir_basic-win32-mb.phpt
Normal file
86
ext/standard/tests/dir/dir_basic-win32-mb.phpt
Normal file
|
@ -0,0 +1,86 @@
|
||||||
|
--TEST--
|
||||||
|
Test dir() function : basic functionality
|
||||||
|
--FILE--
|
||||||
|
<?php
|
||||||
|
/*
|
||||||
|
* Prototype : object dir(string $directory[, resource $context])
|
||||||
|
* Description: Directory class with properties, handle and class and methods read, rewind and close
|
||||||
|
* Source code: ext/standard/dir.c
|
||||||
|
*/
|
||||||
|
|
||||||
|
echo "*** Testing dir() : basic functionality ***\n";
|
||||||
|
|
||||||
|
// include the file.inc for Function: function create_files()
|
||||||
|
include(dirname(__FILE__)."/../file/file.inc");
|
||||||
|
|
||||||
|
// create the temporary directory
|
||||||
|
$file_path = dirname(__FILE__);
|
||||||
|
$dir_path = $file_path."/私はガラスを食べられますdir_basic";
|
||||||
|
@mkdir($dir_path);
|
||||||
|
|
||||||
|
// create files within the temporary directory
|
||||||
|
create_files($dir_path, 3, "alphanumeric", 0755, 1, "w", "私はガラスを食べられますdir_basic");
|
||||||
|
|
||||||
|
echo "Get Directory instance:\n";
|
||||||
|
$d = dir($dir_path);
|
||||||
|
var_dump( $d );
|
||||||
|
|
||||||
|
echo "\nRead and rewind:\n";
|
||||||
|
var_dump( $d->read() );
|
||||||
|
var_dump( $d->read() );
|
||||||
|
var_dump( $d->rewind() );
|
||||||
|
|
||||||
|
echo "\nTest using handle directly:\n";
|
||||||
|
var_dump( readdir($d->handle) );
|
||||||
|
var_dump( readdir($d->handle) );
|
||||||
|
|
||||||
|
echo "\nClose directory:\n";
|
||||||
|
var_dump( $d->close() );
|
||||||
|
var_dump( $d );
|
||||||
|
|
||||||
|
echo "\nTest read after closing the dir:";
|
||||||
|
var_dump( $d->read() );
|
||||||
|
|
||||||
|
// delete temp files
|
||||||
|
delete_files($dir_path, 3, "私はガラスを食べられますdir_basic", 1, ".tmp");
|
||||||
|
echo "Done";
|
||||||
|
?>
|
||||||
|
--CLEAN--
|
||||||
|
<?php
|
||||||
|
$file_path = dirname(__FILE__);
|
||||||
|
$dir_path = $file_path."/私はガラスを食べられますdir_basic";
|
||||||
|
|
||||||
|
rmdir($dir_path);
|
||||||
|
?>
|
||||||
|
--EXPECTF--
|
||||||
|
*** Testing dir() : basic functionality ***
|
||||||
|
Get Directory instance:
|
||||||
|
object(Directory)#%d (2) {
|
||||||
|
["path"]=>
|
||||||
|
string(%d) "%s/私はガラスを食べられますdir_basic"
|
||||||
|
["handle"]=>
|
||||||
|
resource(%d) of type (stream)
|
||||||
|
}
|
||||||
|
|
||||||
|
Read and rewind:
|
||||||
|
string(%d) "%s"
|
||||||
|
string(%d) "%s"
|
||||||
|
NULL
|
||||||
|
|
||||||
|
Test using handle directly:
|
||||||
|
string(%d) "%s"
|
||||||
|
string(%d) "%s"
|
||||||
|
|
||||||
|
Close directory:
|
||||||
|
NULL
|
||||||
|
object(Directory)#%d (2) {
|
||||||
|
["path"]=>
|
||||||
|
string(%d) "%s私はガラスを食べられますdir_basic"
|
||||||
|
["handle"]=>
|
||||||
|
resource(%d) of type (Unknown)
|
||||||
|
}
|
||||||
|
|
||||||
|
Test read after closing the dir:
|
||||||
|
Warning: Directory::read(): %s is not a valid Directory resource in %s on line %d
|
||||||
|
bool(false)
|
||||||
|
Done
|
223
ext/standard/tests/dir/dir_variation2-win32-mb.phpt
Normal file
223
ext/standard/tests/dir/dir_variation2-win32-mb.phpt
Normal file
|
@ -0,0 +1,223 @@
|
||||||
|
--TEST--
|
||||||
|
Test dir() function : usage variations - unexpected value for 'context' argument
|
||||||
|
--FILE--
|
||||||
|
<?php
|
||||||
|
/*
|
||||||
|
* Prototype : object dir(string $directory[, resource $context])
|
||||||
|
* Description: Directory class with properties, handle and class and methods read, rewind and close
|
||||||
|
* Source code: ext/standard/dir.c
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Passing non resource values to 'context' argument of dir() and see
|
||||||
|
* that the function outputs proper warning messages wherever expected.
|
||||||
|
*/
|
||||||
|
|
||||||
|
echo "*** Testing dir() : unexpected values for \$context argument ***\n";
|
||||||
|
|
||||||
|
// create the temporary directory
|
||||||
|
$file_path = dirname(__FILE__);
|
||||||
|
$directory = $file_path."/私はガラスを食べられますdir_variation2";
|
||||||
|
@mkdir($directory);
|
||||||
|
|
||||||
|
// get an unset variable
|
||||||
|
$unset_var = stream_context_create();
|
||||||
|
unset($unset_var);
|
||||||
|
|
||||||
|
class classA
|
||||||
|
{
|
||||||
|
public $var;
|
||||||
|
public function init() {
|
||||||
|
$this->var = 10;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// heredoc string
|
||||||
|
$heredoc = <<<EOT
|
||||||
|
hello world
|
||||||
|
EOT;
|
||||||
|
|
||||||
|
// unexpected values to be passed to $directory argument
|
||||||
|
$unexpected_values = array (
|
||||||
|
// int data
|
||||||
|
/*1*/ 0,
|
||||||
|
1,
|
||||||
|
12345,
|
||||||
|
-2345,
|
||||||
|
|
||||||
|
// float data
|
||||||
|
/*5*/ 10.5,
|
||||||
|
-10.5,
|
||||||
|
12.3456789000e10,
|
||||||
|
12.3456789000E-10,
|
||||||
|
.5,
|
||||||
|
|
||||||
|
// array data
|
||||||
|
/*10*/ array(),
|
||||||
|
array(0),
|
||||||
|
array(1),
|
||||||
|
array(1, 2),
|
||||||
|
array('color' => 'red', 'item' => 'pen'),
|
||||||
|
|
||||||
|
|
||||||
|
// null data
|
||||||
|
/*15*/ NULL,
|
||||||
|
null,
|
||||||
|
|
||||||
|
// boolean data
|
||||||
|
/*17*/ true,
|
||||||
|
false,
|
||||||
|
TRUE,
|
||||||
|
FALSE,
|
||||||
|
|
||||||
|
// empty data
|
||||||
|
/*21*/ "",
|
||||||
|
'',
|
||||||
|
|
||||||
|
// string data
|
||||||
|
/*23*/ "string",
|
||||||
|
'string',
|
||||||
|
$heredoc,
|
||||||
|
|
||||||
|
// object data
|
||||||
|
/*26*/ new classA(),
|
||||||
|
|
||||||
|
// undefined data
|
||||||
|
/*27*/ @$undefined_var,
|
||||||
|
|
||||||
|
// unset data
|
||||||
|
/*28*/ @$unset_var
|
||||||
|
);
|
||||||
|
|
||||||
|
// loop through various elements of $unexpected_values to check the behavior of dir()
|
||||||
|
$iterator = 1;
|
||||||
|
foreach( $unexpected_values as $unexpected_value ) {
|
||||||
|
echo "\n-- Iteration $iterator --";
|
||||||
|
var_dump( dir($directory, $unexpected_value) );
|
||||||
|
$iterator++;
|
||||||
|
}
|
||||||
|
|
||||||
|
echo "Done";
|
||||||
|
?>
|
||||||
|
--CLEAN--
|
||||||
|
<?php
|
||||||
|
$file_path = dirname(__FILE__);
|
||||||
|
$directory = $file_path."/私はガラスを食べられますdir_variation2";
|
||||||
|
|
||||||
|
rmdir($directory);
|
||||||
|
?>
|
||||||
|
--EXPECTF--
|
||||||
|
*** Testing dir() : unexpected values for $context argument ***
|
||||||
|
|
||||||
|
-- Iteration 1 --
|
||||||
|
Warning: dir() expects parameter 2 to be resource, integer given in %s on line %d
|
||||||
|
NULL
|
||||||
|
|
||||||
|
-- Iteration 2 --
|
||||||
|
Warning: dir() expects parameter 2 to be resource, integer given in %s on line %d
|
||||||
|
NULL
|
||||||
|
|
||||||
|
-- Iteration 3 --
|
||||||
|
Warning: dir() expects parameter 2 to be resource, integer given in %s on line %d
|
||||||
|
NULL
|
||||||
|
|
||||||
|
-- Iteration 4 --
|
||||||
|
Warning: dir() expects parameter 2 to be resource, integer given in %s on line %d
|
||||||
|
NULL
|
||||||
|
|
||||||
|
-- Iteration 5 --
|
||||||
|
Warning: dir() expects parameter 2 to be resource, float given in %s on line %d
|
||||||
|
NULL
|
||||||
|
|
||||||
|
-- Iteration 6 --
|
||||||
|
Warning: dir() expects parameter 2 to be resource, float given in %s on line %d
|
||||||
|
NULL
|
||||||
|
|
||||||
|
-- Iteration 7 --
|
||||||
|
Warning: dir() expects parameter 2 to be resource, float given in %s on line %d
|
||||||
|
NULL
|
||||||
|
|
||||||
|
-- Iteration 8 --
|
||||||
|
Warning: dir() expects parameter 2 to be resource, float given in %s on line %d
|
||||||
|
NULL
|
||||||
|
|
||||||
|
-- Iteration 9 --
|
||||||
|
Warning: dir() expects parameter 2 to be resource, float given in %s on line %d
|
||||||
|
NULL
|
||||||
|
|
||||||
|
-- Iteration 10 --
|
||||||
|
Warning: dir() expects parameter 2 to be resource, array given in %s on line %d
|
||||||
|
NULL
|
||||||
|
|
||||||
|
-- Iteration 11 --
|
||||||
|
Warning: dir() expects parameter 2 to be resource, array given in %s on line %d
|
||||||
|
NULL
|
||||||
|
|
||||||
|
-- Iteration 12 --
|
||||||
|
Warning: dir() expects parameter 2 to be resource, array given in %s on line %d
|
||||||
|
NULL
|
||||||
|
|
||||||
|
-- Iteration 13 --
|
||||||
|
Warning: dir() expects parameter 2 to be resource, array given in %s on line %d
|
||||||
|
NULL
|
||||||
|
|
||||||
|
-- Iteration 14 --
|
||||||
|
Warning: dir() expects parameter 2 to be resource, array given in %s on line %d
|
||||||
|
NULL
|
||||||
|
|
||||||
|
-- Iteration 15 --
|
||||||
|
Warning: dir() expects parameter 2 to be resource, null given in %s on line %d
|
||||||
|
NULL
|
||||||
|
|
||||||
|
-- Iteration 16 --
|
||||||
|
Warning: dir() expects parameter 2 to be resource, null given in %s on line %d
|
||||||
|
NULL
|
||||||
|
|
||||||
|
-- Iteration 17 --
|
||||||
|
Warning: dir() expects parameter 2 to be resource, boolean given in %s on line %d
|
||||||
|
NULL
|
||||||
|
|
||||||
|
-- Iteration 18 --
|
||||||
|
Warning: dir() expects parameter 2 to be resource, boolean given in %s on line %d
|
||||||
|
NULL
|
||||||
|
|
||||||
|
-- Iteration 19 --
|
||||||
|
Warning: dir() expects parameter 2 to be resource, boolean given in %s on line %d
|
||||||
|
NULL
|
||||||
|
|
||||||
|
-- Iteration 20 --
|
||||||
|
Warning: dir() expects parameter 2 to be resource, boolean given in %s on line %d
|
||||||
|
NULL
|
||||||
|
|
||||||
|
-- Iteration 21 --
|
||||||
|
Warning: dir() expects parameter 2 to be resource, string given in %s on line %d
|
||||||
|
NULL
|
||||||
|
|
||||||
|
-- Iteration 22 --
|
||||||
|
Warning: dir() expects parameter 2 to be resource, string given in %s on line %d
|
||||||
|
NULL
|
||||||
|
|
||||||
|
-- Iteration 23 --
|
||||||
|
Warning: dir() expects parameter 2 to be resource, string given in %s on line %d
|
||||||
|
NULL
|
||||||
|
|
||||||
|
-- Iteration 24 --
|
||||||
|
Warning: dir() expects parameter 2 to be resource, string given in %s on line %d
|
||||||
|
NULL
|
||||||
|
|
||||||
|
-- Iteration 25 --
|
||||||
|
Warning: dir() expects parameter 2 to be resource, string given in %s on line %d
|
||||||
|
NULL
|
||||||
|
|
||||||
|
-- Iteration 26 --
|
||||||
|
Warning: dir() expects parameter 2 to be resource, object given in %s on line %d
|
||||||
|
NULL
|
||||||
|
|
||||||
|
-- Iteration 27 --
|
||||||
|
Warning: dir() expects parameter 2 to be resource, null given in %s on line %d
|
||||||
|
NULL
|
||||||
|
|
||||||
|
-- Iteration 28 --
|
||||||
|
Warning: dir() expects parameter 2 to be resource, null given in %s on line %d
|
||||||
|
NULL
|
||||||
|
Done
|
72
ext/standard/tests/dir/dir_variation4-win32-mb.phpt
Normal file
72
ext/standard/tests/dir/dir_variation4-win32-mb.phpt
Normal file
|
@ -0,0 +1,72 @@
|
||||||
|
--TEST--
|
||||||
|
Test dir() function : usage variations - operate on previously opened directory
|
||||||
|
--FILE--
|
||||||
|
<?php
|
||||||
|
/*
|
||||||
|
* Prototype : object dir(string $directory[, resource $context])
|
||||||
|
* Description: Directory class with properties, handle and class and methods read, rewind and close
|
||||||
|
* Source code: ext/standard/dir.c
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Testing the behavior of dir() function by trying to open a
|
||||||
|
* directory which is already open.
|
||||||
|
*/
|
||||||
|
|
||||||
|
echo "*** Testing dir() : operate on previously opened directory ***\n";
|
||||||
|
|
||||||
|
// include the file.inc for Function: function create_files()
|
||||||
|
include( dirname(__FILE__)."/../file/file.inc");
|
||||||
|
|
||||||
|
// create the temporary directory
|
||||||
|
$file_path = dirname(__FILE__);
|
||||||
|
$dir_path = $file_path."/私はガラスを食べられますdir_variation4";
|
||||||
|
@mkdir($dir_path);
|
||||||
|
|
||||||
|
// create files within the temporary directory
|
||||||
|
create_files($dir_path, 3, "alphanumeric", 0755, 1, "w", "私はガラスを食べられますdir_variation4");
|
||||||
|
|
||||||
|
// open the directory
|
||||||
|
$d = dir($dir_path);
|
||||||
|
var_dump( $d );
|
||||||
|
|
||||||
|
// open the same directory again without closing it
|
||||||
|
$e = dir($dir_path);
|
||||||
|
var_dump( $e );
|
||||||
|
|
||||||
|
echo "-- reading directory contents with previous handle --\n";
|
||||||
|
var_dump( $d->read() ); // with previous handle
|
||||||
|
|
||||||
|
echo "-- reading directory contents with current handle --\n";
|
||||||
|
var_dump( $e->read() ); // with current handle
|
||||||
|
|
||||||
|
// delete temporary files
|
||||||
|
delete_files($dir_path, 3, "私はガラスを食べられますdir_variation4");
|
||||||
|
echo "Done";
|
||||||
|
?>
|
||||||
|
--CLEAN--
|
||||||
|
<?php
|
||||||
|
$file_path = dirname(__FILE__);
|
||||||
|
$dir_path = $file_path."/私はガラスを食べられますdir_variation4";
|
||||||
|
|
||||||
|
rmdir($dir_path);
|
||||||
|
?>
|
||||||
|
--EXPECTF--
|
||||||
|
*** Testing dir() : operate on previously opened directory ***
|
||||||
|
object(Directory)#%d (2) {
|
||||||
|
["path"]=>
|
||||||
|
string(%d) "%s/私はガラスを食べられますdir_variation4"
|
||||||
|
["handle"]=>
|
||||||
|
resource(%d) of type (stream)
|
||||||
|
}
|
||||||
|
object(Directory)#%d (2) {
|
||||||
|
["path"]=>
|
||||||
|
string(%d) "%s/私はガラスを食べられますdir_variation4"
|
||||||
|
["handle"]=>
|
||||||
|
resource(%d) of type (stream)
|
||||||
|
}
|
||||||
|
-- reading directory contents with previous handle --
|
||||||
|
string(%d) "%s"
|
||||||
|
-- reading directory contents with current handle --
|
||||||
|
string(%d) "%s"
|
||||||
|
Done
|
34
ext/standard/tests/dir/getcwd_basic-win32-mb.phpt
Normal file
34
ext/standard/tests/dir/getcwd_basic-win32-mb.phpt
Normal file
|
@ -0,0 +1,34 @@
|
||||||
|
--TEST--
|
||||||
|
Test getcwd() function : basic functionality
|
||||||
|
--FILE--
|
||||||
|
<?php
|
||||||
|
/* Prototype : mixed getcwd(void)
|
||||||
|
* Description: Gets the current directory
|
||||||
|
* Source code: ext/standard/dir.c
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Test basic functionality of getcwd()
|
||||||
|
*/
|
||||||
|
|
||||||
|
echo "*** Testing getcwd() : basic functionality ***\n";
|
||||||
|
|
||||||
|
//create temporary directory for test, removed in CLEAN section
|
||||||
|
$directory = dirname(__FILE__) . "/私はガラスを食べられますgetcwd_basic";
|
||||||
|
mkdir($directory);
|
||||||
|
|
||||||
|
var_dump(getcwd());
|
||||||
|
chdir($directory);
|
||||||
|
var_dump(getcwd());
|
||||||
|
?>
|
||||||
|
===DONE===
|
||||||
|
--CLEAN--
|
||||||
|
<?php
|
||||||
|
$directory = dirname(__FILE__) . "/私はガラスを食べられますgetcwd_basic";
|
||||||
|
rmdir($directory);
|
||||||
|
?>
|
||||||
|
--EXPECTF--
|
||||||
|
*** Testing getcwd() : basic functionality ***
|
||||||
|
string(%d) "%s"
|
||||||
|
string(%d) "%s%e私はガラスを食べられますgetcwd_basic"
|
||||||
|
===DONE===
|
62
ext/standard/tests/dir/opendir_basic-win32-mb.phpt
Normal file
62
ext/standard/tests/dir/opendir_basic-win32-mb.phpt
Normal file
|
@ -0,0 +1,62 @@
|
||||||
|
--TEST--
|
||||||
|
Test opendir() function : basic functionality
|
||||||
|
--FILE--
|
||||||
|
<?php
|
||||||
|
/* Prototype : mixed opendir(string $path[, resource $context])
|
||||||
|
* Description: Open a directory and return a dir_handle
|
||||||
|
* Source code: ext/standard/dir.c
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Test basic functionality of opendir() with absolute and relative paths as $path argument
|
||||||
|
*/
|
||||||
|
|
||||||
|
echo "*** Testing opendir() : basic functionality ***\n";
|
||||||
|
|
||||||
|
$base_dir_path = dirname(__FILE__);
|
||||||
|
|
||||||
|
$level_one_dir_name = "私はガラスを食べられますlevel_one";
|
||||||
|
$level_one_dir_path = "$base_dir_path/$level_one_dir_name";
|
||||||
|
|
||||||
|
$level_two_dir_name = "私はガラスを食べられますlevel_two";
|
||||||
|
$level_two_dir_path = "$base_dir_path/$level_one_dir_name/$level_two_dir_name";
|
||||||
|
|
||||||
|
// create temporary directories - will remove in CLEAN section
|
||||||
|
mkdir($level_one_dir_path);
|
||||||
|
mkdir($level_two_dir_path);
|
||||||
|
|
||||||
|
echo "\n-- Testing opendir() with absolute path: --\n";
|
||||||
|
var_dump($dh1 = opendir($level_one_dir_path));
|
||||||
|
|
||||||
|
|
||||||
|
echo "\n-- Testing opendir() with relative paths: --\n";
|
||||||
|
var_dump(chdir($level_one_dir_path));
|
||||||
|
var_dump($dh2 = opendir($level_two_dir_name));
|
||||||
|
|
||||||
|
echo "\n-- Close directory handles: --\n";
|
||||||
|
closedir($dh1);
|
||||||
|
var_dump($dh1);
|
||||||
|
closedir($dh2);
|
||||||
|
var_dump($dh2);
|
||||||
|
?>
|
||||||
|
===DONE===
|
||||||
|
--CLEAN--
|
||||||
|
<?php
|
||||||
|
$file_path = dirname(__FILE__);
|
||||||
|
rmdir("$file_path/私はガラスを食べられますlevel_one/私はガラスを食べられますlevel_two");
|
||||||
|
rmdir("$file_path/私はガラスを食べられますlevel_one");
|
||||||
|
?>
|
||||||
|
--EXPECTF--
|
||||||
|
*** Testing opendir() : basic functionality ***
|
||||||
|
|
||||||
|
-- Testing opendir() with absolute path: --
|
||||||
|
resource(%d) of type (stream)
|
||||||
|
|
||||||
|
-- Testing opendir() with relative paths: --
|
||||||
|
bool(true)
|
||||||
|
resource(%d) of type (stream)
|
||||||
|
|
||||||
|
-- Close directory handles: --
|
||||||
|
resource(%d) of type (Unknown)
|
||||||
|
resource(%d) of type (Unknown)
|
||||||
|
===DONE===
|
47
ext/standard/tests/dir/opendir_error1-win32-mb.phpt
Normal file
47
ext/standard/tests/dir/opendir_error1-win32-mb.phpt
Normal file
|
@ -0,0 +1,47 @@
|
||||||
|
--TEST--
|
||||||
|
Test opendir() function : error conditions - Incorrect number of args
|
||||||
|
--FILE--
|
||||||
|
<?php
|
||||||
|
/* Prototype : mixed opendir(string $path[, resource $context])
|
||||||
|
* Description: Open a directory and return a dir_handle
|
||||||
|
* Source code: ext/standard/dir.c
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Pass incorrect number of arguments to opendir() to test behaviour
|
||||||
|
*/
|
||||||
|
|
||||||
|
echo "*** Testing opendir() : error conditions ***\n";
|
||||||
|
|
||||||
|
// Zero arguments
|
||||||
|
echo "\n-- Testing opendir() function with Zero arguments --\n";
|
||||||
|
var_dump( opendir() );
|
||||||
|
|
||||||
|
//Test opendir with one more than the expected number of arguments
|
||||||
|
echo "\n-- Testing opendir() function with more than expected no. of arguments --\n";
|
||||||
|
$path = dirname(__FILE__) . "/私はガラスを食べられますopendir_error";
|
||||||
|
mkdir($path);
|
||||||
|
$context = stream_context_create();
|
||||||
|
|
||||||
|
$extra_arg = 10;
|
||||||
|
var_dump( opendir($path, $context, $extra_arg) );
|
||||||
|
?>
|
||||||
|
===DONE===
|
||||||
|
--CLEAN--
|
||||||
|
<?php
|
||||||
|
$path = dirname(__FILE__) . "/私はガラスを食べられますopendir_error";
|
||||||
|
rmdir($path);
|
||||||
|
?>
|
||||||
|
--EXPECTF--
|
||||||
|
*** Testing opendir() : error conditions ***
|
||||||
|
|
||||||
|
-- Testing opendir() function with Zero arguments --
|
||||||
|
|
||||||
|
Warning: opendir() expects at least 1 parameter, 0 given in %s on line %d
|
||||||
|
NULL
|
||||||
|
|
||||||
|
-- Testing opendir() function with more than expected no. of arguments --
|
||||||
|
|
||||||
|
Warning: opendir() expects at most 2 parameters, 3 given in %s on line %d
|
||||||
|
NULL
|
||||||
|
===DONE===
|
239
ext/standard/tests/dir/opendir_variation2-win32-mb.phpt
Normal file
239
ext/standard/tests/dir/opendir_variation2-win32-mb.phpt
Normal file
|
@ -0,0 +1,239 @@
|
||||||
|
--TEST--
|
||||||
|
Test opendir() function : usage variations - different data types as $context arg
|
||||||
|
--FILE--
|
||||||
|
<?php
|
||||||
|
/* Prototype : mixed opendir(string $path[, resource $context])
|
||||||
|
* Description: Open a directory and return a dir_handle
|
||||||
|
* Source code: ext/standard/dir.c
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Pass different data types as $context argument to opendir() to test behaviour
|
||||||
|
*/
|
||||||
|
|
||||||
|
echo "*** Testing opendir() : usage variation ***\n";
|
||||||
|
|
||||||
|
|
||||||
|
// Initialise function arguments not being substituted (if any)
|
||||||
|
// create temporary directory for test, removed in CLEAN section
|
||||||
|
$path = dirname(__FILE__) . "/私はガラスを食べられますopendir_variation2";
|
||||||
|
mkdir($path);
|
||||||
|
|
||||||
|
|
||||||
|
//get an unset variable
|
||||||
|
$unset_var = 10;
|
||||||
|
unset ($unset_var);
|
||||||
|
|
||||||
|
// get a class
|
||||||
|
class classA
|
||||||
|
{
|
||||||
|
public function __toString()
|
||||||
|
{
|
||||||
|
return "Class A object";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// heredoc string
|
||||||
|
$heredoc = <<<EOT
|
||||||
|
hello world
|
||||||
|
EOT;
|
||||||
|
|
||||||
|
// get a resource variable
|
||||||
|
$fp = fopen(__FILE__, "r");
|
||||||
|
|
||||||
|
// unexpected values to be passed to $context argument
|
||||||
|
$inputs = array(
|
||||||
|
|
||||||
|
// int data
|
||||||
|
/*1*/ 0,
|
||||||
|
1,
|
||||||
|
12345,
|
||||||
|
-2345,
|
||||||
|
|
||||||
|
// float data
|
||||||
|
/*5*/ 10.5,
|
||||||
|
-10.5,
|
||||||
|
12.3456789000e10,
|
||||||
|
12.3456789000E-10,
|
||||||
|
.5,
|
||||||
|
|
||||||
|
// null data
|
||||||
|
/*10*/ NULL,
|
||||||
|
null,
|
||||||
|
|
||||||
|
// boolean data
|
||||||
|
/*12*/ true,
|
||||||
|
false,
|
||||||
|
TRUE,
|
||||||
|
FALSE,
|
||||||
|
|
||||||
|
// empty data
|
||||||
|
/*16*/ "",
|
||||||
|
'',
|
||||||
|
array(),
|
||||||
|
|
||||||
|
// string data
|
||||||
|
/*19*/ "string",
|
||||||
|
'string',
|
||||||
|
$heredoc,
|
||||||
|
|
||||||
|
// object data
|
||||||
|
/*22*/ new classA(),
|
||||||
|
|
||||||
|
// undefined data
|
||||||
|
/*23*/ @$undefined_var,
|
||||||
|
|
||||||
|
// unset data
|
||||||
|
/*24*/ @$unset_var,
|
||||||
|
|
||||||
|
// resource variable
|
||||||
|
/*25*/ $fp
|
||||||
|
);
|
||||||
|
|
||||||
|
// loop through each element of $inputs to check the behavior of opendir()
|
||||||
|
$iterator = 1;
|
||||||
|
foreach($inputs as $input) {
|
||||||
|
echo "\n-- Iteration $iterator --\n";
|
||||||
|
var_dump($dh = opendir($path, $input) );#
|
||||||
|
if ($dh) {
|
||||||
|
closedir($dh);
|
||||||
|
}
|
||||||
|
$iterator++;
|
||||||
|
};
|
||||||
|
|
||||||
|
fclose($fp);
|
||||||
|
?>
|
||||||
|
===DONE===
|
||||||
|
--CLEAN--
|
||||||
|
<?php
|
||||||
|
$path = dirname(__FILE__) . "/私はガラスを食べられますopendir_variation2";
|
||||||
|
rmdir($path);
|
||||||
|
?>
|
||||||
|
--EXPECTF--
|
||||||
|
*** Testing opendir() : usage variation ***
|
||||||
|
|
||||||
|
-- Iteration 1 --
|
||||||
|
|
||||||
|
Warning: opendir() expects parameter 2 to be resource, integer given in %s on line %d
|
||||||
|
NULL
|
||||||
|
|
||||||
|
-- Iteration 2 --
|
||||||
|
|
||||||
|
Warning: opendir() expects parameter 2 to be resource, integer given in %s on line %d
|
||||||
|
NULL
|
||||||
|
|
||||||
|
-- Iteration 3 --
|
||||||
|
|
||||||
|
Warning: opendir() expects parameter 2 to be resource, integer given in %s on line %d
|
||||||
|
NULL
|
||||||
|
|
||||||
|
-- Iteration 4 --
|
||||||
|
|
||||||
|
Warning: opendir() expects parameter 2 to be resource, integer given in %s on line %d
|
||||||
|
NULL
|
||||||
|
|
||||||
|
-- Iteration 5 --
|
||||||
|
|
||||||
|
Warning: opendir() expects parameter 2 to be resource, float given in %s on line %d
|
||||||
|
NULL
|
||||||
|
|
||||||
|
-- Iteration 6 --
|
||||||
|
|
||||||
|
Warning: opendir() expects parameter 2 to be resource, float given in %s on line %d
|
||||||
|
NULL
|
||||||
|
|
||||||
|
-- Iteration 7 --
|
||||||
|
|
||||||
|
Warning: opendir() expects parameter 2 to be resource, float given in %s on line %d
|
||||||
|
NULL
|
||||||
|
|
||||||
|
-- Iteration 8 --
|
||||||
|
|
||||||
|
Warning: opendir() expects parameter 2 to be resource, float given in %s on line %d
|
||||||
|
NULL
|
||||||
|
|
||||||
|
-- Iteration 9 --
|
||||||
|
|
||||||
|
Warning: opendir() expects parameter 2 to be resource, float given in %s on line %d
|
||||||
|
NULL
|
||||||
|
|
||||||
|
-- Iteration 10 --
|
||||||
|
|
||||||
|
Warning: opendir() expects parameter 2 to be resource, null given in %s on line %d
|
||||||
|
NULL
|
||||||
|
|
||||||
|
-- Iteration 11 --
|
||||||
|
|
||||||
|
Warning: opendir() expects parameter 2 to be resource, null given in %s on line %d
|
||||||
|
NULL
|
||||||
|
|
||||||
|
-- Iteration 12 --
|
||||||
|
|
||||||
|
Warning: opendir() expects parameter 2 to be resource, boolean given in %s on line %d
|
||||||
|
NULL
|
||||||
|
|
||||||
|
-- Iteration 13 --
|
||||||
|
|
||||||
|
Warning: opendir() expects parameter 2 to be resource, boolean given in %s on line %d
|
||||||
|
NULL
|
||||||
|
|
||||||
|
-- Iteration 14 --
|
||||||
|
|
||||||
|
Warning: opendir() expects parameter 2 to be resource, boolean given in %s on line %d
|
||||||
|
NULL
|
||||||
|
|
||||||
|
-- Iteration 15 --
|
||||||
|
|
||||||
|
Warning: opendir() expects parameter 2 to be resource, boolean given in %s on line %d
|
||||||
|
NULL
|
||||||
|
|
||||||
|
-- Iteration 16 --
|
||||||
|
|
||||||
|
Warning: opendir() expects parameter 2 to be resource, string given in %s on line %d
|
||||||
|
NULL
|
||||||
|
|
||||||
|
-- Iteration 17 --
|
||||||
|
|
||||||
|
Warning: opendir() expects parameter 2 to be resource, string given in %s on line %d
|
||||||
|
NULL
|
||||||
|
|
||||||
|
-- Iteration 18 --
|
||||||
|
|
||||||
|
Warning: opendir() expects parameter 2 to be resource, array given in %s on line %d
|
||||||
|
NULL
|
||||||
|
|
||||||
|
-- Iteration 19 --
|
||||||
|
|
||||||
|
Warning: opendir() expects parameter 2 to be resource, string given in %s on line %d
|
||||||
|
NULL
|
||||||
|
|
||||||
|
-- Iteration 20 --
|
||||||
|
|
||||||
|
Warning: opendir() expects parameter 2 to be resource, string given in %s on line %d
|
||||||
|
NULL
|
||||||
|
|
||||||
|
-- Iteration 21 --
|
||||||
|
|
||||||
|
Warning: opendir() expects parameter 2 to be resource, string given in %s on line %d
|
||||||
|
NULL
|
||||||
|
|
||||||
|
-- Iteration 22 --
|
||||||
|
|
||||||
|
Warning: opendir() expects parameter 2 to be resource, object given in %s on line %d
|
||||||
|
NULL
|
||||||
|
|
||||||
|
-- Iteration 23 --
|
||||||
|
|
||||||
|
Warning: opendir() expects parameter 2 to be resource, null given in %s on line %d
|
||||||
|
NULL
|
||||||
|
|
||||||
|
-- Iteration 24 --
|
||||||
|
|
||||||
|
Warning: opendir() expects parameter 2 to be resource, null given in %s on line %d
|
||||||
|
NULL
|
||||||
|
|
||||||
|
-- Iteration 25 --
|
||||||
|
|
||||||
|
Warning: opendir(): supplied resource is not a valid Stream-Context resource in %s on line %d
|
||||||
|
resource(%d) of type (stream)
|
||||||
|
===DONE===
|
50
ext/standard/tests/dir/opendir_variation3-win32-mb.phpt
Normal file
50
ext/standard/tests/dir/opendir_variation3-win32-mb.phpt
Normal file
|
@ -0,0 +1,50 @@
|
||||||
|
--TEST--
|
||||||
|
Test opendir() function : usage variations - open a directory twice
|
||||||
|
--FILE--
|
||||||
|
<?php
|
||||||
|
/* Prototype : mixed opendir(string $path[, resource $context])
|
||||||
|
* Description: Open a directory and return a dir_handle
|
||||||
|
* Source code: ext/standard/dir.c
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Call opendir() twice with the same directory as $path argument
|
||||||
|
*/
|
||||||
|
|
||||||
|
echo "*** Testing opendir() : usage variation ***\n";
|
||||||
|
|
||||||
|
$path = dirname(__FILE__) . "/私はガラスを食べられますopendir_variation3";
|
||||||
|
mkdir($path);
|
||||||
|
|
||||||
|
echo "\n-- Open directory first time: --\n";
|
||||||
|
var_dump($dh1 = opendir($path));
|
||||||
|
|
||||||
|
echo "\n-- Open directory second time: --\n";
|
||||||
|
var_dump($dh2 = opendir($path));
|
||||||
|
|
||||||
|
if ($dh1 !== $dh2) {
|
||||||
|
echo "\nNew resource created\n";
|
||||||
|
} else {
|
||||||
|
echo "\nNo new resource created\n";
|
||||||
|
}
|
||||||
|
|
||||||
|
closedir($dh1);
|
||||||
|
closedir($dh2);
|
||||||
|
?>
|
||||||
|
===DONE===
|
||||||
|
--CLEAN--
|
||||||
|
<?php
|
||||||
|
$path = dirname(__FILE__) . "/私はガラスを食べられますopendir_variation3";
|
||||||
|
rmdir($path);
|
||||||
|
?>
|
||||||
|
--EXPECTF--
|
||||||
|
*** Testing opendir() : usage variation ***
|
||||||
|
|
||||||
|
-- Open directory first time: --
|
||||||
|
resource(%d) of type (stream)
|
||||||
|
|
||||||
|
-- Open directory second time: --
|
||||||
|
resource(%d) of type (stream)
|
||||||
|
|
||||||
|
New resource created
|
||||||
|
===DONE===
|
107
ext/standard/tests/dir/opendir_variation4-win32-mb.phpt
Normal file
107
ext/standard/tests/dir/opendir_variation4-win32-mb.phpt
Normal file
|
@ -0,0 +1,107 @@
|
||||||
|
--TEST--
|
||||||
|
Test opendir() function : usage variations - different relative paths
|
||||||
|
--FILE--
|
||||||
|
<?php
|
||||||
|
/* Prototype : mixed opendir(string $path[, resource $context])
|
||||||
|
* Description: Open a directory and return a dir_handle
|
||||||
|
* Source code: ext/standard/dir.c
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Test opendir() with different relative paths as $path argument
|
||||||
|
*/
|
||||||
|
|
||||||
|
echo "*** Testing opendir() : usage variation ***\n";
|
||||||
|
|
||||||
|
$base_dir_path = dirname(__FILE__);
|
||||||
|
|
||||||
|
$level_one_dir_name = "私はガラスを食べられますlevel_one";
|
||||||
|
$level_one_dir_path = "$base_dir_path/$level_one_dir_name";
|
||||||
|
|
||||||
|
$level_two_dir_name = "私はガラスを食べられますlevel_two";
|
||||||
|
$level_two_dir_path = "$base_dir_path/$level_one_dir_name/$level_two_dir_name";
|
||||||
|
|
||||||
|
// create directories
|
||||||
|
mkdir($level_one_dir_path);
|
||||||
|
mkdir($level_two_dir_path);
|
||||||
|
|
||||||
|
echo "\n-- \$path = './私はガラスを食べられますlevel_one': --\n";
|
||||||
|
var_dump(chdir($base_dir_path));
|
||||||
|
var_dump($dh = opendir("./$level_one_dir_name"));
|
||||||
|
clean_dh($dh);
|
||||||
|
|
||||||
|
echo "\n-- \$path = '私はガラスを食べられますlevel_one/私はガラスを食べられますlevel_two': --\n";
|
||||||
|
var_dump(chdir($base_dir_path));
|
||||||
|
var_dump($dh = opendir("$level_one_dir_name/$level_two_dir_name"));
|
||||||
|
clean_dh($dh);
|
||||||
|
|
||||||
|
echo "\n-- \$path = '..': --\n";
|
||||||
|
var_dump($dh = opendir('..'));
|
||||||
|
clean_dh($dh);
|
||||||
|
|
||||||
|
echo "\n-- \$path = 'level_two', '.': --\n";
|
||||||
|
var_dump(chdir($level_two_dir_path));
|
||||||
|
var_dump($dh = opendir('.'));
|
||||||
|
clean_dh($dh);
|
||||||
|
|
||||||
|
echo "\n-- \$path = '../': --\n";
|
||||||
|
var_dump($dh = opendir('../'));
|
||||||
|
clean_dh($dh);
|
||||||
|
|
||||||
|
echo "\n-- \$path = './': --\n";
|
||||||
|
var_dump(chdir($level_two_dir_path));
|
||||||
|
var_dump($dh = opendir('./'));
|
||||||
|
clean_dh($dh);
|
||||||
|
|
||||||
|
echo "\n-- \$path = '../../'私はガラスを食べられますlevel_one': --\n";
|
||||||
|
var_dump(chdir($level_two_dir_path));
|
||||||
|
var_dump($dh = opendir("../../$level_one_dir_name"));
|
||||||
|
clean_dh($dh);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* function to remove directory handle before re-using variable name in test
|
||||||
|
* and to ensure directory is not in use at CLEAN section so can me removed
|
||||||
|
*/
|
||||||
|
function clean_dh($dh){
|
||||||
|
if (is_resource($dh)) {
|
||||||
|
closedir($dh);
|
||||||
|
}
|
||||||
|
unset($dh);
|
||||||
|
}
|
||||||
|
?>
|
||||||
|
===DONE===
|
||||||
|
--CLEAN--
|
||||||
|
<?php
|
||||||
|
$file_path = dirname(__FILE__);
|
||||||
|
rmdir("$file_path/私はガラスを食べられますlevel_one/私はガラスを食べられますlevel_two");
|
||||||
|
rmdir("$file_path/私はガラスを食べられますlevel_one");
|
||||||
|
?>
|
||||||
|
--EXPECTF--
|
||||||
|
*** Testing opendir() : usage variation ***
|
||||||
|
|
||||||
|
-- $path = './私はガラスを食べられますlevel_one': --
|
||||||
|
bool(true)
|
||||||
|
resource(%d) of type (stream)
|
||||||
|
|
||||||
|
-- $path = '私はガラスを食べられますlevel_one/私はガラスを食べられますlevel_two': --
|
||||||
|
bool(true)
|
||||||
|
resource(%d) of type (stream)
|
||||||
|
|
||||||
|
-- $path = '..': --
|
||||||
|
resource(%d) of type (stream)
|
||||||
|
|
||||||
|
-- $path = 'level_two', '.': --
|
||||||
|
bool(true)
|
||||||
|
resource(%d) of type (stream)
|
||||||
|
|
||||||
|
-- $path = '../': --
|
||||||
|
resource(%d) of type (stream)
|
||||||
|
|
||||||
|
-- $path = './': --
|
||||||
|
bool(true)
|
||||||
|
resource(%d) of type (stream)
|
||||||
|
|
||||||
|
-- $path = '../../'私はガラスを食べられますlevel_one': --
|
||||||
|
bool(true)
|
||||||
|
resource(%d) of type (stream)
|
||||||
|
===DONE===
|
75
ext/standard/tests/dir/opendir_variation6-win32-mb.phpt
Normal file
75
ext/standard/tests/dir/opendir_variation6-win32-mb.phpt
Normal file
|
@ -0,0 +1,75 @@
|
||||||
|
--TEST--
|
||||||
|
Test opendir() function : usage variations - Different wildcards
|
||||||
|
--SKIPIF--
|
||||||
|
<?php
|
||||||
|
if (substr(PHP_OS, 0, 3) != 'WIN') {
|
||||||
|
die("skip Valid only on Windows");
|
||||||
|
}
|
||||||
|
?>
|
||||||
|
--FILE--
|
||||||
|
<?php
|
||||||
|
/* Prototype : mixed opendir(string $path[, resource $context])
|
||||||
|
* Description: Open a directory and return a dir_handle
|
||||||
|
* Source code: ext/standard/dir.c
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Pass paths containing wildcards to test if opendir() recognises them
|
||||||
|
*/
|
||||||
|
|
||||||
|
echo "*** Testing opendir() : usage variations ***\n";
|
||||||
|
// create the temporary directories
|
||||||
|
$file_path = dirname(__FILE__);
|
||||||
|
$dir_path = $file_path . "/opendir_variation6";
|
||||||
|
$sub_dir_path = $dir_path . "/sub_dir1";
|
||||||
|
|
||||||
|
mkdir($dir_path);
|
||||||
|
mkdir($sub_dir_path);
|
||||||
|
|
||||||
|
// with different wildcard characters
|
||||||
|
|
||||||
|
echo "\n-- Wildcard = '*' --\n";
|
||||||
|
var_dump( opendir($file_path . "/opendir_var*") );
|
||||||
|
var_dump( opendir($file_path . "/*") );
|
||||||
|
|
||||||
|
echo "\n-- Wildcard = '?' --\n";
|
||||||
|
var_dump( opendir($dir_path . "/sub_dir?") );
|
||||||
|
var_dump( opendir($dir_path . "/sub?dir1") );
|
||||||
|
|
||||||
|
?>
|
||||||
|
===DONE===
|
||||||
|
--CLEAN--
|
||||||
|
<?php
|
||||||
|
$dir_path = dirname(__FILE__) . "/opendir_variation6";
|
||||||
|
$sub_dir_path = $dir_path . "/sub_dir1";
|
||||||
|
|
||||||
|
rmdir($sub_dir_path);
|
||||||
|
rmdir($dir_path);
|
||||||
|
?>
|
||||||
|
--EXPECTF--
|
||||||
|
*** Testing opendir() : usage variations ***
|
||||||
|
|
||||||
|
-- Wildcard = '*' --
|
||||||
|
|
||||||
|
Warning: opendir(%s/opendir_var*,%s/opendir_var*): %s in %s on line %d
|
||||||
|
|
||||||
|
Warning: opendir(%s/opendir_var*): failed to open dir: %s in %s on line %d
|
||||||
|
bool(false)
|
||||||
|
|
||||||
|
Warning: opendir(%s/*,%s/*): %s in %s on line %d
|
||||||
|
|
||||||
|
Warning: opendir(%s/*): failed to open dir: %s in %s on line %d
|
||||||
|
bool(false)
|
||||||
|
|
||||||
|
-- Wildcard = '?' --
|
||||||
|
|
||||||
|
Warning: opendir(%s/opendir_variation6/sub_dir?,%s/opendir_variation6/sub_dir?): %s in %s on line %d
|
||||||
|
|
||||||
|
Warning: opendir(%s/opendir_variation6/sub_dir?): failed to open dir: %s in %s on line %d
|
||||||
|
bool(false)
|
||||||
|
|
||||||
|
Warning: opendir(%s/opendir_variation6/sub?dir1,%s/opendir_variation6/sub?dir1): %s in %s on line %d
|
||||||
|
|
||||||
|
Warning: opendir(%s/opendir_variation6/sub?dir1): failed to open dir: %s in %s on line %d
|
||||||
|
bool(false)
|
||||||
|
===DONE===
|
73
ext/standard/tests/dir/readdir_basic-win32-mb.phpt
Normal file
73
ext/standard/tests/dir/readdir_basic-win32-mb.phpt
Normal file
|
@ -0,0 +1,73 @@
|
||||||
|
--TEST--
|
||||||
|
Test readdir() function : basic functionality
|
||||||
|
--FILE--
|
||||||
|
<?php
|
||||||
|
/* Prototype : string readdir([resource $dir_handle])
|
||||||
|
* Description: Read directory entry from dir_handle
|
||||||
|
* Source code: ext/standard/dir.C
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Test basic functionality of readdir()
|
||||||
|
*/
|
||||||
|
|
||||||
|
echo "*** Testing readdir() : basic functionality ***\n";
|
||||||
|
|
||||||
|
// include the file.inc for Function: function create_files()
|
||||||
|
chdir(dirname(__FILE__));
|
||||||
|
include(dirname(__FILE__)."/../file/file.inc");
|
||||||
|
|
||||||
|
$path = dirname(__FILE__) . '/私はガラスを食べられますreaddir_basic';
|
||||||
|
mkdir($path);
|
||||||
|
create_files($path, 3);
|
||||||
|
|
||||||
|
echo "\n-- Call readdir() with \$path argument --\n";
|
||||||
|
var_dump($dh = opendir($path));
|
||||||
|
$a = array();
|
||||||
|
while( FALSE !== ($file = readdir($dh)) ) {
|
||||||
|
$a[] = $file;
|
||||||
|
}
|
||||||
|
sort($a);
|
||||||
|
foreach($a as $file) {
|
||||||
|
var_dump($file);
|
||||||
|
}
|
||||||
|
|
||||||
|
echo "\n-- Call readdir() without \$path argument --\n";
|
||||||
|
var_dump($dh = opendir($path));
|
||||||
|
$a = array();
|
||||||
|
while( FALSE !== ( $file = readdir() ) ) {
|
||||||
|
$a[] = $file;
|
||||||
|
}
|
||||||
|
sort($a);
|
||||||
|
foreach($a as $file) {
|
||||||
|
var_dump($file);
|
||||||
|
}
|
||||||
|
|
||||||
|
delete_files($path, 3);
|
||||||
|
closedir($dh);
|
||||||
|
?>
|
||||||
|
===DONE===
|
||||||
|
--CLEAN--
|
||||||
|
<?php
|
||||||
|
$path = dirname(__FILE__) . '/私はガラスを食べられますreaddir_basic';
|
||||||
|
rmdir($path);
|
||||||
|
?>
|
||||||
|
--EXPECTF--
|
||||||
|
*** Testing readdir() : basic functionality ***
|
||||||
|
|
||||||
|
-- Call readdir() with $path argument --
|
||||||
|
resource(%d) of type (stream)
|
||||||
|
string(1) "."
|
||||||
|
string(2) ".."
|
||||||
|
string(9) "file1.tmp"
|
||||||
|
string(9) "file2.tmp"
|
||||||
|
string(9) "file3.tmp"
|
||||||
|
|
||||||
|
-- Call readdir() without $path argument --
|
||||||
|
resource(%d) of type (stream)
|
||||||
|
string(1) "."
|
||||||
|
string(2) ".."
|
||||||
|
string(9) "file1.tmp"
|
||||||
|
string(9) "file2.tmp"
|
||||||
|
string(9) "file3.tmp"
|
||||||
|
===DONE===
|
43
ext/standard/tests/dir/readdir_error-win32-mb.phpt
Normal file
43
ext/standard/tests/dir/readdir_error-win32-mb.phpt
Normal file
|
@ -0,0 +1,43 @@
|
||||||
|
--TEST--
|
||||||
|
Test readdir() function : error conditions - Incorrect number of args
|
||||||
|
--FILE--
|
||||||
|
<?php
|
||||||
|
/* Prototype : string readdir([resource $dir_handle])
|
||||||
|
* Description: Read directory entry from dir_handle
|
||||||
|
* Source code: ext/standard/dir.c
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Pass incorrect number of arguments to readdir() to test behaviour
|
||||||
|
*/
|
||||||
|
|
||||||
|
echo "*** Testing readdir() : error conditions ***\n";
|
||||||
|
|
||||||
|
|
||||||
|
//Test readdir with one more than the expected number of arguments
|
||||||
|
echo "\n-- Testing readdir() function with more than expected no. of arguments --\n";
|
||||||
|
|
||||||
|
$path = dirname(__FILE__) . "/私はガラスを食べられますreaddir_error";
|
||||||
|
mkdir($path);
|
||||||
|
$dir_handle = opendir($path);
|
||||||
|
$extra_arg = 10;
|
||||||
|
|
||||||
|
var_dump( readdir($dir_handle, $extra_arg) );
|
||||||
|
|
||||||
|
// close the handle so can remove dir in CLEAN section
|
||||||
|
closedir($dir_handle);
|
||||||
|
?>
|
||||||
|
===DONE===
|
||||||
|
--CLEAN--
|
||||||
|
<?php
|
||||||
|
$path = dirname(__FILE__) . "/私はガラスを食べられますreaddir_error";
|
||||||
|
rmdir($path);
|
||||||
|
?>
|
||||||
|
--EXPECTF--
|
||||||
|
*** Testing readdir() : error conditions ***
|
||||||
|
|
||||||
|
-- Testing readdir() function with more than expected no. of arguments --
|
||||||
|
|
||||||
|
Warning: readdir() expects at most 1 parameter, 2 given in %s on line %d
|
||||||
|
NULL
|
||||||
|
===DONE===
|
48
ext/standard/tests/dir/readdir_variation2-win32-mb.phpt
Normal file
48
ext/standard/tests/dir/readdir_variation2-win32-mb.phpt
Normal file
|
@ -0,0 +1,48 @@
|
||||||
|
--TEST--
|
||||||
|
Test readdir() function : usage variations - empty directories
|
||||||
|
--FILE--
|
||||||
|
<?php
|
||||||
|
/* Prototype : string readdir([resource $dir_handle])
|
||||||
|
* Description: Read directory entry from dir_handle
|
||||||
|
* Source code: ext/standard/dir.c
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Pass readdir() a directory handle pointing to an empty directory to test behaviour
|
||||||
|
*/
|
||||||
|
|
||||||
|
echo "*** Testing readdir() : usage variations ***\n";
|
||||||
|
|
||||||
|
$path = dirname(__FILE__) . '/私はガラスを食べられますreaddir_variation2';
|
||||||
|
mkdir($path);
|
||||||
|
$dir_handle = opendir($path);
|
||||||
|
|
||||||
|
echo "\n-- Pass an empty directory to readdir() --\n";
|
||||||
|
function mysort($a,$b) {
|
||||||
|
return strlen($a) > strlen($b) ? 1 : -1;
|
||||||
|
}
|
||||||
|
$entries = array();
|
||||||
|
while(FALSE !== ($file = readdir($dir_handle))){
|
||||||
|
$entries[] = $file;
|
||||||
|
}
|
||||||
|
|
||||||
|
closedir($dir_handle);
|
||||||
|
|
||||||
|
usort($entries, "mysort");
|
||||||
|
foreach($entries as $entry) {
|
||||||
|
var_dump($entry);
|
||||||
|
}
|
||||||
|
?>
|
||||||
|
===DONE===
|
||||||
|
--CLEAN--
|
||||||
|
<?php
|
||||||
|
$path = dirname(__FILE__) . '/私はガラスを食べられますreaddir_variation2';
|
||||||
|
rmdir($path);
|
||||||
|
?>
|
||||||
|
--EXPECTF--
|
||||||
|
*** Testing readdir() : usage variations ***
|
||||||
|
|
||||||
|
-- Pass an empty directory to readdir() --
|
||||||
|
string(1) "."
|
||||||
|
string(2) ".."
|
||||||
|
===DONE===
|
68
ext/standard/tests/dir/readdir_variation3-win32-mb.phpt
Normal file
68
ext/standard/tests/dir/readdir_variation3-win32-mb.phpt
Normal file
|
@ -0,0 +1,68 @@
|
||||||
|
--TEST--
|
||||||
|
Test readdir() function : usage variations - sub-directories
|
||||||
|
--FILE--
|
||||||
|
<?php
|
||||||
|
/* Prototype : string readdir([resource $dir_handle])
|
||||||
|
* Description: Read directory entry from dir_handle
|
||||||
|
* Source code: ext/standard/dir.c
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Pass a directory handle pointing to a directory that has a sub-directory
|
||||||
|
* to test behaviour of readdir()
|
||||||
|
*/
|
||||||
|
|
||||||
|
echo "*** Testing readdir() : usage variations ***\n";
|
||||||
|
|
||||||
|
// include the file.inc for Function: function create_files()
|
||||||
|
chdir(dirname(__FILE__));
|
||||||
|
include(dirname(__FILE__)."/../file/file.inc");
|
||||||
|
|
||||||
|
$path_top = dirname(__FILE__) . '/readdir_variation3';
|
||||||
|
$path_sub = $path_top . '/私はガラスを食べられますsub_folder';
|
||||||
|
mkdir($path_top);
|
||||||
|
mkdir($path_sub);
|
||||||
|
|
||||||
|
create_files($path_top, 2);
|
||||||
|
create_files($path_sub, 2);
|
||||||
|
|
||||||
|
$dir_handle = opendir($path_top);
|
||||||
|
while(FALSE !== ($file = readdir($dir_handle))) {
|
||||||
|
|
||||||
|
// different OS order files differently so will
|
||||||
|
// store file names into an array so can use sorted in expected output
|
||||||
|
$contents[] = $file;
|
||||||
|
}
|
||||||
|
|
||||||
|
// more important to check that all contents are present than order they are returned in
|
||||||
|
sort($contents);
|
||||||
|
var_dump($contents);
|
||||||
|
|
||||||
|
delete_files($path_top, 2);
|
||||||
|
delete_files($path_sub, 2);
|
||||||
|
|
||||||
|
closedir($dir_handle);
|
||||||
|
?>
|
||||||
|
===DONE===
|
||||||
|
--CLEAN--
|
||||||
|
<?php
|
||||||
|
$path_top = dirname(__FILE__) . '/readdir_variation3';
|
||||||
|
$path_sub = $path_top . '/私はガラスを食べられますsub_folder';
|
||||||
|
rmdir($path_sub);
|
||||||
|
rmdir($path_top);
|
||||||
|
?>
|
||||||
|
--EXPECTF--
|
||||||
|
*** Testing readdir() : usage variations ***
|
||||||
|
array(5) {
|
||||||
|
[0]=>
|
||||||
|
string(1) "."
|
||||||
|
[1]=>
|
||||||
|
string(2) ".."
|
||||||
|
[2]=>
|
||||||
|
string(9) "file1.tmp"
|
||||||
|
[3]=>
|
||||||
|
string(9) "file2.tmp"
|
||||||
|
[4]=>
|
||||||
|
string(46) "私はガラスを食べられますsub_folder"
|
||||||
|
}
|
||||||
|
===DONE===
|
178
ext/standard/tests/dir/readdir_variation4-win32-mb.phpt
Normal file
178
ext/standard/tests/dir/readdir_variation4-win32-mb.phpt
Normal file
|
@ -0,0 +1,178 @@
|
||||||
|
--TEST--
|
||||||
|
Test readdir() function : usage variations - different file names
|
||||||
|
--FILE--
|
||||||
|
<?php
|
||||||
|
/* Prototype : string readdir([resource $dir_handle])
|
||||||
|
* Description: Read directory entry from dir_handle
|
||||||
|
* Source code: ext/standard/dir.c
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Pass a directory handle pointing to a directory that contains
|
||||||
|
* files with different file names to test how readdir() reads them
|
||||||
|
*/
|
||||||
|
|
||||||
|
echo "*** Testing readdir() : usage variations ***\n";
|
||||||
|
|
||||||
|
$dir_path = dirname(__FILE__) . "/私はガラスを食べられますreaddir_variation4/";
|
||||||
|
mkdir($dir_path);
|
||||||
|
|
||||||
|
// heredoc string
|
||||||
|
$heredoc = <<<EOT
|
||||||
|
hd_file
|
||||||
|
EOT;
|
||||||
|
|
||||||
|
$inputs = array(
|
||||||
|
|
||||||
|
// int data
|
||||||
|
/*1*/ 0,
|
||||||
|
1,
|
||||||
|
12345,
|
||||||
|
-2345,
|
||||||
|
|
||||||
|
// float data
|
||||||
|
/*5*/ 10.5,
|
||||||
|
-10.5,
|
||||||
|
12.3456789000e10,
|
||||||
|
12.3456789000E-10,
|
||||||
|
.5,
|
||||||
|
|
||||||
|
// empty data
|
||||||
|
/*10*/ "",
|
||||||
|
array(),
|
||||||
|
|
||||||
|
// string data
|
||||||
|
/*12*/ "double_file",
|
||||||
|
'single_file',
|
||||||
|
$heredoc,
|
||||||
|
);
|
||||||
|
|
||||||
|
$iterator = 1;
|
||||||
|
foreach($inputs as $key => $input) {
|
||||||
|
echo "\n-- Iteration $iterator --\n";
|
||||||
|
$handle = "fp{$iterator}";
|
||||||
|
var_dump( $$handle = @fopen($dir_path . "私はガラスを食べられます$input.tmp", 'w') );
|
||||||
|
var_dump( fwrite($$handle, $key));
|
||||||
|
fclose($$handle);
|
||||||
|
$iterator++;
|
||||||
|
};
|
||||||
|
|
||||||
|
echo "\n-- Call to readdir() --\n";
|
||||||
|
$dir_handle = opendir($dir_path);
|
||||||
|
while(FALSE !== ($file = readdir($dir_handle))){
|
||||||
|
|
||||||
|
// different OS order files differently so will
|
||||||
|
// store file names into an array so can use sorted in expected output
|
||||||
|
$contents[] = $file;
|
||||||
|
|
||||||
|
// remove files while going through directory
|
||||||
|
@unlink($dir_path . $file);
|
||||||
|
}
|
||||||
|
|
||||||
|
// more important to check that all contents are present than order they are returned in
|
||||||
|
sort($contents);
|
||||||
|
var_dump($contents);
|
||||||
|
|
||||||
|
closedir($dir_handle);
|
||||||
|
?>
|
||||||
|
===DONE===
|
||||||
|
--CLEAN--
|
||||||
|
<?php
|
||||||
|
$dir_path = dirname(__FILE__) . "/私はガラスを食べられますreaddir_variation4/";
|
||||||
|
rmdir($dir_path);
|
||||||
|
?>
|
||||||
|
--EXPECTF--
|
||||||
|
*** Testing readdir() : usage variations ***
|
||||||
|
|
||||||
|
-- Iteration 1 --
|
||||||
|
resource(%d) of type (stream)
|
||||||
|
int(1)
|
||||||
|
|
||||||
|
-- Iteration 2 --
|
||||||
|
resource(%d) of type (stream)
|
||||||
|
int(1)
|
||||||
|
|
||||||
|
-- Iteration 3 --
|
||||||
|
resource(%d) of type (stream)
|
||||||
|
int(1)
|
||||||
|
|
||||||
|
-- Iteration 4 --
|
||||||
|
resource(%d) of type (stream)
|
||||||
|
int(1)
|
||||||
|
|
||||||
|
-- Iteration 5 --
|
||||||
|
resource(%d) of type (stream)
|
||||||
|
int(1)
|
||||||
|
|
||||||
|
-- Iteration 6 --
|
||||||
|
resource(%d) of type (stream)
|
||||||
|
int(1)
|
||||||
|
|
||||||
|
-- Iteration 7 --
|
||||||
|
resource(%d) of type (stream)
|
||||||
|
int(1)
|
||||||
|
|
||||||
|
-- Iteration 8 --
|
||||||
|
resource(%d) of type (stream)
|
||||||
|
int(1)
|
||||||
|
|
||||||
|
-- Iteration 9 --
|
||||||
|
resource(%d) of type (stream)
|
||||||
|
int(1)
|
||||||
|
|
||||||
|
-- Iteration 10 --
|
||||||
|
resource(%d) of type (stream)
|
||||||
|
int(1)
|
||||||
|
|
||||||
|
-- Iteration 11 --
|
||||||
|
resource(%d) of type (stream)
|
||||||
|
int(2)
|
||||||
|
|
||||||
|
-- Iteration 12 --
|
||||||
|
resource(%d) of type (stream)
|
||||||
|
int(2)
|
||||||
|
|
||||||
|
-- Iteration 13 --
|
||||||
|
resource(%d) of type (stream)
|
||||||
|
int(2)
|
||||||
|
|
||||||
|
-- Iteration 14 --
|
||||||
|
resource(%d) of type (stream)
|
||||||
|
int(2)
|
||||||
|
|
||||||
|
-- Call to readdir() --
|
||||||
|
array(16) {
|
||||||
|
[0]=>
|
||||||
|
string(1) "."
|
||||||
|
[1]=>
|
||||||
|
string(2) ".."
|
||||||
|
[2]=>
|
||||||
|
string(45) "私はガラスを食べられます-10.5.tmp"
|
||||||
|
[3]=>
|
||||||
|
string(45) "私はガラスを食べられます-2345.tmp"
|
||||||
|
[4]=>
|
||||||
|
string(40) "私はガラスを食べられます.tmp"
|
||||||
|
[5]=>
|
||||||
|
string(43) "私はガラスを食べられます0.5.tmp"
|
||||||
|
[6]=>
|
||||||
|
string(41) "私はガラスを食べられます0.tmp"
|
||||||
|
[7]=>
|
||||||
|
string(53) "私はガラスを食べられます1.23456789E-9.tmp"
|
||||||
|
[8]=>
|
||||||
|
string(41) "私はガラスを食べられます1.tmp"
|
||||||
|
[9]=>
|
||||||
|
string(44) "私はガラスを食べられます10.5.tmp"
|
||||||
|
[10]=>
|
||||||
|
string(45) "私はガラスを食べられます12345.tmp"
|
||||||
|
[11]=>
|
||||||
|
string(52) "私はガラスを食べられます123456789000.tmp"
|
||||||
|
[12]=>
|
||||||
|
string(45) "私はガラスを食べられますArray.tmp"
|
||||||
|
[13]=>
|
||||||
|
string(51) "私はガラスを食べられますdouble_file.tmp"
|
||||||
|
[14]=>
|
||||||
|
string(47) "私はガラスを食べられますhd_file.tmp"
|
||||||
|
[15]=>
|
||||||
|
string(51) "私はガラスを食べられますsingle_file.tmp"
|
||||||
|
}
|
||||||
|
===DONE===
|
80
ext/standard/tests/dir/readdir_variation6-win32-mb.phpt
Normal file
80
ext/standard/tests/dir/readdir_variation6-win32-mb.phpt
Normal file
|
@ -0,0 +1,80 @@
|
||||||
|
--TEST--
|
||||||
|
Test readdir() function : usage variations - operate on previously opened directory
|
||||||
|
--FILE--
|
||||||
|
<?php
|
||||||
|
/* Prototype : string readdir([resource $dir_handle])
|
||||||
|
* Description: Read directory entry from dir_handle
|
||||||
|
* Source code: ext/standard/dir.c
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Open two directory handles on the same directory and pass both
|
||||||
|
* to readdir() to test behaviour
|
||||||
|
*/
|
||||||
|
|
||||||
|
echo "*** Testing readdir() : usage variations ***\n";
|
||||||
|
|
||||||
|
// include the file.inc for Function: function create_files()
|
||||||
|
include( dirname(__FILE__)."/../file/file.inc");
|
||||||
|
|
||||||
|
// create the temporary directory
|
||||||
|
$dir_path = dirname(__FILE__) . "/私はガラスを食べられますreaddir_variation6";
|
||||||
|
mkdir($dir_path);
|
||||||
|
|
||||||
|
// create files within the temporary directory
|
||||||
|
create_files($dir_path, 3, "alphanumeric", 0755, 1, "w", "私はガラスを食べられますreaddir_variation6");
|
||||||
|
|
||||||
|
// open the directory
|
||||||
|
$dir_handle1 = opendir($dir_path);
|
||||||
|
|
||||||
|
// open the same directory again without closing it
|
||||||
|
opendir($dir_path);
|
||||||
|
|
||||||
|
echo "\n-- Reading Directory Contents with Previous Handle --\n";
|
||||||
|
$a = array();
|
||||||
|
while (FALSE !== ($file = readdir($dir_handle1))) {
|
||||||
|
$a[] = $file;
|
||||||
|
}
|
||||||
|
sort($a);
|
||||||
|
foreach ($a as $file) {
|
||||||
|
var_dump($file);
|
||||||
|
}
|
||||||
|
|
||||||
|
echo "\n-- Reading Directory Contents with Current Handle (no arguments supplied) --\n";
|
||||||
|
$a = array();
|
||||||
|
while (FALSE !== ($file = readdir())) {
|
||||||
|
$a[] = $file;
|
||||||
|
}
|
||||||
|
sort($a);
|
||||||
|
foreach ($a as $file) {
|
||||||
|
var_dump($file);
|
||||||
|
}
|
||||||
|
|
||||||
|
// delete temporary files
|
||||||
|
delete_files($dir_path, 3, "私はガラスを食べられますreaddir_variation6");
|
||||||
|
closedir($dir_handle1);
|
||||||
|
closedir();
|
||||||
|
?>
|
||||||
|
===DONE===
|
||||||
|
--CLEAN--
|
||||||
|
<?php
|
||||||
|
$dir_path = dirname(__FILE__) . "/私はガラスを食べられますreaddir_variation6";
|
||||||
|
rmdir($dir_path);
|
||||||
|
?>
|
||||||
|
--EXPECTF--
|
||||||
|
*** Testing readdir() : usage variations ***
|
||||||
|
|
||||||
|
-- Reading Directory Contents with Previous Handle --
|
||||||
|
string(1) "."
|
||||||
|
string(2) ".."
|
||||||
|
string(59) "私はガラスを食べられますreaddir_variation61.tmp"
|
||||||
|
string(59) "私はガラスを食べられますreaddir_variation62.tmp"
|
||||||
|
string(59) "私はガラスを食べられますreaddir_variation63.tmp"
|
||||||
|
|
||||||
|
-- Reading Directory Contents with Current Handle (no arguments supplied) --
|
||||||
|
string(1) "."
|
||||||
|
string(2) ".."
|
||||||
|
string(59) "私はガラスを食べられますreaddir_variation61.tmp"
|
||||||
|
string(59) "私はガラスを食べられますreaddir_variation62.tmp"
|
||||||
|
string(59) "私はガラスを食べられますreaddir_variation63.tmp"
|
||||||
|
===DONE===
|
96
ext/standard/tests/dir/rewinddir_basic-win32-mb.phpt
Normal file
96
ext/standard/tests/dir/rewinddir_basic-win32-mb.phpt
Normal file
|
@ -0,0 +1,96 @@
|
||||||
|
--TEST--
|
||||||
|
Test rewinddir() function : basic functionality
|
||||||
|
--FILE--
|
||||||
|
<?php
|
||||||
|
/* Prototype : void rewinddir([resource $dir_handle])
|
||||||
|
* Description: Rewind dir_handle back to the start
|
||||||
|
* Source code: ext/standard/dir.c
|
||||||
|
* Alias to functions: rewind
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Test basic functionality of rewinddir()
|
||||||
|
*/
|
||||||
|
|
||||||
|
echo "*** Testing rewinddir() : basic functionality ***\n";
|
||||||
|
|
||||||
|
// include file.inc for create_files function
|
||||||
|
include(dirname(__FILE__) . "/../file/file.inc");
|
||||||
|
|
||||||
|
$dir_path1 = dirname(__FILE__) . "/私はガラスを食べられますrewinddir_basic_dir1";
|
||||||
|
$dir_path2 = dirname(__FILE__) . "/私はガラスを食べられますrewinddir_basic_dir2";
|
||||||
|
mkdir($dir_path1);
|
||||||
|
mkdir($dir_path2);
|
||||||
|
|
||||||
|
@create_files($dir_path1, 1, "numeric", 0755, 1, "w", "私はガラスを食べられますfile");
|
||||||
|
@create_files($dir_path2, 1, 'numeric', 0755, 1, 'w', "私はガラスを食べられますfile", 2);
|
||||||
|
var_dump($dh1 = opendir($dir_path1));
|
||||||
|
var_dump($dh2 = opendir($dir_path2));
|
||||||
|
|
||||||
|
$data = array();
|
||||||
|
echo "\n-- Read and rewind first directory (argument supplied) --\n";
|
||||||
|
while(FALSE !== $file1 = readdir($dh1)) {
|
||||||
|
$data[] = $file1;
|
||||||
|
}
|
||||||
|
$first = $data[0];
|
||||||
|
sort($data);
|
||||||
|
var_dump($data);
|
||||||
|
|
||||||
|
var_dump(rewinddir($dh1));
|
||||||
|
var_dump(readdir($dh1) == $first);
|
||||||
|
|
||||||
|
$data = array();
|
||||||
|
echo "\n-- Read and rewind second directory (no argument supplied) --\n";
|
||||||
|
while(FALSE !== $file2 = readdir()) {
|
||||||
|
$data[] = $file2;
|
||||||
|
}
|
||||||
|
$first = $data[0];
|
||||||
|
sort($data);
|
||||||
|
var_dump($data);
|
||||||
|
|
||||||
|
var_dump(rewinddir());
|
||||||
|
var_dump(readdir() == $first);
|
||||||
|
|
||||||
|
closedir($dh1);
|
||||||
|
closedir($dh2);
|
||||||
|
|
||||||
|
delete_files($dir_path1, 1, "私はガラスを食べられますfile");
|
||||||
|
delete_files($dir_path2, 1, "私はガラスを食べられますfile", 2);
|
||||||
|
?>
|
||||||
|
===DONE===
|
||||||
|
--CLEAN--
|
||||||
|
<?php
|
||||||
|
$dir_path1 = dirname(__FILE__) . "/私はガラスを食べられますrewinddir_basic_dir1";
|
||||||
|
$dir_path2 = dirname(__FILE__) . "/私はガラスを食べられますrewinddir_basic_dir2";
|
||||||
|
rmdir($dir_path1);
|
||||||
|
rmdir($dir_path2);
|
||||||
|
?>
|
||||||
|
--EXPECTF--
|
||||||
|
*** Testing rewinddir() : basic functionality ***
|
||||||
|
resource(%d) of type (stream)
|
||||||
|
resource(%d) of type (stream)
|
||||||
|
|
||||||
|
-- Read and rewind first directory (argument supplied) --
|
||||||
|
array(3) {
|
||||||
|
[0]=>
|
||||||
|
string(1) "."
|
||||||
|
[1]=>
|
||||||
|
string(2) ".."
|
||||||
|
[2]=>
|
||||||
|
string(45) "私はガラスを食べられますfile1.tmp"
|
||||||
|
}
|
||||||
|
NULL
|
||||||
|
bool(true)
|
||||||
|
|
||||||
|
-- Read and rewind second directory (no argument supplied) --
|
||||||
|
array(3) {
|
||||||
|
[0]=>
|
||||||
|
string(1) "."
|
||||||
|
[1]=>
|
||||||
|
string(2) ".."
|
||||||
|
[2]=>
|
||||||
|
string(45) "私はガラスを食べられますfile2.tmp"
|
||||||
|
}
|
||||||
|
NULL
|
||||||
|
bool(true)
|
||||||
|
===DONE===
|
42
ext/standard/tests/dir/rewinddir_error-win32-mb.phpt
Normal file
42
ext/standard/tests/dir/rewinddir_error-win32-mb.phpt
Normal file
|
@ -0,0 +1,42 @@
|
||||||
|
--TEST--
|
||||||
|
Test rewinddir() function : error conditions - incorrect number of args
|
||||||
|
--FILE--
|
||||||
|
<?php
|
||||||
|
/* Prototype : void rewinddir([resource $dir_handle])
|
||||||
|
* Description: Rewind dir_handle back to the start
|
||||||
|
* Source code: ext/standard/dir.c
|
||||||
|
* Alias to functions: rewind
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Pass incorrect number of arguments to rewinddir() to test behaviour
|
||||||
|
*/
|
||||||
|
|
||||||
|
echo "*** Testing rewinddir() : error conditions ***\n";
|
||||||
|
|
||||||
|
|
||||||
|
//Test rewinddir with one more than the expected number of arguments
|
||||||
|
echo "\n-- Testing rewinddir() function with more than expected no. of arguments --\n";
|
||||||
|
|
||||||
|
$dir_path = dirname(__FILE__) . "/私はガラスを食べられますrewinddir_error";
|
||||||
|
mkdir($dir_path);
|
||||||
|
$dir_handle = opendir($dir_path);
|
||||||
|
$extra_arg = 10;
|
||||||
|
|
||||||
|
var_dump( rewinddir($dir_handle, $extra_arg) );
|
||||||
|
closedir($dir_handle);
|
||||||
|
?>
|
||||||
|
===DONE===
|
||||||
|
--CLEAN--
|
||||||
|
<?php
|
||||||
|
$dir_path = dirname(__FILE__) . "/私はガラスを食べられますrewinddir_error";
|
||||||
|
rmdir($dir_path);
|
||||||
|
?>
|
||||||
|
--EXPECTF--
|
||||||
|
*** Testing rewinddir() : error conditions ***
|
||||||
|
|
||||||
|
-- Testing rewinddir() function with more than expected no. of arguments --
|
||||||
|
|
||||||
|
Warning: rewinddir() expects at most 1 parameter, 2 given in %s on line %d
|
||||||
|
NULL
|
||||||
|
===DONE===
|
45
ext/standard/tests/dir/rewinddir_variation2-win32-mb.phpt
Normal file
45
ext/standard/tests/dir/rewinddir_variation2-win32-mb.phpt
Normal file
|
@ -0,0 +1,45 @@
|
||||||
|
--TEST--
|
||||||
|
Test rewinddir() function : usage variations - operate on a closed directory
|
||||||
|
--FILE--
|
||||||
|
<?php
|
||||||
|
/* Prototype : void rewinddir([resource $dir_handle])
|
||||||
|
* Description: Rewind dir_handle back to the start
|
||||||
|
* Source code: ext/standard/dir.c
|
||||||
|
* Alias to functions: rewind
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Open and close a directory handle then call rewinddir() to test behaviour
|
||||||
|
*/
|
||||||
|
|
||||||
|
echo "*** Testing rewinddir() : usage variations ***\n";
|
||||||
|
|
||||||
|
$dir_path = dirname(__FILE__) . '/私はガラスを食べられますrewinddir_variation2';
|
||||||
|
mkdir($dir_path);
|
||||||
|
|
||||||
|
echo "\n-- Create the directory handle, read and close the directory --\n";
|
||||||
|
var_dump($dir_handle = opendir($dir_path));
|
||||||
|
var_dump(readdir($dir_handle));
|
||||||
|
closedir($dir_handle);
|
||||||
|
|
||||||
|
echo "\n-- Call to rewinddir() --\n";
|
||||||
|
var_dump(rewinddir($dir_handle));
|
||||||
|
?>
|
||||||
|
===DONE===
|
||||||
|
--CLEAN--
|
||||||
|
<?php
|
||||||
|
$dir_path = dirname(__FILE__) . '/私はガラスを食べられますrewinddir_variation2';
|
||||||
|
rmdir($dir_path);
|
||||||
|
?>
|
||||||
|
--EXPECTF--
|
||||||
|
*** Testing rewinddir() : usage variations ***
|
||||||
|
|
||||||
|
-- Create the directory handle, read and close the directory --
|
||||||
|
resource(%d) of type (stream)
|
||||||
|
string(%d) "%s"
|
||||||
|
|
||||||
|
-- Call to rewinddir() --
|
||||||
|
|
||||||
|
Warning: rewinddir(): %s is not a valid Directory resource in %s on line %d
|
||||||
|
bool(false)
|
||||||
|
===DONE===
|
70
ext/standard/tests/dir/scandir_basic-win32-mb.phpt
Normal file
70
ext/standard/tests/dir/scandir_basic-win32-mb.phpt
Normal file
|
@ -0,0 +1,70 @@
|
||||||
|
--TEST--
|
||||||
|
Test scandir() function : basic functionality
|
||||||
|
--FILE--
|
||||||
|
<?php
|
||||||
|
/* Prototype : array scandir(string $dir [, int $sorting_order [, resource $context]])
|
||||||
|
* Description: List files & directories inside the specified path
|
||||||
|
* Source code: ext/standard/dir.c
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Test basic functionality of scandir()
|
||||||
|
*/
|
||||||
|
|
||||||
|
echo "*** Testing scandir() : basic functionality ***\n";
|
||||||
|
|
||||||
|
// include file.inc for create_files function
|
||||||
|
include (dirname(__FILE__) . '/../file/file.inc');
|
||||||
|
|
||||||
|
// set up directory
|
||||||
|
$directory = dirname(__FILE__) . '/私はガラスを食べられますscandir_basic';
|
||||||
|
mkdir($directory);
|
||||||
|
create_files($directory, 3, "numeric", 0755, 1, "w", "私はガラスを食べられますfile");
|
||||||
|
|
||||||
|
echo "\n-- scandir() with mandatory arguments --\n";
|
||||||
|
var_dump(scandir($directory));
|
||||||
|
|
||||||
|
echo "\n-- scandir() with all arguments --\n";
|
||||||
|
$sorting_order = SCANDIR_SORT_DESCENDING;
|
||||||
|
$context = stream_context_create();
|
||||||
|
var_dump(scandir($directory, $sorting_order, $context));
|
||||||
|
|
||||||
|
delete_files($directory, 3, "私はガラスを食べられますfile");
|
||||||
|
?>
|
||||||
|
===DONE===
|
||||||
|
--CLEAN--
|
||||||
|
<?php
|
||||||
|
$directory = dirname(__FILE__) . '/私はガラスを食べられますscandir_basic';
|
||||||
|
rmdir($directory);
|
||||||
|
?>
|
||||||
|
--EXPECTF--
|
||||||
|
*** Testing scandir() : basic functionality ***
|
||||||
|
|
||||||
|
-- scandir() with mandatory arguments --
|
||||||
|
array(5) {
|
||||||
|
[0]=>
|
||||||
|
string(1) "."
|
||||||
|
[1]=>
|
||||||
|
string(2) ".."
|
||||||
|
[2]=>
|
||||||
|
string(45) "私はガラスを食べられますfile1.tmp"
|
||||||
|
[3]=>
|
||||||
|
string(45) "私はガラスを食べられますfile2.tmp"
|
||||||
|
[4]=>
|
||||||
|
string(45) "私はガラスを食べられますfile3.tmp"
|
||||||
|
}
|
||||||
|
|
||||||
|
-- scandir() with all arguments --
|
||||||
|
array(5) {
|
||||||
|
[0]=>
|
||||||
|
string(45) "私はガラスを食べられますfile3.tmp"
|
||||||
|
[1]=>
|
||||||
|
string(45) "私はガラスを食べられますfile2.tmp"
|
||||||
|
[2]=>
|
||||||
|
string(45) "私はガラスを食べられますfile1.tmp"
|
||||||
|
[3]=>
|
||||||
|
string(2) ".."
|
||||||
|
[4]=>
|
||||||
|
string(1) "."
|
||||||
|
}
|
||||||
|
===DONE===
|
47
ext/standard/tests/dir/scandir_error1-win32-mb.phpt
Normal file
47
ext/standard/tests/dir/scandir_error1-win32-mb.phpt
Normal file
|
@ -0,0 +1,47 @@
|
||||||
|
--TEST--
|
||||||
|
Test scandir() function : error conditions - Incorrect number of args
|
||||||
|
--FILE--
|
||||||
|
<?php
|
||||||
|
/* Prototype : array scandir(string $dir [, int $sorting_order [, resource $context]])
|
||||||
|
* Description: List files & directories inside the specified path
|
||||||
|
* Source code: ext/standard/dir.c
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Pass incorrect number of arguments to scandir() to test behaviour
|
||||||
|
*/
|
||||||
|
|
||||||
|
echo "*** Testing scandir() : error conditions ***\n";
|
||||||
|
|
||||||
|
// Zero arguments
|
||||||
|
echo "\n-- Testing scandir() function with Zero arguments --\n";
|
||||||
|
var_dump( scandir() );
|
||||||
|
|
||||||
|
//Test scandir with one more than the expected number of arguments
|
||||||
|
echo "\n-- Testing scandir() function with more than expected no. of arguments --\n";
|
||||||
|
$dir = dirname(__FILE__) . '/私はガラスを食べられますscandir_error';
|
||||||
|
mkdir($dir);
|
||||||
|
$sorting_order = 10;
|
||||||
|
$context = stream_context_create();
|
||||||
|
$extra_arg = 10;
|
||||||
|
var_dump( scandir($dir, $sorting_order, $context, $extra_arg) );
|
||||||
|
?>
|
||||||
|
===DONE===
|
||||||
|
--CLEAN--
|
||||||
|
<?php
|
||||||
|
$directory = dirname(__FILE__) . '/私はガラスを食べられますscandir_error';
|
||||||
|
rmdir($directory);
|
||||||
|
?>
|
||||||
|
--EXPECTF--
|
||||||
|
*** Testing scandir() : error conditions ***
|
||||||
|
|
||||||
|
-- Testing scandir() function with Zero arguments --
|
||||||
|
|
||||||
|
Warning: scandir() expects at least 1 parameter, 0 given in %s on line %d
|
||||||
|
NULL
|
||||||
|
|
||||||
|
-- Testing scandir() function with more than expected no. of arguments --
|
||||||
|
|
||||||
|
Warning: scandir() expects at most 3 parameters, 4 given in %s on line %d
|
||||||
|
NULL
|
||||||
|
===DONE===
|
79
ext/standard/tests/dir/scandir_variation10-win32-mb.phpt
Normal file
79
ext/standard/tests/dir/scandir_variation10-win32-mb.phpt
Normal file
|
@ -0,0 +1,79 @@
|
||||||
|
--TEST--
|
||||||
|
Test scandir() function : usage variations - different sorting constants
|
||||||
|
--FILE--
|
||||||
|
<?php
|
||||||
|
/* Prototype : array scandir(string $dir [, int $sorting_order [, resource $context]])
|
||||||
|
* Description: List files & directories inside the specified path
|
||||||
|
* Source code: ext/standard/dir.c
|
||||||
|
*/
|
||||||
|
|
||||||
|
printf("SCANDIR_SORT_ASCENDING: %d\n", SCANDIR_SORT_ASCENDING);
|
||||||
|
printf("SCANDIR_SORT_DESCENDING: %d\n", SCANDIR_SORT_DESCENDING);
|
||||||
|
printf("SCANDIR_SORT_NONE: %d\n", SCANDIR_SORT_NONE);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Pass different integers as $sorting_order argument to test how scandir()
|
||||||
|
* re-orders the array
|
||||||
|
*/
|
||||||
|
|
||||||
|
echo "*** Testing scandir() : usage variations ***\n";
|
||||||
|
|
||||||
|
// include for create_files/delete_files functions
|
||||||
|
include(dirname(__FILE__) . '/../file/file.inc');
|
||||||
|
|
||||||
|
// create directory and files
|
||||||
|
$dir = dirname(__FILE__) . '/私はガラスを食べられますscandir_variation10';
|
||||||
|
mkdir($dir);
|
||||||
|
@create_files($dir, 2, "numeric", 0755, 1, "w", "私はガラスを食べられますfile");
|
||||||
|
|
||||||
|
// Deterministic tests.
|
||||||
|
var_dump(scandir($dir, SCANDIR_SORT_ASCENDING));
|
||||||
|
var_dump(scandir($dir, SCANDIR_SORT_DESCENDING));
|
||||||
|
|
||||||
|
// Non-deterministic tests.
|
||||||
|
$files = scandir($dir, SCANDIR_SORT_NONE);
|
||||||
|
var_dump(count($files));
|
||||||
|
var_dump(in_array('.', $files));
|
||||||
|
var_dump(in_array('..', $files));
|
||||||
|
var_dump(in_array('私はガラスを食べられますfile1.tmp', $files));
|
||||||
|
var_dump(in_array('私はガラスを食べられますfile2.tmp', $files));
|
||||||
|
|
||||||
|
delete_files($dir, 2, "私はガラスを食べられますfile");
|
||||||
|
?>
|
||||||
|
===DONE===
|
||||||
|
--CLEAN--
|
||||||
|
<?php
|
||||||
|
$dir = dirname(__FILE__) . '/私はガラスを食べられますscandir_variation10';
|
||||||
|
rmdir($dir);
|
||||||
|
?>
|
||||||
|
--EXPECTF--
|
||||||
|
SCANDIR_SORT_ASCENDING: 0
|
||||||
|
SCANDIR_SORT_DESCENDING: 1
|
||||||
|
SCANDIR_SORT_NONE: 2
|
||||||
|
*** Testing scandir() : usage variations ***
|
||||||
|
array(4) {
|
||||||
|
[0]=>
|
||||||
|
string(1) "."
|
||||||
|
[1]=>
|
||||||
|
string(2) ".."
|
||||||
|
[2]=>
|
||||||
|
string(45) "私はガラスを食べられますfile1.tmp"
|
||||||
|
[3]=>
|
||||||
|
string(45) "私はガラスを食べられますfile2.tmp"
|
||||||
|
}
|
||||||
|
array(4) {
|
||||||
|
[0]=>
|
||||||
|
string(45) "私はガラスを食べられますfile2.tmp"
|
||||||
|
[1]=>
|
||||||
|
string(45) "私はガラスを食べられますfile1.tmp"
|
||||||
|
[2]=>
|
||||||
|
string(2) ".."
|
||||||
|
[3]=>
|
||||||
|
string(1) "."
|
||||||
|
}
|
||||||
|
int(4)
|
||||||
|
bool(true)
|
||||||
|
bool(true)
|
||||||
|
bool(true)
|
||||||
|
bool(true)
|
||||||
|
===DONE===
|
283
ext/standard/tests/dir/scandir_variation2-win32-mb.phpt
Normal file
283
ext/standard/tests/dir/scandir_variation2-win32-mb.phpt
Normal file
|
@ -0,0 +1,283 @@
|
||||||
|
--TEST--
|
||||||
|
Test scandir() function : usage variations - diff data types as $sorting_order arg
|
||||||
|
--FILE--
|
||||||
|
<?php
|
||||||
|
/* Prototype : array scandir(string $dir [, int $sorting_order [, resource $context]])
|
||||||
|
* Description: List files & directories inside the specified path
|
||||||
|
* Source code: ext/standard/dir.c
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Pass different data types as $sorting_order argument to test how scandir() behaves
|
||||||
|
*/
|
||||||
|
|
||||||
|
echo "*** Testing scandir() : usage variations ***\n";
|
||||||
|
|
||||||
|
// Initialise function arguments not being substituted
|
||||||
|
$dir = dirname(__FILE__) . '/私はガラスを食べられますscandir_variation2';
|
||||||
|
mkdir($dir);
|
||||||
|
|
||||||
|
//get an unset variable
|
||||||
|
$unset_var = 10;
|
||||||
|
unset ($unset_var);
|
||||||
|
|
||||||
|
// get a class
|
||||||
|
class classA
|
||||||
|
{
|
||||||
|
public function __toString() {
|
||||||
|
return "Class A object";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// heredoc string
|
||||||
|
$heredoc = <<<EOT
|
||||||
|
hello world
|
||||||
|
EOT;
|
||||||
|
|
||||||
|
// get a resource variable
|
||||||
|
$fp = fopen(__FILE__, "r");
|
||||||
|
|
||||||
|
// unexpected values to be passed to $sorting_order argument
|
||||||
|
$inputs = array(
|
||||||
|
|
||||||
|
// int data
|
||||||
|
/*1*/ 0,
|
||||||
|
1,
|
||||||
|
12345,
|
||||||
|
-2345,
|
||||||
|
|
||||||
|
// float data
|
||||||
|
/*5*/ 10.5,
|
||||||
|
-10.5,
|
||||||
|
12.3456789000e10,
|
||||||
|
12.3456789000E-10,
|
||||||
|
.5,
|
||||||
|
|
||||||
|
// null data
|
||||||
|
/*10*/ NULL,
|
||||||
|
null,
|
||||||
|
|
||||||
|
// boolean data
|
||||||
|
/*12*/ true,
|
||||||
|
false,
|
||||||
|
TRUE,
|
||||||
|
FALSE,
|
||||||
|
|
||||||
|
// empty data
|
||||||
|
/*16*/ "",
|
||||||
|
'',
|
||||||
|
array(),
|
||||||
|
|
||||||
|
// string data
|
||||||
|
/*19*/ "string",
|
||||||
|
'string',
|
||||||
|
$heredoc,
|
||||||
|
|
||||||
|
// object data
|
||||||
|
/*22*/ new classA(),
|
||||||
|
|
||||||
|
// undefined data
|
||||||
|
/*23*/ @$undefined_var,
|
||||||
|
|
||||||
|
// unset data
|
||||||
|
/*24*/ @$unset_var,
|
||||||
|
|
||||||
|
// resource variable
|
||||||
|
/*25*/ $fp
|
||||||
|
);
|
||||||
|
|
||||||
|
// loop through each element of $inputs to check the behavior of scandir()
|
||||||
|
$iterator = 1;
|
||||||
|
foreach($inputs as $input) {
|
||||||
|
echo "\n-- Iteration $iterator --\n";
|
||||||
|
var_dump( scandir($dir, $input) );
|
||||||
|
$iterator++;
|
||||||
|
};
|
||||||
|
|
||||||
|
fclose($fp);
|
||||||
|
?>
|
||||||
|
===DONE===
|
||||||
|
--CLEAN--
|
||||||
|
<?php
|
||||||
|
$dir = dirname(__FILE__) . '/私はガラスを食べられますscandir_variation2';
|
||||||
|
rmdir($dir);
|
||||||
|
?>
|
||||||
|
--EXPECTF--
|
||||||
|
*** Testing scandir() : usage variations ***
|
||||||
|
|
||||||
|
-- Iteration 1 --
|
||||||
|
array(2) {
|
||||||
|
[0]=>
|
||||||
|
string(1) "."
|
||||||
|
[1]=>
|
||||||
|
string(2) ".."
|
||||||
|
}
|
||||||
|
|
||||||
|
-- Iteration 2 --
|
||||||
|
array(2) {
|
||||||
|
[0]=>
|
||||||
|
string(2) ".."
|
||||||
|
[1]=>
|
||||||
|
string(1) "."
|
||||||
|
}
|
||||||
|
|
||||||
|
-- Iteration 3 --
|
||||||
|
array(2) {
|
||||||
|
[0]=>
|
||||||
|
string(2) ".."
|
||||||
|
[1]=>
|
||||||
|
string(1) "."
|
||||||
|
}
|
||||||
|
|
||||||
|
-- Iteration 4 --
|
||||||
|
array(2) {
|
||||||
|
[0]=>
|
||||||
|
string(2) ".."
|
||||||
|
[1]=>
|
||||||
|
string(1) "."
|
||||||
|
}
|
||||||
|
|
||||||
|
-- Iteration 5 --
|
||||||
|
array(2) {
|
||||||
|
[0]=>
|
||||||
|
string(2) ".."
|
||||||
|
[1]=>
|
||||||
|
string(1) "."
|
||||||
|
}
|
||||||
|
|
||||||
|
-- Iteration 6 --
|
||||||
|
array(2) {
|
||||||
|
[0]=>
|
||||||
|
string(2) ".."
|
||||||
|
[1]=>
|
||||||
|
string(1) "."
|
||||||
|
}
|
||||||
|
|
||||||
|
-- Iteration 7 --
|
||||||
|
array(2) {
|
||||||
|
[0]=>
|
||||||
|
string(2) ".."
|
||||||
|
[1]=>
|
||||||
|
string(1) "."
|
||||||
|
}
|
||||||
|
|
||||||
|
-- Iteration 8 --
|
||||||
|
array(2) {
|
||||||
|
[0]=>
|
||||||
|
string(1) "."
|
||||||
|
[1]=>
|
||||||
|
string(2) ".."
|
||||||
|
}
|
||||||
|
|
||||||
|
-- Iteration 9 --
|
||||||
|
array(2) {
|
||||||
|
[0]=>
|
||||||
|
string(1) "."
|
||||||
|
[1]=>
|
||||||
|
string(2) ".."
|
||||||
|
}
|
||||||
|
|
||||||
|
-- Iteration 10 --
|
||||||
|
array(2) {
|
||||||
|
[0]=>
|
||||||
|
string(1) "."
|
||||||
|
[1]=>
|
||||||
|
string(2) ".."
|
||||||
|
}
|
||||||
|
|
||||||
|
-- Iteration 11 --
|
||||||
|
array(2) {
|
||||||
|
[0]=>
|
||||||
|
string(1) "."
|
||||||
|
[1]=>
|
||||||
|
string(2) ".."
|
||||||
|
}
|
||||||
|
|
||||||
|
-- Iteration 12 --
|
||||||
|
array(2) {
|
||||||
|
[0]=>
|
||||||
|
string(2) ".."
|
||||||
|
[1]=>
|
||||||
|
string(1) "."
|
||||||
|
}
|
||||||
|
|
||||||
|
-- Iteration 13 --
|
||||||
|
array(2) {
|
||||||
|
[0]=>
|
||||||
|
string(1) "."
|
||||||
|
[1]=>
|
||||||
|
string(2) ".."
|
||||||
|
}
|
||||||
|
|
||||||
|
-- Iteration 14 --
|
||||||
|
array(2) {
|
||||||
|
[0]=>
|
||||||
|
string(2) ".."
|
||||||
|
[1]=>
|
||||||
|
string(1) "."
|
||||||
|
}
|
||||||
|
|
||||||
|
-- Iteration 15 --
|
||||||
|
array(2) {
|
||||||
|
[0]=>
|
||||||
|
string(1) "."
|
||||||
|
[1]=>
|
||||||
|
string(2) ".."
|
||||||
|
}
|
||||||
|
|
||||||
|
-- Iteration 16 --
|
||||||
|
|
||||||
|
Warning: scandir() expects parameter 2 to be integer, string given in %s on line %d
|
||||||
|
NULL
|
||||||
|
|
||||||
|
-- Iteration 17 --
|
||||||
|
|
||||||
|
Warning: scandir() expects parameter 2 to be integer, string given in %s on line %d
|
||||||
|
NULL
|
||||||
|
|
||||||
|
-- Iteration 18 --
|
||||||
|
|
||||||
|
Warning: scandir() expects parameter 2 to be integer, array given in %s on line %d
|
||||||
|
NULL
|
||||||
|
|
||||||
|
-- Iteration 19 --
|
||||||
|
|
||||||
|
Warning: scandir() expects parameter 2 to be integer, string given in %s on line %d
|
||||||
|
NULL
|
||||||
|
|
||||||
|
-- Iteration 20 --
|
||||||
|
|
||||||
|
Warning: scandir() expects parameter 2 to be integer, string given in %s on line %d
|
||||||
|
NULL
|
||||||
|
|
||||||
|
-- Iteration 21 --
|
||||||
|
|
||||||
|
Warning: scandir() expects parameter 2 to be integer, string given in %s on line %d
|
||||||
|
NULL
|
||||||
|
|
||||||
|
-- Iteration 22 --
|
||||||
|
|
||||||
|
Warning: scandir() expects parameter 2 to be integer, object given in %s on line %d
|
||||||
|
NULL
|
||||||
|
|
||||||
|
-- Iteration 23 --
|
||||||
|
array(2) {
|
||||||
|
[0]=>
|
||||||
|
string(1) "."
|
||||||
|
[1]=>
|
||||||
|
string(2) ".."
|
||||||
|
}
|
||||||
|
|
||||||
|
-- Iteration 24 --
|
||||||
|
array(2) {
|
||||||
|
[0]=>
|
||||||
|
string(1) "."
|
||||||
|
[1]=>
|
||||||
|
string(2) ".."
|
||||||
|
}
|
||||||
|
|
||||||
|
-- Iteration 25 --
|
||||||
|
|
||||||
|
Warning: scandir() expects parameter 2 to be integer, resource given in %s on line %d
|
||||||
|
NULL
|
||||||
|
===DONE===
|
238
ext/standard/tests/dir/scandir_variation3-win32-mb.phpt
Normal file
238
ext/standard/tests/dir/scandir_variation3-win32-mb.phpt
Normal file
|
@ -0,0 +1,238 @@
|
||||||
|
--TEST--
|
||||||
|
Test scandir() function : usage variations - diff data types as $context arg
|
||||||
|
--FILE--
|
||||||
|
<?php
|
||||||
|
/* Prototype : array scandir(string $dir [, int $sorting_order [, resource $context]])
|
||||||
|
* Description: List files & directories inside the specified path
|
||||||
|
* Source code: ext/standard/dir.c
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Pass different data types as $context argument to test how scandir() behaves
|
||||||
|
*/
|
||||||
|
|
||||||
|
echo "*** Testing scandir() : usage variations ***\n";
|
||||||
|
|
||||||
|
// Initialise function arguments not being substituted
|
||||||
|
$dir = dirname(__FILE__) . '/私はガラスを食べられますscandir_variation3';
|
||||||
|
mkdir($dir);
|
||||||
|
$sorting_order = SCANDIR_SORT_ASCENDING;
|
||||||
|
|
||||||
|
//get an unset variable
|
||||||
|
$unset_var = 10;
|
||||||
|
unset ($unset_var);
|
||||||
|
|
||||||
|
// get a class
|
||||||
|
class classA
|
||||||
|
{
|
||||||
|
public function __toString() {
|
||||||
|
return "Class A object";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// heredoc string
|
||||||
|
$heredoc = <<<EOT
|
||||||
|
hello world
|
||||||
|
EOT;
|
||||||
|
|
||||||
|
// get a resource variable
|
||||||
|
$fp = fopen(__FILE__, "r");
|
||||||
|
|
||||||
|
// unexpected values to be passed to $context argument
|
||||||
|
$inputs = array(
|
||||||
|
|
||||||
|
// int data
|
||||||
|
/*1*/ 0,
|
||||||
|
1,
|
||||||
|
12345,
|
||||||
|
-2345,
|
||||||
|
|
||||||
|
// float data
|
||||||
|
/*5*/ 10.5,
|
||||||
|
-10.5,
|
||||||
|
12.3456789000e10,
|
||||||
|
12.3456789000E-10,
|
||||||
|
.5,
|
||||||
|
|
||||||
|
// null data
|
||||||
|
/*10*/ NULL,
|
||||||
|
null,
|
||||||
|
|
||||||
|
// boolean data
|
||||||
|
/*12*/ true,
|
||||||
|
false,
|
||||||
|
TRUE,
|
||||||
|
FALSE,
|
||||||
|
|
||||||
|
// empty data
|
||||||
|
/*16*/ "",
|
||||||
|
'',
|
||||||
|
array(),
|
||||||
|
|
||||||
|
// string data
|
||||||
|
/*19*/ "string",
|
||||||
|
'string',
|
||||||
|
$heredoc,
|
||||||
|
|
||||||
|
// object data
|
||||||
|
/*22*/ new classA(),
|
||||||
|
|
||||||
|
// undefined data
|
||||||
|
/*23*/ @$undefined_var,
|
||||||
|
|
||||||
|
// unset data
|
||||||
|
/*24*/ @$unset_var,
|
||||||
|
|
||||||
|
// resource variable
|
||||||
|
/*25*/ $fp
|
||||||
|
);
|
||||||
|
|
||||||
|
// loop through each element of $inputs to check the behavior of scandir()
|
||||||
|
$iterator = 1;
|
||||||
|
foreach($inputs as $input) {
|
||||||
|
echo "\n-- Iteration $iterator --\n";
|
||||||
|
var_dump( scandir($dir, $sorting_order, $input) );
|
||||||
|
$iterator++;
|
||||||
|
};
|
||||||
|
|
||||||
|
fclose($fp);
|
||||||
|
?>
|
||||||
|
===DONE===
|
||||||
|
--CLEAN--
|
||||||
|
<?php
|
||||||
|
$dir = dirname(__FILE__) . '/私はガラスを食べられますscandir_variation3';
|
||||||
|
rmdir($dir);
|
||||||
|
?>
|
||||||
|
--EXPECTF--
|
||||||
|
*** Testing scandir() : usage variations ***
|
||||||
|
|
||||||
|
-- Iteration 1 --
|
||||||
|
|
||||||
|
Warning: scandir() expects parameter 3 to be resource, integer given in %s on line %d
|
||||||
|
NULL
|
||||||
|
|
||||||
|
-- Iteration 2 --
|
||||||
|
|
||||||
|
Warning: scandir() expects parameter 3 to be resource, integer given in %s on line %d
|
||||||
|
NULL
|
||||||
|
|
||||||
|
-- Iteration 3 --
|
||||||
|
|
||||||
|
Warning: scandir() expects parameter 3 to be resource, integer given in %s on line %d
|
||||||
|
NULL
|
||||||
|
|
||||||
|
-- Iteration 4 --
|
||||||
|
|
||||||
|
Warning: scandir() expects parameter 3 to be resource, integer given in %s on line %d
|
||||||
|
NULL
|
||||||
|
|
||||||
|
-- Iteration 5 --
|
||||||
|
|
||||||
|
Warning: scandir() expects parameter 3 to be resource, float given in %s on line %d
|
||||||
|
NULL
|
||||||
|
|
||||||
|
-- Iteration 6 --
|
||||||
|
|
||||||
|
Warning: scandir() expects parameter 3 to be resource, float given in %s on line %d
|
||||||
|
NULL
|
||||||
|
|
||||||
|
-- Iteration 7 --
|
||||||
|
|
||||||
|
Warning: scandir() expects parameter 3 to be resource, float given in %s on line %d
|
||||||
|
NULL
|
||||||
|
|
||||||
|
-- Iteration 8 --
|
||||||
|
|
||||||
|
Warning: scandir() expects parameter 3 to be resource, float given in %s on line %d
|
||||||
|
NULL
|
||||||
|
|
||||||
|
-- Iteration 9 --
|
||||||
|
|
||||||
|
Warning: scandir() expects parameter 3 to be resource, float given in %s on line %d
|
||||||
|
NULL
|
||||||
|
|
||||||
|
-- Iteration 10 --
|
||||||
|
|
||||||
|
Warning: scandir() expects parameter 3 to be resource, null given in %s on line %d
|
||||||
|
NULL
|
||||||
|
|
||||||
|
-- Iteration 11 --
|
||||||
|
|
||||||
|
Warning: scandir() expects parameter 3 to be resource, null given in %s on line %d
|
||||||
|
NULL
|
||||||
|
|
||||||
|
-- Iteration 12 --
|
||||||
|
|
||||||
|
Warning: scandir() expects parameter 3 to be resource, boolean given in %s on line %d
|
||||||
|
NULL
|
||||||
|
|
||||||
|
-- Iteration 13 --
|
||||||
|
|
||||||
|
Warning: scandir() expects parameter 3 to be resource, boolean given in %s on line %d
|
||||||
|
NULL
|
||||||
|
|
||||||
|
-- Iteration 14 --
|
||||||
|
|
||||||
|
Warning: scandir() expects parameter 3 to be resource, boolean given in %s on line %d
|
||||||
|
NULL
|
||||||
|
|
||||||
|
-- Iteration 15 --
|
||||||
|
|
||||||
|
Warning: scandir() expects parameter 3 to be resource, boolean given in %s on line %d
|
||||||
|
NULL
|
||||||
|
|
||||||
|
-- Iteration 16 --
|
||||||
|
|
||||||
|
Warning: scandir() expects parameter 3 to be resource, string given in %s on line %d
|
||||||
|
NULL
|
||||||
|
|
||||||
|
-- Iteration 17 --
|
||||||
|
|
||||||
|
Warning: scandir() expects parameter 3 to be resource, string given in %s on line %d
|
||||||
|
NULL
|
||||||
|
|
||||||
|
-- Iteration 18 --
|
||||||
|
|
||||||
|
Warning: scandir() expects parameter 3 to be resource, array given in %s on line %d
|
||||||
|
NULL
|
||||||
|
|
||||||
|
-- Iteration 19 --
|
||||||
|
|
||||||
|
Warning: scandir() expects parameter 3 to be resource, string given in %s on line %d
|
||||||
|
NULL
|
||||||
|
|
||||||
|
-- Iteration 20 --
|
||||||
|
|
||||||
|
Warning: scandir() expects parameter 3 to be resource, string given in %s on line %d
|
||||||
|
NULL
|
||||||
|
|
||||||
|
-- Iteration 21 --
|
||||||
|
|
||||||
|
Warning: scandir() expects parameter 3 to be resource, string given in %s on line %d
|
||||||
|
NULL
|
||||||
|
|
||||||
|
-- Iteration 22 --
|
||||||
|
|
||||||
|
Warning: scandir() expects parameter 3 to be resource, object given in %s on line %d
|
||||||
|
NULL
|
||||||
|
|
||||||
|
-- Iteration 23 --
|
||||||
|
|
||||||
|
Warning: scandir() expects parameter 3 to be resource, null given in %s on line %d
|
||||||
|
NULL
|
||||||
|
|
||||||
|
-- Iteration 24 --
|
||||||
|
|
||||||
|
Warning: scandir() expects parameter 3 to be resource, null given in %s on line %d
|
||||||
|
NULL
|
||||||
|
|
||||||
|
-- Iteration 25 --
|
||||||
|
|
||||||
|
Warning: scandir(): supplied resource is not a valid Stream-Context resource in %s on line %d
|
||||||
|
array(2) {
|
||||||
|
[0]=>
|
||||||
|
string(1) "."
|
||||||
|
[1]=>
|
||||||
|
string(2) ".."
|
||||||
|
}
|
||||||
|
===DONE===
|
169
ext/standard/tests/dir/scandir_variation4-win32-mb.phpt
Normal file
169
ext/standard/tests/dir/scandir_variation4-win32-mb.phpt
Normal file
|
@ -0,0 +1,169 @@
|
||||||
|
--TEST--
|
||||||
|
Test scandir() function : usage variations - different relative paths
|
||||||
|
--FILE--
|
||||||
|
<?php
|
||||||
|
/* Prototype : array scandir(string $dir [, int $sorting_order [, resource $context]])
|
||||||
|
* Description: List files & directories inside the specified path
|
||||||
|
* Source code: ext/standard/dir.c
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Test scandir() with relative paths as $dir argument
|
||||||
|
*/
|
||||||
|
|
||||||
|
echo "*** Testing scandir() : usage variations ***\n";
|
||||||
|
|
||||||
|
// include for create_files/delete_files functions
|
||||||
|
include (dirname(__FILE__) . '/../file/file.inc');
|
||||||
|
|
||||||
|
$base_dir_path = dirname(__FILE__);
|
||||||
|
|
||||||
|
$level_one_dir_path = "$base_dir_path/私はガラスを食べられますlevel_one";
|
||||||
|
$level_two_dir_path = "$level_one_dir_path/私はガラスを食べられますlevel_two";
|
||||||
|
|
||||||
|
// create directories and files
|
||||||
|
mkdir($level_one_dir_path);
|
||||||
|
create_files($level_one_dir_path, 2, 'numeric', 0755, 1, 'w', '私はガラスを食べられますlevel_one', 1);
|
||||||
|
mkdir($level_two_dir_path);
|
||||||
|
create_files($level_two_dir_path, 2, 'numeric', 0755, 1, 'w', '私はガラスを食べられますlevel_two', 1);
|
||||||
|
|
||||||
|
echo "\n-- \$path = './私はガラスを食べられますlevel_one': --\n";
|
||||||
|
var_dump(chdir($base_dir_path));
|
||||||
|
var_dump(scandir('./私はガラスを食べられますlevel_one'));
|
||||||
|
|
||||||
|
echo "\n-- \$path = 'level_one/私はガラスを食べられますlevel_two': --\n";
|
||||||
|
var_dump(chdir($base_dir_path));
|
||||||
|
var_dump(scandir('私はガラスを食べられますlevel_one/私はガラスを食べられますlevel_two'));
|
||||||
|
|
||||||
|
echo "\n-- \$path = '..': --\n";
|
||||||
|
var_dump(chdir($level_two_dir_path));
|
||||||
|
var_dump(scandir('..'));
|
||||||
|
|
||||||
|
echo "\n-- \$path = '私はガラスを食べられますlevel_two', '.': --\n";
|
||||||
|
var_dump(chdir($level_two_dir_path));
|
||||||
|
var_dump(scandir('.'));
|
||||||
|
|
||||||
|
echo "\n-- \$path = '../': --\n";
|
||||||
|
var_dump(chdir($level_two_dir_path));
|
||||||
|
var_dump(scandir('../'));
|
||||||
|
|
||||||
|
echo "\n-- \$path = './': --\n";
|
||||||
|
var_dump(chdir($level_two_dir_path));
|
||||||
|
var_dump(scandir('./'));
|
||||||
|
|
||||||
|
echo "\n-- \$path = '../../'私はガラスを食べられますlevel_one': --\n";
|
||||||
|
var_dump(chdir($level_two_dir_path));
|
||||||
|
var_dump(scandir('../../私はガラスを食べられますlevel_one'));
|
||||||
|
|
||||||
|
@delete_files($level_one_dir_path, 2, '私はガラスを食べられますlevel_one');
|
||||||
|
@delete_files($level_two_dir_path, 2, '私はガラスを食べられますlevel_two');
|
||||||
|
?>
|
||||||
|
===DONE===
|
||||||
|
--CLEAN--
|
||||||
|
<?php
|
||||||
|
$dir_path = dirname(__FILE__);
|
||||||
|
rmdir("$dir_path/私はガラスを食べられますlevel_one/私はガラスを食べられますlevel_two");
|
||||||
|
rmdir("$dir_path/私はガラスを食べられますlevel_one");
|
||||||
|
?>
|
||||||
|
--EXPECTF--
|
||||||
|
*** Testing scandir() : usage variations ***
|
||||||
|
|
||||||
|
-- $path = './私はガラスを食べられますlevel_one': --
|
||||||
|
bool(true)
|
||||||
|
array(5) {
|
||||||
|
[0]=>
|
||||||
|
string(1) "."
|
||||||
|
[1]=>
|
||||||
|
string(2) ".."
|
||||||
|
[2]=>
|
||||||
|
string(50) "私はガラスを食べられますlevel_one1.tmp"
|
||||||
|
[3]=>
|
||||||
|
string(50) "私はガラスを食べられますlevel_one2.tmp"
|
||||||
|
[4]=>
|
||||||
|
string(45) "私はガラスを食べられますlevel_two"
|
||||||
|
}
|
||||||
|
|
||||||
|
-- $path = 'level_one/私はガラスを食べられますlevel_two': --
|
||||||
|
bool(true)
|
||||||
|
array(4) {
|
||||||
|
[0]=>
|
||||||
|
string(1) "."
|
||||||
|
[1]=>
|
||||||
|
string(2) ".."
|
||||||
|
[2]=>
|
||||||
|
string(50) "私はガラスを食べられますlevel_two1.tmp"
|
||||||
|
[3]=>
|
||||||
|
string(50) "私はガラスを食べられますlevel_two2.tmp"
|
||||||
|
}
|
||||||
|
|
||||||
|
-- $path = '..': --
|
||||||
|
bool(true)
|
||||||
|
array(5) {
|
||||||
|
[0]=>
|
||||||
|
string(1) "."
|
||||||
|
[1]=>
|
||||||
|
string(2) ".."
|
||||||
|
[2]=>
|
||||||
|
string(50) "私はガラスを食べられますlevel_one1.tmp"
|
||||||
|
[3]=>
|
||||||
|
string(50) "私はガラスを食べられますlevel_one2.tmp"
|
||||||
|
[4]=>
|
||||||
|
string(45) "私はガラスを食べられますlevel_two"
|
||||||
|
}
|
||||||
|
|
||||||
|
-- $path = '私はガラスを食べられますlevel_two', '.': --
|
||||||
|
bool(true)
|
||||||
|
array(4) {
|
||||||
|
[0]=>
|
||||||
|
string(1) "."
|
||||||
|
[1]=>
|
||||||
|
string(2) ".."
|
||||||
|
[2]=>
|
||||||
|
string(50) "私はガラスを食べられますlevel_two1.tmp"
|
||||||
|
[3]=>
|
||||||
|
string(50) "私はガラスを食べられますlevel_two2.tmp"
|
||||||
|
}
|
||||||
|
|
||||||
|
-- $path = '../': --
|
||||||
|
bool(true)
|
||||||
|
array(5) {
|
||||||
|
[0]=>
|
||||||
|
string(1) "."
|
||||||
|
[1]=>
|
||||||
|
string(2) ".."
|
||||||
|
[2]=>
|
||||||
|
string(50) "私はガラスを食べられますlevel_one1.tmp"
|
||||||
|
[3]=>
|
||||||
|
string(50) "私はガラスを食べられますlevel_one2.tmp"
|
||||||
|
[4]=>
|
||||||
|
string(45) "私はガラスを食べられますlevel_two"
|
||||||
|
}
|
||||||
|
|
||||||
|
-- $path = './': --
|
||||||
|
bool(true)
|
||||||
|
array(4) {
|
||||||
|
[0]=>
|
||||||
|
string(1) "."
|
||||||
|
[1]=>
|
||||||
|
string(2) ".."
|
||||||
|
[2]=>
|
||||||
|
string(50) "私はガラスを食べられますlevel_two1.tmp"
|
||||||
|
[3]=>
|
||||||
|
string(50) "私はガラスを食べられますlevel_two2.tmp"
|
||||||
|
}
|
||||||
|
|
||||||
|
-- $path = '../../'私はガラスを食べられますlevel_one': --
|
||||||
|
bool(true)
|
||||||
|
array(5) {
|
||||||
|
[0]=>
|
||||||
|
string(1) "."
|
||||||
|
[1]=>
|
||||||
|
string(2) ".."
|
||||||
|
[2]=>
|
||||||
|
string(50) "私はガラスを食べられますlevel_one1.tmp"
|
||||||
|
[3]=>
|
||||||
|
string(50) "私はガラスを食べられますlevel_one2.tmp"
|
||||||
|
[4]=>
|
||||||
|
string(45) "私はガラスを食べられますlevel_two"
|
||||||
|
}
|
||||||
|
===DONE===
|
154
ext/standard/tests/dir/scandir_variation8-win32-mb.phpt
Normal file
154
ext/standard/tests/dir/scandir_variation8-win32-mb.phpt
Normal file
|
@ -0,0 +1,154 @@
|
||||||
|
--TEST--
|
||||||
|
Test scandir() function : usage variations - different file names
|
||||||
|
--FILE--
|
||||||
|
<?php
|
||||||
|
/* Prototype : array scandir(string $dir [, int $sorting_order [, resource $context]])
|
||||||
|
* Description: List files & directories inside the specified path
|
||||||
|
* Source code: ext/standard/dir.c
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Pass a directory containing files with different types of names to test how scandir()
|
||||||
|
* reads them
|
||||||
|
*/
|
||||||
|
|
||||||
|
echo "*** Testing scandir() : usage variations ***\n";
|
||||||
|
|
||||||
|
$dir_path = dirname(__FILE__) . "/私はガラスを食べられますscandir_variation8/";
|
||||||
|
mkdir($dir_path);
|
||||||
|
|
||||||
|
// heredoc string
|
||||||
|
$heredoc = <<<EOT
|
||||||
|
hd_file
|
||||||
|
EOT;
|
||||||
|
|
||||||
|
$inputs = array(
|
||||||
|
|
||||||
|
// int data
|
||||||
|
/*1*/ 0,
|
||||||
|
1,
|
||||||
|
12345,
|
||||||
|
-2345,
|
||||||
|
|
||||||
|
// float data
|
||||||
|
/*5*/ 10.5,
|
||||||
|
-10.5,
|
||||||
|
12.3456789000e10,
|
||||||
|
12.3456789000E-10,
|
||||||
|
.5,
|
||||||
|
|
||||||
|
// empty data
|
||||||
|
/*10*/ "",
|
||||||
|
array(),
|
||||||
|
|
||||||
|
// string data
|
||||||
|
/*12*/ "double_file",
|
||||||
|
'single_file',
|
||||||
|
$heredoc,
|
||||||
|
);
|
||||||
|
|
||||||
|
$iterator = 1;
|
||||||
|
foreach($inputs as $key => $input) {
|
||||||
|
echo "\n-- Iteration $iterator --\n";
|
||||||
|
$handle = "fp{$iterator}";
|
||||||
|
var_dump( $$handle = @fopen($dir_path . "/私はガラスを食べられます$input.tmp", 'w') );
|
||||||
|
fclose($$handle);
|
||||||
|
$iterator++;
|
||||||
|
};
|
||||||
|
|
||||||
|
echo "\n-- Call to scandir() --\n";
|
||||||
|
var_dump($content = scandir($dir_path));
|
||||||
|
|
||||||
|
// remove all files in directory so can remove directory in CLEAN section
|
||||||
|
foreach ($content as $file_name) {
|
||||||
|
// suppress errors as won't be able to remove "." and ".." entries
|
||||||
|
@unlink($dir_path . $file_name);
|
||||||
|
}
|
||||||
|
?>
|
||||||
|
===DONE===
|
||||||
|
--CLEAN--
|
||||||
|
<?php
|
||||||
|
$dir_path = dirname(__FILE__) . "/私はガラスを食べられますscandir_variation8";
|
||||||
|
rmdir($dir_path);
|
||||||
|
?>
|
||||||
|
--EXPECTF--
|
||||||
|
*** Testing scandir() : usage variations ***
|
||||||
|
|
||||||
|
-- Iteration 1 --
|
||||||
|
resource(%d) of type (stream)
|
||||||
|
|
||||||
|
-- Iteration 2 --
|
||||||
|
resource(%d) of type (stream)
|
||||||
|
|
||||||
|
-- Iteration 3 --
|
||||||
|
resource(%d) of type (stream)
|
||||||
|
|
||||||
|
-- Iteration 4 --
|
||||||
|
resource(%d) of type (stream)
|
||||||
|
|
||||||
|
-- Iteration 5 --
|
||||||
|
resource(%d) of type (stream)
|
||||||
|
|
||||||
|
-- Iteration 6 --
|
||||||
|
resource(%d) of type (stream)
|
||||||
|
|
||||||
|
-- Iteration 7 --
|
||||||
|
resource(%d) of type (stream)
|
||||||
|
|
||||||
|
-- Iteration 8 --
|
||||||
|
resource(%d) of type (stream)
|
||||||
|
|
||||||
|
-- Iteration 9 --
|
||||||
|
resource(%d) of type (stream)
|
||||||
|
|
||||||
|
-- Iteration 10 --
|
||||||
|
resource(%d) of type (stream)
|
||||||
|
|
||||||
|
-- Iteration 11 --
|
||||||
|
resource(%d) of type (stream)
|
||||||
|
|
||||||
|
-- Iteration 12 --
|
||||||
|
resource(%d) of type (stream)
|
||||||
|
|
||||||
|
-- Iteration 13 --
|
||||||
|
resource(%d) of type (stream)
|
||||||
|
|
||||||
|
-- Iteration 14 --
|
||||||
|
resource(%d) of type (stream)
|
||||||
|
|
||||||
|
-- Call to scandir() --
|
||||||
|
array(16) {
|
||||||
|
[0]=>
|
||||||
|
string(1) "."
|
||||||
|
[1]=>
|
||||||
|
string(2) ".."
|
||||||
|
[2]=>
|
||||||
|
string(45) "私はガラスを食べられます-10.5.tmp"
|
||||||
|
[3]=>
|
||||||
|
string(45) "私はガラスを食べられます-2345.tmp"
|
||||||
|
[4]=>
|
||||||
|
string(40) "私はガラスを食べられます.tmp"
|
||||||
|
[5]=>
|
||||||
|
string(43) "私はガラスを食べられます0.5.tmp"
|
||||||
|
[6]=>
|
||||||
|
string(41) "私はガラスを食べられます0.tmp"
|
||||||
|
[7]=>
|
||||||
|
string(53) "私はガラスを食べられます1.23456789E-9.tmp"
|
||||||
|
[8]=>
|
||||||
|
string(41) "私はガラスを食べられます1.tmp"
|
||||||
|
[9]=>
|
||||||
|
string(44) "私はガラスを食べられます10.5.tmp"
|
||||||
|
[10]=>
|
||||||
|
string(45) "私はガラスを食べられます12345.tmp"
|
||||||
|
[11]=>
|
||||||
|
string(52) "私はガラスを食べられます123456789000.tmp"
|
||||||
|
[12]=>
|
||||||
|
string(45) "私はガラスを食べられますArray.tmp"
|
||||||
|
[13]=>
|
||||||
|
string(51) "私はガラスを食べられますdouble_file.tmp"
|
||||||
|
[14]=>
|
||||||
|
string(47) "私はガラスを食べられますhd_file.tmp"
|
||||||
|
[15]=>
|
||||||
|
string(51) "私はガラスを食べられますsingle_file.tmp"
|
||||||
|
}
|
||||||
|
===DONE===
|
72
ext/standard/tests/dir/scandir_variation9-win32-mb.phpt
Normal file
72
ext/standard/tests/dir/scandir_variation9-win32-mb.phpt
Normal file
|
@ -0,0 +1,72 @@
|
||||||
|
--TEST--
|
||||||
|
Test scandir() function : usage variations - different ints as $sorting_order arg
|
||||||
|
--FILE--
|
||||||
|
<?php
|
||||||
|
/* Prototype : array scandir(string $dir [, int $sorting_order [, resource $context]])
|
||||||
|
* Description: List files & directories inside the specified path
|
||||||
|
* Source code: ext/standard/dir.c
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Pass different integers as $sorting_order argument to test how scandir()
|
||||||
|
* re-orders the array
|
||||||
|
*/
|
||||||
|
|
||||||
|
echo "*** Testing scandir() : usage variations ***\n";
|
||||||
|
|
||||||
|
// include for create_files/delete_files functions
|
||||||
|
include(dirname(__FILE__) . '/../file/file.inc');
|
||||||
|
|
||||||
|
// create directory and files
|
||||||
|
$dir = dirname(__FILE__) . '/私はガラスを食べられますscandir_variation9';
|
||||||
|
mkdir($dir);
|
||||||
|
@create_files($dir, 2, "numeric", 0755, 1, "w", "私はガラスを食べられますfile");
|
||||||
|
|
||||||
|
// different ints to pass as $sorting_order argument
|
||||||
|
$ints = array (PHP_INT_MAX, -PHP_INT_MAX, 0);
|
||||||
|
|
||||||
|
foreach($ints as $sorting_order) {
|
||||||
|
var_dump( scandir($dir, $sorting_order) );
|
||||||
|
}
|
||||||
|
|
||||||
|
delete_files($dir, 2, "私はガラスを食べられますfile");
|
||||||
|
?>
|
||||||
|
===DONE===
|
||||||
|
--CLEAN--
|
||||||
|
<?php
|
||||||
|
$dir = dirname(__FILE__) . '/私はガラスを食べられますscandir_variation9';
|
||||||
|
rmdir($dir);
|
||||||
|
?>
|
||||||
|
--EXPECTF--
|
||||||
|
*** Testing scandir() : usage variations ***
|
||||||
|
array(4) {
|
||||||
|
[0]=>
|
||||||
|
string(45) "私はガラスを食べられますfile2.tmp"
|
||||||
|
[1]=>
|
||||||
|
string(45) "私はガラスを食べられますfile1.tmp"
|
||||||
|
[2]=>
|
||||||
|
string(2) ".."
|
||||||
|
[3]=>
|
||||||
|
string(1) "."
|
||||||
|
}
|
||||||
|
array(4) {
|
||||||
|
[0]=>
|
||||||
|
string(45) "私はガラスを食べられますfile2.tmp"
|
||||||
|
[1]=>
|
||||||
|
string(45) "私はガラスを食べられますfile1.tmp"
|
||||||
|
[2]=>
|
||||||
|
string(2) ".."
|
||||||
|
[3]=>
|
||||||
|
string(1) "."
|
||||||
|
}
|
||||||
|
array(4) {
|
||||||
|
[0]=>
|
||||||
|
string(1) "."
|
||||||
|
[1]=>
|
||||||
|
string(2) ".."
|
||||||
|
[2]=>
|
||||||
|
string(45) "私はガラスを食べられますfile1.tmp"
|
||||||
|
[3]=>
|
||||||
|
string(45) "私はガラスを食べられますfile2.tmp"
|
||||||
|
}
|
||||||
|
===DONE===
|
|
@ -0,0 +1,69 @@
|
||||||
|
--TEST--
|
||||||
|
Directory class behaviour.
|
||||||
|
--FILE--
|
||||||
|
<?php
|
||||||
|
|
||||||
|
$d = getcwd().PATH_SEPARATOR."私はガラスを食べられます";
|
||||||
|
|
||||||
|
mkdir($d);
|
||||||
|
|
||||||
|
echo "\n--> Try all methods with bad handle:\n";
|
||||||
|
$d = new Directory($d);
|
||||||
|
$d->handle = "Havoc!";
|
||||||
|
var_dump($d->read());
|
||||||
|
var_dump($d->rewind());
|
||||||
|
var_dump($d->close());
|
||||||
|
|
||||||
|
echo "\n--> Try all methods with no handle:\n";
|
||||||
|
$d = new Directory($d);
|
||||||
|
unset($d->handle);
|
||||||
|
var_dump($d->read());
|
||||||
|
var_dump($d->rewind());
|
||||||
|
var_dump($d->close());
|
||||||
|
|
||||||
|
echo "\n--> Try all methods with wrong number of args:\n";
|
||||||
|
$d = new Directory($d);
|
||||||
|
var_dump($d->read(1,2));
|
||||||
|
var_dump($d->rewind(1,2));
|
||||||
|
var_dump($d->close(1,2));
|
||||||
|
|
||||||
|
?>
|
||||||
|
--CLEAN--
|
||||||
|
<?php
|
||||||
|
$d = getcwd().PATH_SEPARATOR."私はガラスを食べられます";
|
||||||
|
rmdir($d);
|
||||||
|
|
||||||
|
?>
|
||||||
|
--EXPECTF--
|
||||||
|
--> Try all methods with bad handle:
|
||||||
|
|
||||||
|
Warning: Directory::read(): supplied argument is not a valid Directory resource in %s on line %d
|
||||||
|
bool(false)
|
||||||
|
|
||||||
|
Warning: Directory::rewind(): supplied argument is not a valid Directory resource in %s on line %d
|
||||||
|
bool(false)
|
||||||
|
|
||||||
|
Warning: Directory::close(): supplied argument is not a valid Directory resource in %s on line %d
|
||||||
|
bool(false)
|
||||||
|
|
||||||
|
--> Try all methods with no handle:
|
||||||
|
|
||||||
|
Warning: Directory::read(): Unable to find my handle property in %s on line %d
|
||||||
|
bool(false)
|
||||||
|
|
||||||
|
Warning: Directory::rewind(): Unable to find my handle property in %s on line %d
|
||||||
|
bool(false)
|
||||||
|
|
||||||
|
Warning: Directory::close(): Unable to find my handle property in %s on line %d
|
||||||
|
bool(false)
|
||||||
|
|
||||||
|
--> Try all methods with wrong number of args:
|
||||||
|
|
||||||
|
Warning: Directory::read() expects at most 1 parameter, 2 given in %s on line %d
|
||||||
|
NULL
|
||||||
|
|
||||||
|
Warning: Directory::rewind() expects at most 1 parameter, 2 given in %s on line %d
|
||||||
|
NULL
|
||||||
|
|
||||||
|
Warning: Directory::close() expects at most 1 parameter, 2 given in %s on line %d
|
||||||
|
NULL
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Add a link
Reference in a new issue