Changeset 794


Ignore:
Timestamp:
Oct 2, 2003, 3:39:36 AM (22 years ago)
Author:
bird
Message:

DELDIR check.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/emx/src/lib/sys/remove.c

    • Property cvs2svn:cvs-rev changed from 1.4 to 1.5
    r793 r794  
    11/* sys/remove.c (emx+gcc) -- Copyright (c) 1992-1996 by Eberhard Mattes */
     2                          -- Copyright (c) 2003 by Knut St. Osmundsen */
    23
    34#include "libc-alias.h"
    45#define INCL_FSMACROS
     6#define INCL_DOSMISC
    57#include <os2emx.h>
    68#include <emx/syscalls.h>
    79#include "syscalls.h"
    810
    9 int _STD(remove) (const char *name)
     11int _STD(remove)(const char *name)
    1012{
    11   ULONG rc;
    12   FS_VAR();
     13    static int    fUseForce; /* state: 0 - uninit, 1 - DosForceDelete, -1 - DosDelete */
     14    ULONG         rc;
     15    FS_VAR();
    1316
    14   FS_SAVE_LOAD();
    15   rc = DosDelete (name);
    16   FS_RESTORE();
    17   if (rc == 0)
     17    FS_SAVE_LOAD();
     18    /*
     19     * DosDelete is kind of slow as it always scans the environment (in a R0
     20     * accessing R3 data safe manner to make matters worse even) for DELDIR.
     21     * Since only a limited number of programs actually changes this
     22     * environment block, we assume that it's ok to check the first time if
     23     * DELDIR processing is enabled or not. If it isn't there, we can use
     24     * DosForceDelete and save quite a bit of time if we're called some
     25     * times.
     26     */
     27    if (fUseForce == 0)
     28    {
     29        PSZ psz = NULL;
     30        if (DosScanEnv("DELDIR", &psz) || !psz)
     31            fUseForce = 1;
     32        else
     33            fUseForce = -1;
     34    }
     35
     36    /*
     37     * Do the delete.
     38     */
     39    if (fUseForce == 1)
     40        rc = DosForceDelete(name);
     41    else
     42        rc = DosDelete(name);
     43    FS_RESTORE();
     44    if (rc)
     45    {
     46        _sys_set_errno(rc);
     47        return -1;
     48    }
    1849    return 0;
    19   else
    20     {
    21       _sys_set_errno (rc);
    22       return -1;
    23     }
    2450}
Note: See TracChangeset for help on using the changeset viewer.