VirtualBox

Changeset 20066 in vbox


Ignore:
Timestamp:
May 27, 2009 11:24:23 AM (15 years ago)
Author:
vboxsync
Message:

Runtime: added RTDirCreateTemp

Location:
trunk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/include/iprt/dir.h

    r19261 r20066  
    6262 * @param   pszPath   Path to the directory to create.
    6363 * @param   fMode      The mode of the new directory.
    64  */
    65 RTDECL(int) RTDirCreate(const char *pszPath, RTFMODE fMode);
     64 */ RTDECL(int) RTDirCreate(const char *pszPath, RTFMODE fMode);
    6665
    6766/**
     
    7473 */
    7574RTDECL(int) RTDirCreateFullPath(const char *pszPath, RTFMODE fMode);
     75
     76/**
     77 * Creates a directory with a temporary name which is guaranteed not
     78 * to exists. It takes a path with a directory name template and
     79 * overwrites a portion of it to create the unique name. The template
     80 * may be any directory name with some numbers of `Xs` appended to it.
     81 * The trailing `Xs` are replaced with the unique numbers. The
     82 * directory is created with mode 0700.
     83 *
     84 * @returns iprt status code.
     85 * @param   pszTemplate     Buffer with the template path.
     86 */
     87RTDECL(int) RTDirCreateTemp(char *pszTemplate);
    7688
    7789/**
  • trunk/src/VBox/Runtime/r3/posix/dir-posix.cpp

    r14062 r20066  
    107107    LogFlow(("RTDirCreate(%p={%s}, %RTfmode): returns %Rrc\n", pszPath, pszPath, fMode, rc));
    108108    return rc;
     109}
     110
     111RTDECL(int) RTDirCreateTemp(char *pszTemplate)
     112{
     113    if (mkdtemp(pszTemplate))
     114        return VINF_SUCCESS;
     115   
     116    return RTErrConvertFromErrno(errno);
    109117}
    110118
  • trunk/src/VBox/Runtime/r3/win/dir-win.cpp

    r14062 r20066  
    3535#define LOG_GROUP RTLOGGROUP_DIR
    3636#include <Windows.h>
     37#include <io.h>
    3738
    3839#include <iprt/dir.h>
     
    128129
    129130
     131RTDECL(int) RTDirCreateTemp(char *pszTemplate)
     132{
     133    if (!_mktemp(pszTemplate))
     134    {
     135        int rc = RTDirCreate(pszTemplate, 0700);
     136        return rc;
     137    }
     138    return RTErrConvertFromWin32(GetLastError());
     139}
     140
     141
    130142RTDECL(int) RTDirRemove(const char *pszPath)
    131143{
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