* :--------------------------------------- * ------------------------: Copybook for the FindFiles Function * : * : FindFiles function allows you to * : search a directory for a file or sub- * : directory with a name that matches a * : specific full name or a partial name * : if wildcard characters appear in the * : pattern. * : * : Any files found will return not only * : the name, but associated information * : about the file. * : * : If the pattern contains wild card * : characters (*?) the search can return * : Multiple Results, via subsequent calls * : to this Function. * : * : After the last matching file is found * : the Function will close out the search * : automatically. * : * : If there are no wildcards in the * : pattern, the the API will close out * : the search and deliver the matching * : file. * : * : If wildcards are supplied, the first * : matching file will be delivered on the * : first call, and subsequent calls will * : deliver the next matching filename, * : etc, untill there are no more matching * : files. * : * : To terminate the find operation prior * : to returning the last matching file * : you must call the function with * : FINDFILECLOSE set to true. * : * : * : This API can run either on the Client * : or the server side. * : * : If you are running two searches at * : the same time (for example to compare * : files from two sources) you must * : use two seperate copies of this copy- * : book, because status information * : is maintained in the returned results * : which must remain unchanged for each * : search instance. * :--------------------------------------- * * CALLING EXAMPLE------------------------------------------------- * * -- Working Storage Section: * * COPY WIN32API. * COPY FINDFILE. * * -- Procedure Division: * * : Initialize the data areas. * SET FINDFILE-INITIALIZE TO TRUE * * : Load the Pattern for the search, * : this example uses a unique file patern * MOVE "C:\DATA\MYDATAFILE.DAT" TO FINDFILE-PATERN * * : Set which type of API/Function to run * SET FUNC-FINDFILES TO TRUE * * : Call the actual Function * CALL 'GSWINAPI' USING WIN32API-PARMS * FINDFILE-DATA * DUMMY * DUMMY * DUMMY * DUMMY * DUMMY * * IF WIN32API-FAILED * execute file not found-proceedure... * ELSE * PERFORM process-FF-FILENAME routine... * END-IF * * * * MULTIPLE FILE EXAMPLE------------------------------------------- * * -- Working Storage Section: * * COPY WIN32API. * COPY FINDFILE. * * -- Procedure Division: * * : Initialize the data areas on first * : call only: * SET FINDFILE-INITIALIZE TO TRUE * * : Load the Pattern for the search, * : this example uses wildcard characters * * MOVE "C:\DATA\*.DAT" TO FINDFILE-PATERN * * : Set which type of API/Function to run * SET FUNC-FINDFILES TO TRUE * * PERFORM WITH TEST AFTER UNTIL WIN32API-FAILED * * : Call the actual Function * CALL 'GSWINAPI' USING WIN32API-PARMS * FINDFILE-DATA * DUMMY * DUMMY * DUMMY * DUMMY * DUMMY * * IF NOT WIN32API-FAILED * PERFORM process-found-file-proceedure... * END-IF * * END-PERFORM * * ------------------------: Note: * : If you choose NOT to retrieve all * : files, you MUST terminate the * : FINDFILES function, or you will * : "leak handles" till your application * : exits. * : DO NOT set FINDFILE-INITIALIZE * : prior to calling the FIND-CLOSE. * : * : To terminate a FINDFILES session: * * SET FUNC-FINDFILES TO TRUE * SET FINDFILE-CLOSE TO TRUE * : Call the Function * CALL 'GSWINAPI' USING WIN32API-PARMS * FINDFILE-DATA * DUMMY * DUMMY * DUMMY * DUMMY * DUMMY * Note: * When you make a call which could possibly return multiple * files, the data areas will be set up automatically for * multiple retrival based on the absence of wild-card in the * initial call. * * If you wish to force the API to run as if there might be * multiple files even when there were no wild-cards, simply * SET FINDFIND-FIND TO TRUE prior to the first call. * This might be usefull when dealing with non-Windows file * systems, or when you are searchig directories which * have extensions. * * * ---------------------------------------------------------------- * * CLIENT/SERVER: * When running under Client/Server, this Function defaults to * running on the Client side. To run on the server side: * * SET WIN32API-EXECUTE-API-ON-SERVER TO TRUE. * * Note: You only need to do this on the FIRST call. * Subsequent call will operate on the same machine, * because this status is stored in the FILEFIND-ACTIVE * data element. L=Local, C=Client. Do not change this * once the API session has been started. * * * EXAMPLES OF SEARCH PATTERNS * * : All text files in the C:\data dir * C:\data\*.txt * : All files in a specific directory * D:\myfiles\1992\april\ * : All DOC files in AppData directory for * : the currently signed on user. * : Windows 2000 or later. Use Quotes! * "%APPDATA%\*.DOC" * : Files on a remote network share * \\ServerName\ShareName\Directory * : Any Path containing space need QUOTES * "C:\Program Files\Gui Screenio\gs32.dll" * * * * * 01 FINDFILE-DATA. * : Set this Prior to FIRST call, or when * : restarting a search. * : When retrieving multiple files, DO NOT * : set this between successive calls. * : NOTE: Setting this is normally the * : ONLY initialization required. 88 FINDFILE-INITIALIZE VALUE LOW-VALUES. * * : The input pattern which may contain * : wild card characters. * : Used on first call, ignored thereafter 05 FINDFILE-PATTERN PIC X(1024). * : The type of operation for this call. * : You should not have to set this, the * : API will manage it for you EXCEPT when * : you wish to terminate a fine prior to * : retrieving all possible files. 05 FINDFILE-OPERATION PIC X. 88 FINDFILE-FIND VALUE 'F' LOW-VALUES. 88 FINDFILE-CLOSE VALUE 'C'. * ------------------------: Returned Values: * : * : This indicates wether the findfile * : operation is currently active or not. * : You should not change this value. * : If Active, calling find-file again * : may return another file name. 05 FINDFILE-STATUS. 10 FINDFILE-ACTIVE PIC X. 88 FINDFILE-NOT-ACTIVE VALUE LOW-VALUE. * : Indicates Local, Client, or Server. 88 FINDFILE-IS-ACTIVE VALUES 'L' 'C' 'S'. * : This contains a handle to the current * : findfile operation and you should not * : change it. Each FINDFILE session will * : have a unique Value here. 10 FILLER PIC X(4). * * : This describes the file found. * : 05 FINDFILE-FILE-INFORMATION. * : Full file Name + low-value. 10 FF-FILENAME PIC X(260). * : DOS 8.3 file name + low-value. * : Note: This field only appears if the * : file has a long file name. 10 FF-DOSFILENAME PIC X(14). 10 FF-FILEATTRS PIC 9(9) BINARY. * : One or more of these may be true for * : each file. 88 FF-ATTRIBUTE-READONLY VALUE H'00000001'. 88 FF-ATTRIBUTE-HIDDEN VALUE H'00000002'. 88 FF-ATTRIBUTE-SYSTEM VALUE H'00000004'. 88 FF-ATTRIBUTE-DIRECTORY VALUE H'00000010'. 88 FF-ATTRIBUTE-ARCHIVE VALUE H'00000020'. 88 FF-ATTRIBUTE-NORMAL VALUE H'00000080'. 88 FF-ATTRIBUTE-TEMPORARY VALUE H'00000100'. 88 FF-ATTRIBUTE-COMPRESSED VALUE H'00000800'. 88 FF-ATTRIBUTE-OFFLINE VALUE H'00001000'. 88 FF-ATTRIBUTE-VIRTUAL VALUE H'00010000'. 10 FF-FILESIZE PIC S9(18) BINARY. * : Times are UTC time. 10 FF-CREATIONTIME. 15 FF-CREATIONTIME-YEAR PIC S9(4) COMP-5. 15 FF-CREATIONTIME-MONTH PIC S9(4) COMP-5. 15 FF-CREATIONTIME-DAY-OF-WEEK PIC S9(4) COMP-5. 15 FF-CREATIONTIME-DAY PIC S9(4) COMP-5. 15 FF-CREATIONTIME-HOUR PIC S9(4) COMP-5. 15 FF-CREATIONTIME-MINUTE PIC S9(4) COMP-5. 15 FF-CREATIONTIME-SECOND PIC S9(4) COMP-5. 15 FF-CREATIONTIME-HUNDREDTHS PIC S9(4) COMP-5. * : May not be reliable on all windows * : versions. 10 FF-LASTACCESS. 15 FF-LASTACCESS-YEAR PIC S9(4) COMP-5. 15 FF-LASTACCESS-MONTH PIC S9(4) COMP-5. 15 FF-LASTACCESS-DAY-OF-WEEK PIC S9(4) COMP-5. 15 FF-LASTACCESS-DAY PIC S9(4) COMP-5. 15 FF-LASTACCESS-HOUR PIC S9(4) COMP-5. 15 FF-LASTACCESS-MINUTE PIC S9(4) COMP-5. 15 FF-LASTACCESS-SECOND PIC S9(4) COMP-5. 15 FF-LASTACCESS-HUNDREDTHS PIC S9(4) COMP-5. * : This is the time DIR or Explorer shows 10 FF-LASTWRITE. 15 FF-LASTWRITE-YEAR PIC S9(4) COMP-5. 15 FF-LASTWRITE-MONTH PIC S9(4) COMP-5. 15 FF-LASTWRITE-DAY-OF-WEEK PIC S9(4) COMP-5. 15 FF-LASTWRITE-DAY PIC S9(4) COMP-5. 15 FF-LASTWRITE-HOUR PIC S9(4) COMP-5. 15 FF-LASTWRITE-MINUTE PIC S9(4) COMP-5. 15 FF-LASTWRITE-SECOND PIC S9(4) COMP-5. 15 FF-LASTWRITE-HUNDREDTHS PIC S9(4) COMP-5.