Changeset 3092 for trunk/tools


Ignore:
Timestamp:
Mar 11, 2000, 7:52:49 PM (26 years ago)
Author:
bird
Message:

Stops when a lock is found. Added a <tag> to the lock to differ two types of
proceses.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tools/bin/DoWithDirs.cmd

    r3087 r3092  
    1 /* $Id: DoWithDirs.cmd,v 1.4 2000-03-11 17:11:30 bird Exp $
     1/* $Id: DoWithDirs.cmd,v 1.5 2000-03-11 18:52:49 bird Exp $
    22 *
    33 * Syntax: dowithdirs.cmd [-e<list of excludes>] [-c] [-i] [-l] [-r] <cmd with args...>
     
    88 *    -i      Ignore command failure (rc=0)
    99 *    -r      Process diretories in reverse order.
    10  *    -l      Lock directories for other dowithdirs.cmd processes. (-c required!)
     10 *    -l<tag> Lock directories for other dowithdirs.cmd processes. (-c required!)
     11 *            Processing stops (rc=0) on the first locked directory.
     12 *            <tag> is a name of the lock.
    1113 */
    1214
     
    2022    fLocking = 0;
    2123    fReverse = 0;
     24    fExitOnLock = 1;
     25    sLockTag = '';
    2226
    2327    /* parse arguments */
     
    7377                    do
    7478                        fLocking = 1;
     79                        sLockTag = substr(sArg.i, 3);
    7580                    end
    7681
     
    143148                fOK = 1;
    144149                if (fLocking) then
    145                     if (\lockdir()) then
    146                     do
     150                    if (\lockdir(sLockTag)) then
     151                    do
     152                        if (fExitOnLock) then
     153                        do
     154                            /* restore old directory and return sucessfully */
     155                            call directory sOldDir;
     156                            say '# - Lock found, stops processing.';
     157                            exit(0);
     158                        end
    147159                        say '# - warning: Skipping '|| asDirs.i || ' - directory was locked.';
    148160                        fOK = 0;
     
    158170                    /* unlock directory */
    159171                    if (fLocking & fOk) then
    160                         call unlockdir;
     172                        call unlockdir sLockTag;
    161173
    162174                    /* check for return? */
     
    191203
    192204syntax:
    193     say 'Syntax: dowithdirs.cmd [-e<list of excludes>] [-c] [-i] [-l] [-r] <cmd with args...>';
     205    say 'Syntax: dowithdirs.cmd [-e<list of excludes>] [-c] [-i] [-l<tag>] [-r] <cmd with args...>';
    194206    say '   -e      Exclude directories.';
    195207    say '   <list of excludes> is a INCLUDE-path styled list of directories.';
     
    198210    say '   -i      Ignore command failure (rc=0)';
    199211    say '   -r      Process diretories in reverse order.';
    200     say '   -l      Lock directories for other dowithdirs.cmd processes. (-c required!)';
     212    say '   -l<tag> Lock directories for other dowithdirs.cmd processes. (-c required!)';
     213    say '           Processing stops (rc=0) on the first locked directory.';
     214    say '           <tag> is a name of the lock.';
    201215    exit(-1)
    202216
     
    208222 */
    209223lockdir: procedure
    210     rc = stream('.dirlocked', 'c', 'open write');
     224    parse arg sTag
     225    rc = stream('.dirlocked' || sTag, 'c', 'open write');
    211226    return substr(rc, 1, 5) = 'READY';
    212227
     
    216231 */
    217232unlockdir: procedure
    218     rc = stream('.dirlocked', 'c', 'close');
     233    parse arg sTag
     234    rc = stream('.dirlocked' || sTag, 'c', 'close');
    219235    call SysFileDelete '.dirlocked';
    220236    return 0;
Note: See TracChangeset for help on using the changeset viewer.