Rocksolid Light

Welcome to RetroBBS

mail  files  register  newsreader  groups  login

Message-ID:  

When Dexter's on the Internet, can Hell be far behind?"


devel / comp.lang.php / RecursiveIteratorIterator: exclude file

SubjectAuthor
* RecursiveIteratorIterator: exclude fileSupaPlex
`- Re: RecursiveIteratorIterator: exclude fileJ.O. Aho

1
RecursiveIteratorIterator: exclude file

<t4ofh2$b0g$1@gioia.aioe.org>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=503&group=comp.lang.php#503

  copy link   Newsgroups: comp.lang.php
Path: i2pn2.org!i2pn.org!aioe.org!XImnr88bAEHdt86xrlPFQQ.user.46.165.242.91.POSTED!not-for-mail
From: old@gamer.s (SupaPlex)
Newsgroups: comp.lang.php
Subject: RecursiveIteratorIterator: exclude file
Date: Mon, 2 May 2022 13:32:49 +0200
Organization: Aioe.org NNTP Server
Message-ID: <t4ofh2$b0g$1@gioia.aioe.org>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Info: gioia.aioe.org; logging-data="11280"; posting-host="XImnr88bAEHdt86xrlPFQQ.user.gioia.aioe.org"; mail-complaints-to="abuse@aioe.org";
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101
Thunderbird/91.8.1
X-Notice: Filtered by postfilter v. 0.9.2
Content-Language: it-IT
 by: SupaPlex - Mon, 2 May 2022 11:32 UTC

--- CODE ---
function main($dir, $md5ContainerFilename) {
$elements = iterator_to_array(
new RecursiveIteratorIterator(
new RecursiveDirectoryIterator($dir)
)
);

$records = [];
foreach ($elements as $element) {
if (is_dir($element)){
continue;
}

$record = md5($element) . ' ' . $element;

array_push($records, $record);
}

$recordsStr = implode(PHP_EOL, $records);

file_put_contents($md5ContainerFilename, $recordsStr);
}

main(
'.',
'dir/md5-container'
);
--- CODE END ---

$ cat dir/md5-container
b4d1a9a6ea915fbc185205f2d9b61caf ./dir/file
847971a473761ce82235c3f99d6a483b ./dir/file2
76efa814f29375feaf93f6b08982ae4e ./dir/md5-container
516f8127e52fadca9ede40e54a59f04b ./file
0a9990b3c55615b43bd0b0bbbf43dd06 ./file2

As you can see, among the various files, there is also the file
dir/md5-container
This file should be the container, not part of the content.
How can I do to exclude it?

Re: RecursiveIteratorIterator: exclude file

<jdfnt5Fs70dU1@mid.individual.net>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=504&group=comp.lang.php#504

  copy link   Newsgroups: comp.lang.php
Path: i2pn2.org!i2pn.org!news.swapon.de!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail
From: user@example.net (J.O. Aho)
Newsgroups: comp.lang.php
Subject: Re: RecursiveIteratorIterator: exclude file
Date: Wed, 4 May 2022 18:28:20 +0200
Lines: 50
Message-ID: <jdfnt5Fs70dU1@mid.individual.net>
References: <t4ofh2$b0g$1@gioia.aioe.org>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
X-Trace: individual.net aWZjLhuS4YxjuFhxvO+VhgIe9SDA5iAoAM2pkAU8R5UepteKPf
Cancel-Lock: sha1:z+qpAhy+eJfrkq2+LsF84iq5GdQ=
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101
Thunderbird/91.8.1
Content-Language: en-US-large
In-Reply-To: <t4ofh2$b0g$1@gioia.aioe.org>
 by: J.O. Aho - Wed, 4 May 2022 16:28 UTC

On 02/05/2022 13:32, SupaPlex wrote:
> --- CODE ---
> function main($dir, $md5ContainerFilename) {
>     $elements = iterator_to_array(
>             new RecursiveIteratorIterator(
>                     new RecursiveDirectoryIterator($dir)
>             )
>     );
>
>     $records = [];
>     foreach ($elements as $element) {
>         if (is_dir($element)){
>             continue;
>         } if(str_ends_with($element, 'md5-container') {
continue;
]
>
>         $record = md5($element) . ' ' . $element;
>
>         array_push($records, $record);
>     }
>
>     $recordsStr = implode(PHP_EOL, $records);
>
>     file_put_contents($md5ContainerFilename, $recordsStr);
> }
>
> main(
>         '.',
>         'dir/md5-container'
> );
> --- CODE END ---
>
> $ cat dir/md5-container
> b4d1a9a6ea915fbc185205f2d9b61caf ./dir/file
> 847971a473761ce82235c3f99d6a483b ./dir/file2
> 76efa814f29375feaf93f6b08982ae4e ./dir/md5-container
> 516f8127e52fadca9ede40e54a59f04b ./file
> 0a9990b3c55615b43bd0b0bbbf43dd06 ./file2
>
> As you can see, among the various files, there is also the file
> dir/md5-container
> This file should be the container, not part of the content.
> How can I do to exclude it?

See code above.

--

//Aho

1
server_pubkey.txt

rocksolid light 0.9.8
clearnet tor