• file_id.diz extraction function

    From Ignatius@1:340/800 to All on Mon Dec 18 20:05:50 2017
    Hi,

    I have a function:

    --begin--

    function DizExists(const fn:astr):boolean;
    var
    ok:boolean;
    T:Text;
    S:string[50];
    Index:byte;

    begin

    star('Checking for description...'#29);

    if (pos('.zip',fn)<>0) then fpsystem('unzip -L -o '+fn+' file_id.diz -d '+general.temppath+cstr(node)+'/ARC/ >/dev/null')
    else if (pos('.lzh',fn)<>0) then fpsystem('lha e f '+fn+' file_id.diz '+general.temppath+cstr(node)+'/ARC/ >/dev/null')
    else if (pos('.arj',fn)<>0) then fpsystem('arj e f '+fn+' file_id.diz '+general.temppath+cstr(node)+'/ARC/ >/dev/null')
    else if (pos('.rar',fn)<>0) then fpsystem('unrar x -cl '+fn+' file_id.diz '+general.temppath+cstr(node)+'/ARC/ >/dev/null');

    if (exist('/home/rg/TEMP' + cstr(node) + '/ARC/file_id.diz')) then
    assign(T,'/home/rg/TEMP' +cstr(node) + '/ARC/file_id.diz');
    reset(T);
    if (IOResult <> 0) then exit;
    star('Importing description.');
    Index := 1;
    erase(T);
    end;

    --end--

    The problem is that it only extracts the first line of the file_id.diz.
    Anyone have any ideas?

    Thanks,

    |09ignatius |15[|07cia|15]|07

    --- Renegade vY2Ka3
    * Origin: catch twenty two >>> >> > (1:340/800)
  • From mark lewis@1:3634/12.73 to Ignatius on Tue Dec 19 02:11:50 2017
    On 2017 Dec 18 20:05:50, you wrote to All:

    if (pos('.zip',fn)<>0) then fpsystem('unzip -L -o '+fn+' file_id.diz -d '+general.temppath+cstr(node)+'/ARC/ >/dev/null')
    else if (pos('.lzh',fn)<>0) then fpsystem('lha e f '+fn+' file_id.diz '+general.temppath+cstr(node)+'/ARC/ >/dev/null')
    else if (pos('.arj',fn)<>0) then fpsystem('arj e f '+fn+' file_id.diz '+general.temppath+cstr(node)+'/ARC/ >/dev/null')
    else if (pos('.rar',fn)<>0) then fpsystem('unrar x -cl '+fn+' file_id.diz '+general.temppath+cstr(node)+'/ARC/ >/dev/null');

    these extrtact the file_id.diz file... the whole file... there's no way to extract only part of it...

    if (exist('/home/rg/TEMP' + cstr(node) + '/ARC/file_id.diz'))
    then
    assign(T,'/home/rg/TEMP' +cstr(node) + '/ARC/file_id.diz');
    reset(T);
    if (IOResult <> 0) then exit;
    star('Importing description.');
    Index := 1;
    erase(T);
    end;

    nothing here does anything with the file except where you assign it, reset it, and then erase it... you don't ever read it... you don't even have a begin and end inside the "if" statement...

    The problem is that it only extracts the first line of the file_id.diz. Anyone have any ideas?

    nope, sorry...

    but i do have a question... why are you using general.temppath+cstr(node) in the extraction lines but you have hardcoded /home/rg/TEMP+cstr(node) in the importing part? if i had to guess, general.temppath contains /home/rg/TEMP...

    but that brings up something else... why keep calling cstr over and over and over... build your string one time and use it over and over... the code will be
    much more efficient...

    eg: mytempARCpath:=general.temppath+cstr(node)+'/ARC/';

    if (pos('.zip',fn)<>0) then fpsystem('unzip -L -o '+fn+' file_id.diz -d
    '+mytempARCpath+' >/dev/null')
    else if (pos('.lzh',fn)<>0) then fpsystem('lha e f '+fn+' file_id.diz
    '+mytempARCpath+' >/dev/null')
    else if (pos('.arj',fn)<>0) then fpsystem('arj e f '+fn+' file_id.diz
    '+mytempARCpath+' >/dev/null')
    else if (pos('.rar',fn)<>0) then fpsystem('unrar x -cl '+fn+' file_id.diz '+mytempARCpath+' >/dev/null');

    if (exist(mytempARCpath + 'file_id.diz')) then
    BEGIN <-- missing in original code
    assign(T,mytempARCpath + 'file_id.diz');
    reset(T);
    if (IOResult <> 0) then exit;
    star('Importing description.');
    Index := 1;
    erase(T);
    END; <-- missing in original code
    end;


    )\/(ark

    Always Mount a Scratch Monkey
    Do you manage your own servers? If you are not running an IDS/IPS yer doin' it wrong...
    ... It's good to be children sometimes and never better than at Christmas.
    ---
    * Origin: (1:3634/12.73)
  • From mark lewis@1:3634/12.73 to Ignatius on Tue Dec 19 02:11:50 2017

    On 2017 Dec 18 20:05:50, you wrote to All:

    if (pos('.zip',fn)<>0) then fpsystem('unzip -L -o '+fn+' file_id.diz -d '+general.temppath+cstr(node)+'/ARC/ >/dev/null')
    else if (pos('.lzh',fn)<>0) then fpsystem('lha e f '+fn+' file_id.diz '+general.temppath+cstr(node)+'/ARC/ >/dev/null')
    else if (pos('.arj',fn)<>0) then fpsystem('arj e f '+fn+' file_id.diz '+general.temppath+cstr(node)+'/ARC/ >/dev/null')
    else if (pos('.rar',fn)<>0) then fpsystem('unrar x -cl '+fn+' file_id.diz '+general.temppath+cstr(node)+'/ARC/ >/dev/null');

    these extrtact the file_id.diz file... the whole file... there's no way to extract only part of it...

    if (exist('/home/rg/TEMP' + cstr(node) + '/ARC/file_id.diz'))
    then
    assign(T,'/home/rg/TEMP' +cstr(node) + '/ARC/file_id.diz');
    reset(T);
    if (IOResult <> 0) then exit;
    star('Importing description.');
    Index := 1;
    erase(T);
    end;

    nothing here does anything with the file except where you assign it, reset it, and then erase it... you don't ever read it... you don't even have a begin and end inside the "if" statement...

    The problem is that it only extracts the first line of the file_id.diz. Anyone have any ideas?

    nope, sorry...

    but i do have a question... why are you using general.temppath+cstr(node) in the extraction lines but you have hardcoded /home/rg/TEMP+cstr(node) in the importing part? if i had to guess, general.temppath contains /home/rg/TEMP...

    but that brings up something else... why keep calling cstr over and over and over... build your string one time and use it over and over... the code will be
    much more efficient...

    eg: mytempARCpath:=general.temppath+cstr(node)+'/ARC/';

    if (pos('.zip',fn)<>0) then fpsystem('unzip -L -o '+fn+' file_id.diz -d
    '+mytempARCpath+' >/dev/null')
    else if (pos('.lzh',fn)<>0) then fpsystem('lha e f '+fn+' file_id.diz
    '+mytempARCpath+' >/dev/null')
    else if (pos('.arj',fn)<>0) then fpsystem('arj e f '+fn+' file_id.diz
    '+mytempARCpath+' >/dev/null')
    else if (pos('.rar',fn)<>0) then fpsystem('unrar x -cl '+fn+' file_id.diz '+mytempARCpath+' >/dev/null');

    if (exist(mytempARCpath + 'file_id.diz')) then
    BEGIN <-- missing in original code
    assign(T,mytempARCpath + 'file_id.diz');
    reset(T);
    if (IOResult <> 0) then exit;
    star('Importing description.');
    Index := 1;
    erase(T);
    END; <-- missing in original code
    end;


    )\/(ark

    Always Mount a Scratch Monkey
    Do you manage your own servers? If you are not running an IDS/IPS yer doin' it wrong...
    ... It's good to be children sometimes and never better than at Christmas.
    ---
    * Origin: (1:3634/12.73)
  • From Ozz Nixon@1:275/301 to Ignatius on Sun Dec 31 23:36:28 2017
    Hello Ignatius.

    I redesigned, this should work (may have a typo) but should show you the flaw.

    --begin--

    function DizExists(const fn:astr):boolean;
    var
    T:Text;
    S:string;

    begin
    star('Checking for description...'#29);
    S:='';
    if (pos('.zip',fn)<>0) then S:='unzip -L -o '
    else if (pos('.lzh',fn)<>0) then S:='lha e f '
    else if (pos('.arj',fn)<>0) then S:='arj e f '
    else if (pos('.rar',fn)<>0) then S:='unrar x -cl ';
    If (S<>'') then begin
    fpsystem(S+' file_id.diz '+ general.temppath+cstr(node)+'/ARC/ >/dev/null');
    If (exist('/home/rg/TEMP'+cstr(node)+'/ARC/file_id.diz')) then begin
    assign(T,'/home/rg/TEMP'+cstr(node)+'/ARC/file_id.diz');
    {$I-} reset(T); {$I+}
    if (IOResult<>0) then exit;
    star('Importing description.');
    While not EOF(T) do begin
    {$I-} Readln(T,S); {$I+}
    If IOResult=0 then {do something with S!!};
    End;
    erase(T);
    end;
    End;
    --end--

    So where it says: {do something with S!!} use "S" for whatever you need for your BBS code. You should also handle "FILE_ID.DIZ" (uppercase) too.

    Let me know if you need any help...
    Ozz

    --- GoldED+/W32 1.1.4.7
    * Origin: Home of Exchange BBS (QBBS Clone) and Rhenium Mailer (1:275/301)
  • From Ozz Nixon@1:275/301 to Ignatius on Sun Dec 31 23:36:28 2017
    Hello Ignatius.

    I redesigned, this should work (may have a typo) but should show you the flaw.

    --begin--

    function DizExists(const fn:astr):boolean;
    var
    T:Text;
    S:string;

    begin
    star('Checking for description...'#29);
    S:='';
    if (pos('.zip',fn)<>0) then S:='unzip -L -o '
    else if (pos('.lzh',fn)<>0) then S:='lha e f '
    else if (pos('.arj',fn)<>0) then S:='arj e f '
    else if (pos('.rar',fn)<>0) then S:='unrar x -cl ';
    If (S<>'') then begin
    fpsystem(S+' file_id.diz '+ general.temppath+cstr(node)+'/ARC/ >/dev/null');
    If (exist('/home/rg/TEMP'+cstr(node)+'/ARC/file_id.diz')) then begin
    assign(T,'/home/rg/TEMP'+cstr(node)+'/ARC/file_id.diz');
    {$I-} reset(T); {$I+}
    if (IOResult<>0) then exit;
    star('Importing description.');
    While not EOF(T) do begin
    {$I-} Readln(T,S); {$I+}
    If IOResult=0 then {do something with S!!};
    End;
    erase(T);
    end;
    End;
    --end--

    So where it says: {do something with S!!} use "S" for whatever you need for your BBS code. You should also handle "FILE_ID.DIZ" (uppercase) too.

    Let me know if you need any help...
    Ozz

    --- GoldED+/W32 1.1.4.7
    * Origin: Home of Exchange BBS (QBBS Clone) and Rhenium Mailer (1:275/301)