fs.cpp revision 04914e6c23865e4405d351b469529d2f786e1285
/* $Id$ */
/** @file
* InnoTek Portable Runtime - File System.
*/
/*
* Copyright (C) 2006 InnoTek Systemberatung GmbH
*
* This file is part of VirtualBox Open Source Edition (OSE), as
* available from http://www.virtualbox.org. This file is free software;
* General Public License as published by the Free Software Foundation,
* in version 2 as it comes in the "COPYING" file of the VirtualBox OSE
* distribution. VirtualBox OSE is distributed in the hope that it will
* be useful, but WITHOUT ANY WARRANTY of any kind.
*
* If you received this file as part of a commercial VirtualBox
* distribution, then only the terms of your commercial VirtualBox
* license agreement apply instead of the previous paragraph.
*/
/*******************************************************************************
* Header Files *
*******************************************************************************/
#ifndef __WIN__
# define RTTIME_INCL_TIMESPEC
#endif
/**
* Converts dos-style attributes to Unix attributes.
*
* @returns
* @param fMode The mode mask containing dos-style attibutes only.
* @param pszName The filename which this applies to (exe check).
* @param cbName The length of that filename. (optional, set 0)
*/
{
/* everything is readable. */
if (fMode & RTFS_DOS_DIRECTORY)
/* directories are executable. */
else
{
fMode |= RTFS_TYPE_FILE;
{
/* check for executable extension. */
char szExt[4];
)
}
}
/* writable? */
if (!(fMode & RTFS_DOS_READONLY))
return fMode;
}
/**
* Converts Unix attributes to Dos-style attributes.
*
* @returns
* @param fMode The mode mask containing dos-style attibutes only.
*/
{
fMode &= RTFS_UNIX_MASK;
if (RTFS_IS_DIRECTORY(fMode))
if (!(fMode & RTFS_DOS_MASK))
{
fMode |= RTFS_DOS_HIDDEN;
}
return fMode;
}
/**
* Converts dos-style attributes to Unix attributes.
*
* @returns Normalized file mode.
* @param fMode The mode mask containing dos-style attibutes only.
* @param pszName The filename which this applies to (exe check).
* @param cbName The length of that filename. (optional, set 0)
*/
{
if (!(fMode & RTFS_UNIX_MASK))
else if (!(fMode & RTFS_DOS_MASK))
else if (!(fMode & RTFS_TYPE_MASK))
else if (RTFS_IS_DIRECTORY(fMode))
return fMode;
}
/**
* Checks if the file mode is valid or not.
*
* @return true if valid.
* @return false if invalid, done bitching.
* @param fMode The file mode.
*/
{
("%RTfmode\n", fMode), false);
("%RTfmode\n", fMode), false);
/** @todo more checks! */
return true;
}
/**
* Checks if the file mode is valid as a permission mask or not.
*
* @return true if valid.
* @return false if invalid, done bitching.
* @param fMode The file mode.
*/
{
("%RTfmode\n", fMode), false);
/** @todo more checks! */
return true;
}
#ifndef __WIN__
/**
* Internal worker function which setups RTFSOBJINFO based on a UNIX stat struct.
*
* @param pObjInfo The file system object info structure to setup.
* @param pStat The stat structure to use.
*/
void rtFsConvertStatToObjInfo(PRTFSOBJINFO pObjInfo, const struct stat *pStat, const char *pszName, unsigned cbName)
{
#ifdef HAVE_STAT_NSEC
RTTimeSpecAddNano(RTTimeSpecSetSeconds(&pObjInfo->AccessTime, pStat->st_atime), pStat->st_atimensec);
RTTimeSpecAddNano(RTTimeSpecSetSeconds(&pObjInfo->ModificationTime, pStat->st_mtime), pStat->st_mtimensec);
RTTimeSpecAddNano(RTTimeSpecSetSeconds(&pObjInfo->ChangeTime, pStat->st_ctime), pStat->st_ctimensec);
#ifdef HAVE_STAT_BIRTHTIME
RTTimeSpecAddNano(RTTimeSpecSetSeconds(&pObjInfo->BirthTime, pStat->st_birthtime), pStat->st_birthtimensec);
#endif
#elif defined(HAVE_STAT_TIMESPEC_BRIEF)
# ifdef HAVE_STAT_BIRTHTIME
# endif
#elif defined(HAVE_STAT_TIMESPEC)
# ifdef HAVE_STAT_BIRTHTIME
# endif
#else /* just the normal stuff */
# ifdef HAVE_STAT_BIRTHTIME
# endif
#endif
#ifndef HAVE_STAT_BIRTHTIME
#endif
/* the file mode */
#ifdef S_ISTXT
#else
#error "S_ISVTX / S_ISTXT isn't defined"
#endif
#ifdef S_IFWHT
#endif
/* additional unix attribs */
#ifdef HAVE_STAT_FLAGS
#else
#endif
#ifdef HAVE_STAT_GEN
#else
#endif
}
#endif /* !__WIN__ */