Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions ext/phar/tests/phar_buildfromdirectory2-win.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,6 @@ try {
echo $e->getMessage() . "\n";
}
?>
--EXPECTF--
%s(24) "UnexpectedValueException"
RecursiveDirectoryIterator::__construct(1): %s (code: 2)
--EXPECT--
string(24) "UnexpectedValueException"
RecursiveDirectoryIterator::__construct(1): Failed to open directory: No such file or directory
2 changes: 0 additions & 2 deletions ext/phar/tests/phar_gobyebye-win32.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,4 @@ bool(false)
bool(false)
bool(false)

Warning: opendir(foo/hi): %s (code: 3) in phar://%sphar_gobyebye-win32.phar.php/foo/hi on line %d

Warning: opendir(foo/hi): Failed to open directory: No such file or directory in phar://%sphar_gobyebye-win32.phar.php/foo/hi on line %d
6 changes: 0 additions & 6 deletions ext/standard/tests/dir/bug80960.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,8 @@ opendir("notexist?");
opendir(str_pad("longname", PHP_MAXPATHLEN - strlen(getcwd()), "_"));
?>
--EXPECTF--
Warning: opendir(notexist*): %s (code: 123) in %s on line %d

Warning: opendir(notexist*): Failed to open directory: No such file or directory in %s on line %d

Warning: opendir(notexist?): %s (code: 123) in %s on line %d

Warning: opendir(notexist?): Failed to open directory: No such file or directory in %s on line %d

Warning: opendir(longname%r_+%r): %s (code: 111) in %s on line %d

Warning: opendir(longname%r_+%r): Failed to open directory: Filename too long in %s on line %d
8 changes: 0 additions & 8 deletions ext/standard/tests/dir/opendir_variation6-win32.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -46,23 +46,15 @@ rmdir($dir_path);
-- Wildcard = '*' --

Warning: opendir(%s/opendir_var*): %s in %s on line %d

Warning: opendir(%s/opendir_var*): Failed to open directory: %s in %s on line %d
bool(false)

