SQLiteデータベースファイルを開くと、ファイルの先頭に多くの読み込み可能なテキストがあります。-B
ファイルテストのためにSQLiteファイルが誤ってフィルタリングされる可能性はどれくらいありますか?-Bファイルテストの信頼性はどれくらいですか?
The -T and -B switches work as follows. The first block or so of the file is
examined for odd characters such as strange control codes or characters with
the high bit set. If too many strange characters (>30%) are found, it's a -B
file; otherwise it's a -T file. Also, any file containing a zero byte in the
first block is considered a binary file.
は、あなたは今のsqliteファイルの数の統計的分析を行うことができ、彼らの「最初のブロックを解析したり:
#!/usr/bin/env perl
use warnings;
use strict;
use 5.10.1;
use File::Find;
my $dir = shift;
my $databases;
find({
wanted => sub {
my $file = $File::Find::name;
return if not -B $file;
return if not -s $file;
return if not -r $file;
say $file;
open my $fh, '<', $file or die "$file: $!";
my $firstline = readline($fh) // '';
close $fh or die $!;
push @$databases, $file if $firstline =~ /\ASQLite\sformat/;
},
no_chdir => 1,
},
$dir);
say scalar @$databases;
'-T'と' -B'の詳細が書かれているとは思いません。つまり、将来のPerlのリリースで変更される可能性があります。そうすれば、それらは役に立たなくなるでしょう...この質問に対する良い答えはヒューリスティックの詳細を記述することです。私はいつも自分自身を疑問に思っています – Nemo
これらはperlfuncで文書化されています。ここではすべてのファイル演算子が文書化されています。しかし、説明は曖昧です。 –