VirtualBox

Changeset 36167 in vbox for trunk/src/VBox/Runtime/r3/posix


Ignore:
Timestamp:
Mar 4, 2011 12:33:39 PM (14 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
70357
Message:

Runtime/r3/posix: RTDirCreate should fail when creating a directory where a file exists.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Runtime/r3/posix/dir-posix.cpp

    r36166 r36167  
    9191            {
    9292                rc = errno;
     93                bool fVerifyIsDir = true;
    9394#ifdef RT_OS_SOLARIS
    9495                /*
     
    101102                    ||  rc == EACCES)
    102103                {
    103                     rc = EEXIST;
     104                    rc = RTErrConvertFromErrno(rc);
     105                    fVerifyIsDir = false;  /* We'll check if it's a dir ourselves since we're going to stat() anyway. */
     106                    struct stat st;
     107                    if (!stat(pszNativePath, &st))
     108                    {
     109                        rc = VERR_ALREADY_EXISTS;
     110                        if (!S_ISDIR(st.st_mode))
     111                            rc = VERR_IS_A_FILE;
     112                    }
    104113                }
     114                else
     115                    rc = RTErrConvertFromErrno(rc);
     116#else
     117                rc = RTErrConvertFromErrno(rc);
    105118#endif
    106                 rc = RTErrConvertFromErrno(rc);
    107                 if (rc == VERR_ALREADY_EXISTS)
     119                if (   rc == VERR_ALREADY_EXISTS
     120                    && fVerifyIsDir == true)
    108121                {
    109122                    /*
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