Warning: opendir(%s/*): %s in %s on line %d

Warning: opendir(%s/*): Failed to open directory: %s in %s on line %d
bool(false)

-- Wildcard = '?' --

Warning: opendir(%s/opendir_variation6/sub_dir?): %s in %s on line %d

Warning: opendir(%s/opendir_variation6/sub_dir?): Failed to open directory: %s in %s on line %d
bool(false)

Warning: opendir(%s/opendir_variation6/sub?dir1): %s in %s on line %d

Warning: opendir(%s/opendir_variation6/sub?dir1): Failed to open directory: %s in %s on line %d
bool(false)
2 changes: 1 addition & 1 deletion ext/standard/tests/file/rename_variation-win32.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ bool(false)
bool(true)
-- Iteration 2 --

Warning: rename(%s/rename_variation-win32/rename_variation.tmp/,%s/rename_variation2.tmp): %rThe filename, directory name, or volume label syntax is incorrect|The directory name is invalid%r (code: %r123|267%r) in %s on line %d
Warning: rename(): %rThe filename, directory name, or volume label syntax is incorrect|The directory name is invalid%r (code: %r123|267%r) in %s on line %d
bool(false)
bool(false)
bool(false)
Expand Down
6 changes: 3 additions & 3 deletions ext/standard/tests/file/rename_variation11-win32.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -86,12 +86,12 @@ bool(true)

-- Iteration 5 --

Warning: rename(%s\renameVar11\renameVar11Sub\..\\\renameVar11Sub\\..\\..\renameVar11Sub\renameMe.tmp,%s\renameVar11\renameVar11Sub\..\\\renameVar11Sub\\..\\..\renameVar11Sub\IwasRenamed.tmp): The system cannot find the path specified (code: 3) in %s on line %d
Warning: rename(): The system cannot find the path specified (code: 3) in %s on line %d
bool(false)

-- Iteration 6 --

Warning: rename(%s\renameVar11\renameVar11Sub\BADDIR\renameMe.tmp,%s\renameVar11\renameVar11Sub\BADDIR\IwasRenamed.tmp): The system cannot find the path specified (code: 3) in %s on line %d
Warning: rename(): The system cannot find the path specified (code: 3) in %s on line %d
bool(false)

-- Iteration 7 --
Expand All @@ -112,7 +112,7 @@ bool(true)

-- Iteration 11 --

Warning: rename(BADDIR\renameMe.tmp,BADDIR\IwasRenamed.tmp): The system cannot find the path specified (code: 3) in %s on line %d
Warning: rename(): The system cannot find the path specified (code: 3) in %s on line %d
bool(false)

-- Iteration 12 --
Expand Down
6 changes: 3 additions & 3 deletions ext/standard/tests/file/rename_variation12-win32.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -83,12 +83,12 @@ bool(true)

-- Iteration 5 --

Warning: rename(%s/renameVar12/renameVar12Sub/..///renameVar12Sub//..//../renameVar12Sub/renameMe.tmp,%s/renameVar12/renameVar12Sub/..///renameVar12Sub//..//../renameVar12Sub/IwasRenamed.tmp): The system cannot find the path specified (code: 3) in %s on line %d
Warning: rename(): The system cannot find the path specified (code: 3) in %s on line %d
bool(false)

-- Iteration 6 --

Warning: rename(%s/renameVar12/renameVar12Sub/BADDIR/renameMe.tmp,%s/renameVar12/renameVar12Sub/BADDIR/IwasRenamed.tmp): The system cannot find the path specified (code: 3) in %s on line %d
Warning: rename(): The system cannot find the path specified (code: 3) in %s on line %d
bool(false)

-- Iteration 7 --
Expand All @@ -109,7 +109,7 @@ bool(true)

-- Iteration 11 --

Warning: rename(BADDIR/renameMe.tmp,BADDIR/IwasRenamed.tmp): The system cannot find the path specified (code: 3) in %s on line %d
Warning: rename(): The system cannot find the path specified (code: 3) in %s on line %d
bool(false)

*** Done ***
24 changes: 12 additions & 12 deletions ext/standard/tests/file/rename_variation13-win32.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -65,45 +65,45 @@ rmdir($file_path);
-- 0 testing '-1' integer --
bool(true)

Warning: rename(-1,%safile.tmp): The system cannot find the file specified (code: 2) in %srename_variation13-win32.php on line %d
Warning: rename(): The system cannot find the file specified (code: 2) in %srename_variation13-win32.php on line %d
bool(false)
-- 1 testing '1' boolean --
bool(true)

Warning: rename(1,%safile.tmp): The system cannot find the file specified (code: 2) in %srename_variation13-win32.php on line %d
Warning: rename(): The system cannot find the file specified (code: 2) in %srename_variation13-win32.php on line %d
bool(false)
-- 2 testing '' boolean --

Warning: rename(%safile.tmp,): %r(Invalid argument|(The parameter is incorrect|The system cannot find the path specified) \(code: \d+\))%r in %srename_variation13-win32.php on line %d
Warning: rename(): %r(Invalid argument|(The parameter is incorrect|The system cannot find the path specified) \(code: \d+\))%r in %srename_variation13-win32.php on line %d
bool(false)

Warning: rename(,%safile.tmp): %r(Invalid argument|(The parameter is incorrect|The system cannot find the path specified) \(code: \d+\))%r in %srename_variation13-win32.php on line %d
Warning: rename(): %r(Invalid argument|(The parameter is incorrect|The system cannot find the path specified) \(code: \d+\))%r in %srename_variation13-win32.php on line %d
bool(false)
-- 3 testing '' string --

Warning: rename(%safile.tmp,): %r(Invalid argument|(The parameter is incorrect|The system cannot find the path specified) \(code: \d+\))%r in %srename_variation13-win32.php on line %d
Warning: rename(): %r(Invalid argument|(The parameter is incorrect|The system cannot find the path specified) \(code: \d+\))%r in %srename_variation13-win32.php on line %d
bool(false)

Warning: rename(,%safile.tmp): %r(Invalid argument|(The parameter is incorrect|The system cannot find the path specified) \(code: \d+\))%r in %srename_variation13-win32.php on line %d
Warning: rename(): %r(Invalid argument|(The parameter is incorrect|The system cannot find the path specified) \(code: \d+\))%r in %srename_variation13-win32.php on line %d
bool(false)
-- 4 testing ' ' string --

Warning: rename(%s): The filename, directory name, or volume label syntax is incorrect (code: 123) in %srename_variation13-win32.php on line %d
Warning: rename(): The filename, directory name, or volume label syntax is incorrect (code: 123) in %srename_variation13-win32.php on line %d
bool(false)

Warning: rename(%s): The filename, directory name, or volume label syntax is incorrect (code: 123) in %srename_variation13-win32.php on line %d
Warning: rename(): The filename, directory name, or volume label syntax is incorrect (code: 123) in %srename_variation13-win32.php on line %d
bool(false)
-- 5 testing '/no/such/file/dir' string --

Warning: rename(%safile.tmp,/no/such/file/dir): The system cannot find the path specified (code: 3) in %srename_variation13-win32.php on line %d
Warning: rename(): The system cannot find the path specified (code: 3) in %srename_variation13-win32.php on line %d
bool(false)

Warning: rename(/no/such/file/dir,%safile.tmp): The system cannot find the path specified (code: 3) in %srename_variation13-win32.php on line %d
Warning: rename(): The system cannot find the path specified (code: 3) in %srename_variation13-win32.php on line %d
bool(false)
-- 6 testing 'php/php' string --

Warning: rename(%safile.tmp,php/php): The system cannot find the path specified (code: 3) in %srename_variation13-win32.php on line %d
Warning: rename(): The system cannot find the path specified (code: 3) in %srename_variation13-win32.php on line %d
bool(false)

Warning: rename(php/php,%safile.tmp): The system cannot find the path specified (code: 3) in %srename_variation13-win32.php on line %d
Warning: rename(): The system cannot find the path specified (code: 3) in %srename_variation13-win32.php on line %d
bool(false)
2 changes: 1 addition & 1 deletion ext/standard/tests/file/rename_variation3-win32.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ bool(true)

-- Renaming existing file to existing directory name --

Warning: rename(%s/rename_variation3.tmp,%s/rename_variation3_dir): Access is denied (code: 5) in %s on line %d
Warning: rename(): Access is denied (code: 5) in %s on line %d
bool(false)
bool(true)
bool(true)
Expand Down
4 changes: 2 additions & 2 deletions ext/standard/tests/file/rename_variation8-win32.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ rmdir(__DIR__."/rename_basic_dir1");
--EXPECTF--
*** Testing rename() on non-existing file ***

Warning: rename(%s/non_existent_file.tmp,%s/rename_variation8_new.tmp): The system cannot find the file specified (code: 2) in %s on line %d
Warning: rename(): The system cannot find the file specified (code: 2) in %s on line %d
bool(false)
bool(false)
bool(false)
Expand All @@ -58,7 +58,7 @@ bool(true)

*** Testing rename() on non-existing directory ***

Warning: rename(%s/non_existent_dir,%s/rename_basic_dir2): The system cannot find the file specified (code: 2) in %s on line %d
Warning: rename(): The system cannot find the file specified (code: 2) in %s on line %d
bool(false)
bool(false)
bool(false)
Expand Down
4 changes: 2 additions & 2 deletions ext/standard/tests/general_functions/bug44295-win.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ try {
?>
==DONE==
<?php exit(0); ?>
--EXPECTF--
--EXPECT--
before
in catch: DirectoryIterator::__construct(c:\not\exists\here): %s (code: 3)
in catch: DirectoryIterator::__construct(c:\not\exists\here): Failed to open directory: No such file or directory
==DONE==
21 changes: 0 additions & 21 deletions main/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -1287,27 +1287,6 @@ PHPAPI ZEND_COLD void php_error_docref2(const char *docref, const char *param1,
}
/* }}} */

#ifdef PHP_WIN32
PHPAPI ZEND_COLD void php_win32_docref1_from_error(DWORD error, const char *param1) {
char *buf = php_win32_error_to_msg(error);
size_t buf_len;

buf_len = strlen(buf);
if (buf_len >= 2) {
buf[buf_len - 1] = '\0';
buf[buf_len - 2] = '\0';
}
php_error_docref1(NULL, param1, E_WARNING, "%s (code: %lu)", buf, error);
php_win32_error_msg_free(buf);
}

PHPAPI ZEND_COLD void php_win32_docref2_from_error(DWORD error, const char *param1, const char *param2) {
char *buf = php_win32_error_to_msg(error);
php_error_docref2(NULL, param1, param2, E_WARNING, "%s (code: %lu)", buf, error);
php_win32_error_msg_free(buf);
}
#endif

/* {{{ php_html_puts */
PHPAPI void php_html_puts(const char *str, size_t size)
{
Expand Down
4 changes: 0 additions & 4 deletions main/php.h
Original file line number Diff line number Diff line change
Expand Up @@ -307,10 +307,6 @@ PHPAPI ZEND_COLD void php_error_docref1(const char *docref, const char *param1,
PHP_ATTRIBUTE_FORMAT(printf, 4, 5);
PHPAPI ZEND_COLD void php_error_docref2(const char *docref, const char *param1, const char *param2, int type, const char *format, ...)
PHP_ATTRIBUTE_FORMAT(printf, 5, 6);
#ifdef PHP_WIN32
PHPAPI ZEND_COLD void php_win32_docref1_from_error(DWORD error, const char *param1);
PHPAPI ZEND_COLD void php_win32_docref2_from_error(DWORD error, const char *param1, const char *param2);
#endif
END_EXTERN_C()

#define zenderror phperror
Expand Down
22 changes: 18 additions & 4 deletions main/streams/plain_wrapper.c
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,20 @@ typedef struct {
} php_stdio_stream_data;
#define PHP_STDIOP_GET_FD(anfd, data) anfd = (data)->file ? fileno((data)->file) : (data)->fd

#ifdef PHP_WIN32
static ZEND_COLD void php_win32_stream_wrapper_warn_error(
php_stream_wrapper *wrapper,
php_stream_context *context,
int options,
zend_enum_StreamErrorCode code,
DWORD error
) {
char *buf = php_win32_error_to_msg(error);
php_stream_wrapper_error(wrapper, context, NULL, options, E_WARNING, true, code, "%s (code: %lu)", buf, error);
php_win32_error_msg_free(buf);
}
#endif

static int do_fstat(php_stdio_stream_data *d, int force)
{
if (!d->cached_fstat || (force && !d->no_forced_fstat)) {
Expand Down Expand Up @@ -1130,7 +1144,7 @@ static php_stream *php_plain_files_dir_opener(php_stream_wrapper *wrapper, const

#ifdef PHP_WIN32
if (!dir) {
php_win32_docref1_from_error(GetLastError(), path);
php_win32_stream_wrapper_warn_error(wrapper, context, options, PHP_STREAM_EC(OpenFailed), GetLastError());
}

if (dir && dir->finished) {
Expand Down Expand Up @@ -1336,11 +1350,11 @@ static int php_plain_files_rename(php_stream_wrapper *wrapper, const char *url_f

#ifdef PHP_WIN32
if (!php_win32_check_trailing_space(url_from, strlen(url_from))) {
php_win32_docref2_from_error(ERROR_INVALID_NAME, url_from, url_to);
php_win32_stream_wrapper_warn_error(wrapper, context, options, PHP_STREAM_EC(InvalidPath), ERROR_INVALID_NAME);
return 0;
}
if (!php_win32_check_trailing_space(url_to, strlen(url_to))) {
php_win32_docref2_from_error(ERROR_INVALID_NAME, url_from, url_to);
php_win32_stream_wrapper_warn_error(wrapper, context, options, PHP_STREAM_EC(InvalidPath), ERROR_INVALID_NAME);
return 0;
}
#endif
Expand Down Expand Up @@ -1421,7 +1435,7 @@ static int php_plain_files_rename(php_stream_wrapper *wrapper, const char *url_f
#endif

#ifdef PHP_WIN32
php_win32_docref2_from_error(GetLastError(), url_from, url_to);
php_win32_stream_wrapper_warn_error(wrapper, context, options, PHP_STREAM_EC(RenameFailed), GetLastError());
#else
php_stream_wrapper_warn(wrapper, context, options,
RenameFailed,
Expand Down