fs-win.cpp revision 848b6c64616a9dc0d00e7aaad7b82b8eb58e370e
/* $Id$ */
/** @file
* innotek Portable Runtime - File System, Win32.
*/
/*
* Copyright (C) 2006-2007 innotek 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 (GPL) 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.
*
* The contents of this file may alternatively be used under the terms
* of the Common Development and Distribution License Version 1.0
* (CDDL) only, as it comes in the "COPYING.CDDL" file of the
* VirtualBox OSE distribution, in which case the provisions of the
* CDDL are applicable instead of those of the GPL.
*
* You may elect to license modified versions of this file under the
* terms and conditions of either the GPL or the CDDL or both.
*/
/*******************************************************************************
* 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 ppwszFsRoot 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(*pwszEnd))
break;
AssertReturn(pwszEnd >= pwszMin, VERR_INTERNAL_ERROR); /* leaks, but that's irrelevant for an internal error. */
}
return VINF_SUCCESS;
}
/**
* Frees string returned by rtFsGetRoot().
*/
{
}
#else /* 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 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 /* RT_DONT_CONVERT_FILENAMES*/
{
/*
* 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",
}
#ifndef RT_DONT_CONVERT_FILENAMES
#else
#endif
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",
}
#ifndef RT_DONT_CONVERT_FILENAMES
#else
#endif
return rc;
}