|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2008-06-10 15:56 UTC] nanawel at eyeos dot org
Description: ------------ The unlink() function does not work with full Windows URL, whereas fopen() for example works perfectly. If you provide a path like this: file:///C:/my/path (triple slashes) it won't work and you will get this warning: Warning: unlink(/C:/my/path) [function.unlink]: Invalid argument in... But if you provide this path: file://C:/my/path (so just a slash less) unlink will work. Reproduce code: --------------- //For the example, we consider that PHP has full permissions on config.sys, which is not the case normally) $path1 = 'file:///C:/config.sys'; $path2 = 'file://C:/config.sys'; $fp = fopen($path1, 'r'); //OK @fclose($fp); unlink($path1); //ERROR $fp = fopen($path2, 'r'); //OK @fclose($fp); unlink($path2); //OK Expected result: ---------------- unlink() should work with the same standards URL as fopen(). In my example, $path1 should be correct for both functions. Actual result: -------------- Windows absolute URL like file:///C:/... work with fopen(), rename() but _not_ with unlink() (+ Warning raised) Windows non-standard URL like file://C:/... work with fopen(), rename() and unlink() PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Fri Nov 28 20:00:01 2025 UTC |
Ok, to sum up: - mkdir() works with file://C:/my/path under Windows FAILS with file:///C:/my/path under Windows FAILS with file://localhost/C:/my/path under Windows - rmdir() FAILS with ALL file:// schemes under Windows and Linux - unlink() works with file://C:/my/path under Windows FAILS with file:///C:/my/path under Windows FAILS with file://localhost/C:/my/path under Windows I think I didn't forget anything, hope this helps.Some notes: - mkdir() works with file://C:/my/path under Windows expected. FAILS with file:///C:/my/path under Windows expected (/c:/my/path is not a valid path) FAILS with file://localhost/C:/my/path under Windows expected,localhost/C:/my/path is not a valid path (same for linux, fails as well) However, the touch() funciton seems to have issue with file://, maybe other as well but I did not test them all yet. - rmdir() FAILS with ALL file:// schemes under Windows and Linux