HEX
Server: Apache
System: FreeBSD www860.sakura.ne.jp 13.0-RELEASE-p14 FreeBSD 13.0-RELEASE-p14 #2: Mon Dec 9 13:54:55 JST 2024 root@www5301.sakura.ne.jp:/usr/obj/usr/src/amd64.amd64/sys/GENERIC amd64
User: yoyo0427 (1306)
PHP: 8.3.8
Disabled: NONE
Upload Files
File: //usr/local/bin/rfnmz
#! /usr/local/bin/perl -w
#
# -*- Perl -*-
#
# rfnmz - Reindex NMZ.field.* files.
#
# Copyright (C) 2000 Namazu Project All rights reserved.
#     This is free software with ABSOLUTELY NO WARRANTY.
#

use strict;
use FileHandle;
die "usage: rfnmz <index>\n" if @ARGV == 0;

my $target = $ARGV[0];
die "invalid target: $target\n" unless -d $target;

chdir $target;
my @fields = grep {! /\.i$/} glob 'NMZ.field.*';

for my $field (@fields) {
    my $fh_in = new FileHandle;
    $fh_in->open($field) || die "$field: $!";
    binmode($fh_in);

    my $fh_out = new FileHandle;
    $fh_out->open(">$field.i") || die "$field: $!";
    binmode($fh_out);

    my $ptr = 0;
    while (<$fh_in>) {
	print $fh_out pack 'N', $ptr;
	$ptr += length;
    }
}