Changeset 24938


Ignore:
Timestamp:
01/11/12 10:35:25 (9 years ago)
Author:
davidb
Message:

Implementation of saving 'frame.inf' added

Location:
gs3-extensions/html-to-expeditee/trunk/src/perllib
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • gs3-extensions/html-to-expeditee/trunk/src/perllib/ExpediteeFrameIO.pm

    r24934 r24938  
    3131{
    3232    my $class = shift(@_);
    33     my ($username) = shift(@_) || "greenstone";
     33    my $output_dir = shift(@_);
     34    my $username   = shift(@_) || "greenstone";
    3435
    3536    my $self = { 'items' => [], 'lines' => [], 'constraints' => [] };
    3637
     38    $self->{'output_dir'} = $output_dir;
    3739    $self->{'username'} = $username;
    3840
     
    364366{
    365367    my $self = shift @_;
    366     my ($filename) = @_;
     368    my ($file) = @_;
     369
     370    my $filename = &util::filename_cat($self->{'output_dir'},$file);
    367371
    368372    my $status = undef;
     
    380384    }
    381385    else {
    382     print STDERR "ExpediteeFrameIO:: Failed to open $filename for output\n";
     386    print STDERR "ExpediteeFrameIO::saveFrame() Failed to open $filename for output\n";
    383387    $status = 0;
    384388    }
     
    428432
    429433
    430 sub saveNextFreeFrame
    431 {
    432     my $self = shift @_;
    433     my ($nextFreeFrame) = @_;
    434 
    435     print STDERR "****  saveNextFreeFrame not implemented yet!!\n";
     434sub saveLastFrameNumber
     435{
     436    my $self = shift @_;
     437    my ($last_frame_number) = @_;
     438
     439    my $filename = &util::filename_cat($self->{'output_dir'},"frame.inf");
     440
     441    my $status = undef;
     442
     443    if (open(FNOUT,">$filename")) {
     444    binmode(FOUT,":utf8");
     445   
     446    print FNOUT "$last_frame_number\n";
     447
     448    close(FNOUT);
     449    $status = 1;
     450    }
     451    else {
     452    print STDERR "ExpediteeFrameIO::saveLastFrameNumber() Failed to open $filename for output\n";
     453    $status = 0;
     454    }
     455
     456    return $status;
     457
    436458}
    437459
  • gs3-extensions/html-to-expeditee/trunk/src/perllib/cgiactions/HtmlToExpediteeAction.pm

    r24936 r24938  
    9090    &util::mk_dir($output_dir);
    9191    }
    92     my $frame_filename = &util::filename_cat($output_dir,"$fn.exp");
    9392
    94     my $expeditee_frame_io = new ExpediteeFrameIO();
     93    my $expeditee_frame_io = new ExpediteeFrameIO($output_dir);
    9594   
    9695    $expeditee_frame_io->buildFrame($exp_frame_tree);
    9796
    98     if ($expeditee_frame_io->saveFrame($frame_filename)) {
     97    if ($expeditee_frame_io->saveFrame("$fn.exp")) {
    9998   
    10099    # write out next free frame num
    101     $expeditee_frame_io->saveNextFreeFrame($fn+1);
     100    $expeditee_frame_io->saveLastFrameNumber($fn);
    102101
    103102    $gsdl_cgi->generate_message("html-to-expeditee saved frame $fn");
    104103    }
    105104    else {
    106     $gsdl_cgi->generate_error("Failed to open $frame_filename for output");
     105    $gsdl_cgi->generate_error("Failed to save frame number $fn");
    107106    }
    108107}
Note: See TracChangeset for help on using the changeset viewer.