Salesforce

How to extract files from a procedure library ?

« Go Back

Information

 
TitleHow to extract files from a procedure library ?
URL Name21301
Article Number000136082
EnvironmentProduct: Progress
Version: 9.x
Product: OpenEdge
Version: All supported versions
OS: All supported platforms
Other: Procedure Library, prolib
Question/Problem Description
How to extract files from a procedure library ?
Can prolib -extract rebuild directory structure based on library's content ?
How to identify directory structure needed for prolib -extract ?
Steps to Reproduce
Clarifying Information
Error Message
Defect Number
Enhancement Number
Cause
Resolution
Prolib -extract assumes the directory structure is already in place on the file system
It can not rebuild the directory structure on the disk itself, and it will fail to extract files if the target directory does not exist. 

It was determined that the Progress Product is functioning as designed.

An enhancement to the product can be requested through the Progress Community via an Ideas submission. Customer feedback is valuable and Idea submissions are monitored by our Product Management team. Enhancement requests are reviewed during the planning phase of each new product release and a list of the enhancements chosen for implementation can be found in the Release Notes documents that accompany each release. Once an Idea is submitted the Progress Software Community will have the opportunity to comment on and vote for the Idea.

For detailed information on how to submit an Idea, please refer to Knowledge Base article  How to submit an idea for a Progress product enhancement (embedded video)
Workaround
To rebuild the directory structure, following steps are required:

1) Use 
prolib -list command to list the contents of the library. 
2) From the output, identify file/directory structure - files will be listed as relative path references; the relative paths must be re-created on the file system, in the location where the prolib is run.
3) Use prolib -extract command to extract the contents of the library.

This can be automated via shell script or program. 
One example using the OpenEdge ABL:
DEFINE TEMP-TABLE dirtree NO-UNDO
    FIELD dirname  AS CHARACTER FORMAT "X(40)"
    FIELD dirlevel AS INTEGER
    INDEX dirname IS UNIQUE   dirname
    INDEX dirlevel IS PRIMARY dirlevel. 

/* test stub: pick a library that's normally shipped with the product */
RUN ExtractWithDirectories (INPUT "%DLC%/tty/prodict.pl").

/* the bulk of the logic */
PROCEDURE ExtractWithDirectories:

    DEFINE INPUT PARAMETER cLibrarypath AS CHARACTER NO-UNDO.

    DEF VAR cEntry AS CHAR NO-UNDO.
    DEF VAR iCount AS INT  NO-UNDO.

    INPUT THROUGH VALUE("prolib " + cLibrarypath + " -list").

    DO icount = 1 TO 4: /* just ignore the first 4 lines - those are header details */
        IMPORT UNFORMATTED cEntry.
    END.

    REPEAT:
        IMPORT UNFORMATTED cEntry.
        IF TRIM(cEntry) = "" THEN LEAVE.
   
        /* normalize path name to get rid of the Windows vs. Unix difference in notation. Because both are valid in a .pl. */
        cEntry = REPLACE(cEntry,"\","/").
   
        /* Last 7 tokens are Size,Type,Offset, Modified and Added To Lib stuff, not path names.
           Get rid of those in a way that handles:
           - variable length lines
           - variable file extensions (including no extension, so can't rely on for period "." being present in path)
           - variable number of subdirectories (including no subdirectories, so can't rely on "/" or "\" being present in path)
           - spaces in path name (so can't rely on first space on the line read).
        */
        DO icount = 1 TO 7:
            ENTRY(NUM-ENTRIES(cEntry," "),cEntry," ") = "".
            cEntry = RIGHT-TRIM(centry).
        END.
   
        /* cut off the actual file name */
        ENTRY(NUM-ENTRIES(cEntry,"/"),cEntry,"/") = "".
        cEntry = RIGHT-TRIM(centry, "/").
      
        /* Build the list of unique directory names found in the library. 
           Do a multi-pass here to make sure that all parent directories are accounted for as well.
        */
        REPEAT:
            IF cEntry = "" THEN LEAVE. /* passed top of hierarchy */
            IF CAN-FIND(dirtree WHERE dirname = cEntry) THEN LEAVE. /* or found a parent that was added based on earlier entry */

            CREATE dirtree.
            ASSIGN 
                dirname  = cEntry
                dirlevel = NUM-ENTRIES(cEntry,"/").
            ENTRY(NUM-ENTRIES(cEntry,"/"),cEntry,"/") = "".
            cEntry = RIGHT-TRIM(centry, "/").
        END.
    END.

    INPUT close.

    /* with all that figured out, build directory structure by level of the hierarchy */ 
    FOR EACH dirtree BY dirlevel:
        OS-CREATE-DIR value(dirname).
        IF OS-ERROR <> 0 THEN RETURN ERROR "Could not build directory structure".  
    END.

    /* and finally, let the prolib -extract do it's job */
    OS-COMMAND SILENT(VALUE("prolib " + cLibrarypath + " -nowarn -extract *")).

END.
The logic above is used in the (attached) Prolib GUI tool.  
To use the Prolib GUI tool:
  • Extract the contents of prolib.zip
  • Run prolib\prolib.w
  • Enjoy
Note: The following Idea was logged in Aha for prolib to automatically create the directory structure when performing an -extract or -yank operation.

https://openedge.ideas.aha.io/ideas/OPENEDGE-I-51
Notes
References to Written Documentation:
OpenEdge Deployment: Managing ABL Applications, chapter "Managing Procedure Libraries"

Progress Article(s):
 Why and how to use a procedure library

 
Keyword Phrase
Last Modified Date1/9/2021 12:18 AM

Powered by