#!/usr/bin/perl
#-*-cperl-*-

use lib '/app/tools/sale_import/lib';
use RPS::Sale::File;

use strict;

my $sf = new RPS::Sale::File;

foreach my $file (@ARGV) {

    my $binary = ( -B $file ) ? 'Y' : 'N';
    my $text   = ( -T $file ) ? 'Y' : 'N';
    my $service_id;
    my $version_id;
    my $file_format;

    print "FILE: $file (binary: $binary, text: $text)\n";
    print "===================================================================\n";
    if ( $sf->Parse($file) ) {
        $service_id  = $sf->GetServiceID();
        $version_id  = $sf->GetVersionNum();
        $file_format = $sf->GetFileType();
        print "service_id = $service_id($version_id)-$file_format\n\n";
    } else {
        print $sf->errstr() . "\n\n";
    }

}

# use File::Type;
# use MIME::Types;

# my $ft = File::Type->new();
# my $mt = MIME::Types->new();

# foreach my $file (@ARGV) {

# #    my $type = $ft->mime_type($file) || 'UNKOWN';
#     my $ft_type = $ft->checktype_filename($file) || 'UNKOWN';
#     my $mt_type = $mt->mimeTypeOf($file) || 'UNKNOWN';

#     my $binary = (-B $file) ? 'Y' : 'N';
#     my $text   = (-T $file) ? 'Y' : 'N';

# #    print "$file => ft_type: $ft_type, mt_type: $mtype (binary: $binary, text: $text)\n";
# }

