VirtualBox

Changeset 1321 in kBuild


Ignore:
Timestamp:
Dec 2, 2007 10:28:19 AM (17 years ago)
Author:
bird
Message:

Fix stat(./).

Location:
trunk/src/kmk/kmkbuiltin
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/kmk/kmkbuiltin/mscfakes.c

    r1108 r1321  
    300300}
    301301
     302
     303#undef stat
     304/*
     305 * Workaround for directory names with trailing slashes.
     306 * Added by bird reasons stated.
     307 */
     308int
     309my_other_stat(const char *path, struct stat *st)
     310{
     311    int rc = stat(path, st);
     312    if (    rc != 0
     313        &&  errno == ENOENT
     314        &&  *path != '\0')
     315    {
     316        char *slash = strchr(path, '\0') - 1;
     317        if (*slash == '/' || *slash == '\\')
     318        {
     319            size_t len_path = slash - path + 1;
     320            char *tmp = alloca(len_path + 4);
     321            memcpy(tmp, path, len_path);
     322            tmp[len_path] = '.';
     323            tmp[len_path + 1] = '\0';
     324            errno = 0;
     325            rc = stat(tmp, st);
     326            if (    rc == 0
     327                &&  !S_ISDIR(st->st_mode))
     328            {
     329                errno = ENOTDIR;
     330                rc = -1;
     331            }
     332        }
     333    }
     334    return rc;
     335}
     336
  • trunk/src/kmk/kmkbuiltin/mscfakes.h

    r1309 r1321  
    4141# define fstat _fstat64
    4242# define lseek _lseeki64
     43#else
     44# undef stat
     45# define stat(_path, _st) my_other_stat(_path, _st)
     46extern int my_other_stat(const char *, struct stat *);
    4347#endif
     48
    4449
    4550
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette