@Robert I know windows has problems with moving files that are opened
by other processes,
BUT this still works fine on Windows 10 running on NTFS:
<?php
$h = tmpfile();
$path = stream_get_meta_data($h)['uri'];
var_dump(rename($path, __DIR__.'/test.f'));
?>
rename returns true and the file really is moved (and the file is no
longer automatically deleted - i suspect PHP's tmpfile() try to delete
the original path on cleanup, and don't keep track of renames/movings)


On Sat, 29 Apr 2023 at 14:56, Robert Landers <landers.rob...@gmail.com> wrote:
>
> On Sat, Apr 29, 2023 at 9:33 AM Dan Liebner <dlieb...@gmail.com> wrote:
> >
> > Are there any inherent problems with moving a file created with tmpfile()?
> > In practice, it seems that it can be done and the file will not be deleted
> > after being moved and the file handle closed.
> >
> > Thanks,
> > Dan
>
> I suspect it depends on the OS. For example, in Linux, you can delete
> a file you are writing to without issues, but you cannot in Windows.
>
> --
> PHP Internals - PHP Runtime Development Mailing List
> To unsubscribe, visit: https://www.php.net/unsub.php
>

--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: https://www.php.net/unsub.php

Reply via email to