Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:120207 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 25081 invoked from network); 7 May 2023 00:30:29 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 7 May 2023 00:30:29 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 72A001804AC for ; Sat, 6 May 2023 17:30:26 -0700 (PDT) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on php-smtp4.php.net X-Spam-Level: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM,HTML_MESSAGE, RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.2 X-Spam-ASN: AS15169 209.85.128.0/17 X-Spam-Virus: No X-Envelope-From: Received: from mail-yb1-f173.google.com (mail-yb1-f173.google.com [209.85.219.173]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-256) server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by php-smtp4.php.net (Postfix) with ESMTPS for ; Sat, 6 May 2023 17:30:25 -0700 (PDT) Received: by mail-yb1-f173.google.com with SMTP id 3f1490d57ef6-b9a6f17f2b6so19732920276.1 for ; Sat, 06 May 2023 17:30:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1683419425; x=1686011425; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=PWLS+g/k8WdM/GnuKfnxB05iB35fhkhmVWYn/N4hVoU=; b=J9Povb94W6c4Tmiudj/rfW5zVlZ3qHUtmGfVLjDy+p28kSpEhogyucvMhkzxov2ksw hFbPKl9/8la4/SlkVY7BmYvkv9jiHo+wYjj0Zj4FSEsBICmKDknMNn6Nk9Zf/CZ9CNro ncgMevIxkBt7GWy8heyln7bFb6xQG24oFo/oS2PSGKYuW6LEDYCDU158P0BFVldkP2ts e+fA6L9V4TvjePrEVDfKn/OkYp7MLWDa5eZ5G1qSIAFzyLrp4o9q/tNSNEwW87J7xNFD 2s/nPJmE1DztCtOc6+p3/51/WafNe/9Cgz3yHNucx+dVPS5TtbQYYDCQwb5U90K+iiyQ 3tUQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1683419425; x=1686011425; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=PWLS+g/k8WdM/GnuKfnxB05iB35fhkhmVWYn/N4hVoU=; b=iTj8nauyitnt24kTlYKp9X/nSSHHBJEL19XMajM/3NZbU4Eiko+4wx5GZ6hE1heLaI IHnulYAeJ6K6VYSWUKjIaXlGh41xe21tbq2UkE9r9j2MMfeMw/4eM7bYH/FHbcIlyrDv hplnTA4EyHMqQa0tfoggcnTJpUmio6JcpcxD5ER8rd1aaJr1w7xoksJreGkCzCcGfcac wH7o0vdGPv0QZPMFMRyEtPpPd48gr8nv2mvmJtMbJTwRNZzobitYGSzb1QjTw+Q78h8P q8forKQmvRMAAyzudbCSMneb9W5E7VRvbp4s/8xyHnKDXumsWeR5zwoGWeXNKX4O/1GY YySw== X-Gm-Message-State: AC+VfDxq6AoRwF7emxLdOlgIYj45YbM7mq7MPzG+oDUB9rrQJTRTI+2C 1+sc+gpqqX0Ky69TMzDKS9zCnSUu2+8QN6PX82k= X-Google-Smtp-Source: ACHHUZ5fn4qlVU0sc8VrjCs6OEiyRVjiJ+cj+W99St6GsiREjuKrDAFA5JVUxhVlwofP5oSDkYzkZIIViJ6UHbWKWC8= X-Received: by 2002:a25:3618:0:b0:b9a:5606:a6bb with SMTP id d24-20020a253618000000b00b9a5606a6bbmr6849101yba.0.1683419424778; Sat, 06 May 2023 17:30:24 -0700 (PDT) MIME-Version: 1.0 References: <1682838557923.199385846.1005913393@yahoo.de> In-Reply-To: <1682838557923.199385846.1005913393@yahoo.de> Date: Sat, 6 May 2023 20:30:13 -0400 Message-ID: To: Hans Krentel Cc: PHP Internals Content-Type: multipart/alternative; boundary="000000000000d26f3c05fb0fa0f8" Subject: Re: [PHP-DEV] Moving a tmpfile()? From: dliebner@gmail.com (Dan Liebner) --000000000000d26f3c05fb0fa0f8 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable > Why move the temporary file when it is already a temporary file, right? If you don't want to have to write the file again with a copy? On Sat, May 6, 2023 at 1:56=E2=80=AFPM Hans Krentel = wrote: > > > > On Saturday 29 April 2023 09:32:42 (+02:00), Dan Liebner 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. > > yes, not that it would be inherently wrong to do it that way, it is that > tmpfile() already offers the file handle, so you can rewind() and put the > contents in your destination file: > > > $destinationPath =3D tempnam(__DIR__, '.destination.'); > $tempHandle =3D tmpfile(); > > # ... operate on $tempHandle ... > fwrite($tempHandle, "hello world\n"); > > rewind($tempHandle); > $result =3D file_put_contents($destinationPath, $tempHandle); > fclose($tempHandle); > > > Why move the temporary file when it is already a temporary file, right? > > -- hakre > --000000000000d26f3c05fb0fa0f8--