fs-win32.cpp revision 677833bc953b6cb418c701facbdcf4aa18d6c44e
/* $Id$ */
/** @file
* InnoTek Portable Runtime - File System, Win32.
*/
/*
* 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 *
*******************************************************************************/
#define LOG_GROUP RTLOGGROUP_FS
#include <windows.h>
/**
* Checks quickly if this is an correct root specification.
* Root specs ends with a slash of some kind.
*
* @returns indicator.
* @param pszFsPath Path to check.
*/
static bool rtFsIsRoot(const char *pszFsPath)
{
/*
* UNC has exactly two slashes..
*
* Anything else starting with slashe(s) requires
* expansion and will have to take the long road.
*/
if (RTPATH_IS_SLASH(pszFsPath[0]))
{
return false;
/* end of machine name */
if (!pszSlash)
return false;
/* end of service name. */
if (!pszSlash)
return false;
}
/*
* Ok the other alternative is driver letter.
*/
&& !pszFsPath[3];
}
#ifndef RT_DONT_CONVERT_FILENAMES
/**
* Finds the root of the specified volume.
*
* @returns iprt status code.
* @param pszFsPath Path within the filesystem. Verified as one byte or more.
* @param ppuszFsRoot Where to store the returned string. Free with rtFsFreeRoot(),
*/
{
/*
* Do straight forward stuff first,
*/
if (rtFsIsRoot(pszFsPath))
/*
* Expand and add slash (if required).
*/
char szFullPath[RTPATH_MAX];
if (RT_FAILURE(rc))
return rc;
{
}
/*
* Convert the path.
*/
if (RT_FAILURE(rc))
/*
* Walk the path until our proper API is happy or there is no more path left.
*/
{
do
{
/* Strip off the last path component. */
if (RTPATH_IS_SLASH(*puszEnd))
break;
AssertReturn(puszEnd >= puszMin, VERR_INTERNAL_ERROR); /* leaks, but that's irrelevant for an internal error. */
}
return VINF_SUCCESS;
}
/**
* Frees string returned by rtFsGetRoot().
*/
{
}
#else
/**
* Finds the root of the specified volume.
*
* @returns iprt status code.
* @param pszFsPath Path within the filesystem. Verified as one byte or more.
* @param ppszFsRoot Where to store the returned string. Free with rtFsFreeRoot(),
*/
{
/*
* Do straight forward stuff first,
*/
if (rtFsIsRoot(pszFsPath))
/*
* Expand and add slash (if required).
*/
char szFullPath[RTPATH_MAX];
if (RT_FAILURE(rc))
return rc;
{
}
/*
* Walk the path until our proper API is happy or there is no more path left.
*/
{
do
{
/* Strip off the last path component. */
if (RTPATH_IS_SLASH(*pszEnd))
break;
}
}
/**
* Frees string returned by rtFsGetRoot().
*/
static void rtFsFreeRoot(char *pszFsRoot)
{
}
#endif
{
/*
* Validate & get valid root path.
*/
#ifndef RT_DONT_CONVERT_FILENAMES
#else
char pszFsRoot;
#endif
if (RT_FAILURE(rc))
return rc;
/*
* Free and total.
*/
{
#ifndef RT_DONT_CONVERT_FILENAMES
#else
#endif
{
if (pcbTotal)
if (pcbFree)
}
else
{
Log(("RTFsQuerySizes(%s,): GetDiskFreeSpaceEx failed with lasterr %d (%Vrc)\n",
}
}
/*
* Block and sector size.
*/
if ( RT_SUCCESS(rc)
{
#ifndef RT_DONT_CONVERT_FILENAMES
#else
#endif
{
if (pcbBlock)
if (pcbSector)
}
else
{
Log(("RTFsQuerySizes(%s,): GetDiskFreeSpace failed with lasterr %d (%Vrc)\n",
}
}
#ifndef RT_DONT_CONVERT_FILENAMES
#else
#endif
return rc;
}
/**
* Query the serial number of a filesystem.
*
* @returns iprt status code.
* @param pszFsPath Path within the mounted filesystem.
* @param pu32Serial Where to store the serial number.
*/
{
/*
* Validate & get valid root path.
*/
#ifndef RT_DONT_CONVERT_FILENAMES
#else
char pszFsRoot;
#endif
if (RT_FAILURE(rc))
return rc;
/*
* Do work.
*/
#ifndef RT_DONT_CONVERT_FILENAMES
#else
#endif
*pu32Serial = dwSerial;
else
{
Log(("RTFsQuerySizes(%s,): GetDiskFreeSpaceEx failed with lasterr %d (%Vrc)\n",
}
return rc;
}
/**
* Query the properties of a mounted filesystem.
*
* @returns iprt status code.
* @param pszFsPath Path within the mounted filesystem.
* @param pProperties Where to store the properties.
*/
{
/*
* Validate & get valid root path.
*/
#ifndef RT_DONT_CONVERT_FILENAMES
#else
char pszFsRoot;
#endif
if (RT_FAILURE(rc))
return rc;
/*
* Do work.
*/
#ifndef RT_DONT_CONVERT_FILENAMES
#else
#endif
{
}
else
{
Log(("RTFsQuerySizes(%s,): GetVolumeInformation failed with lasterr %d (%Vrc)\n",
}
return rc;
}