pathhost-darwin.cpp revision ed0cf28a5770089e1c761249fd7fb90a6f3ce015
5bf0ee311caa414469f26237ff607cb1b3591508vboxsync/* $Id$ */
5bf0ee311caa414469f26237ff607cb1b3591508vboxsync/** @file
5bf0ee311caa414469f26237ff607cb1b3591508vboxsync * IPRT - Path Convertions, Darwin.
5bf0ee311caa414469f26237ff607cb1b3591508vboxsync *
5bf0ee311caa414469f26237ff607cb1b3591508vboxsync * On darwin path names on the disk are decomposed using normalization
5bf0ee311caa414469f26237ff607cb1b3591508vboxsync * form D (NFD). Since this behavior is unique for the Mac, we will precompose
5bf0ee311caa414469f26237ff607cb1b3591508vboxsync * the path name strings we get from the XNU kernel.
5bf0ee311caa414469f26237ff607cb1b3591508vboxsync */
5bf0ee311caa414469f26237ff607cb1b3591508vboxsync
5bf0ee311caa414469f26237ff607cb1b3591508vboxsync/*
5bf0ee311caa414469f26237ff607cb1b3591508vboxsync * Copyright (C) 2006-2010 Oracle Corporation
5bf0ee311caa414469f26237ff607cb1b3591508vboxsync *
5bf0ee311caa414469f26237ff607cb1b3591508vboxsync * This file is part of VirtualBox Open Source Edition (OSE), as
5bf0ee311caa414469f26237ff607cb1b3591508vboxsync * available from http://www.virtualbox.org. This file is free software;
5bf0ee311caa414469f26237ff607cb1b3591508vboxsync * you can redistribute it and/or modify it under the terms of the GNU
5bf0ee311caa414469f26237ff607cb1b3591508vboxsync * General Public License (GPL) as published by the Free Software
5bf0ee311caa414469f26237ff607cb1b3591508vboxsync * Foundation, in version 2 as it comes in the "COPYING" file of the
5bf0ee311caa414469f26237ff607cb1b3591508vboxsync * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
5bf0ee311caa414469f26237ff607cb1b3591508vboxsync * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
5bf0ee311caa414469f26237ff607cb1b3591508vboxsync *
5bf0ee311caa414469f26237ff607cb1b3591508vboxsync * The contents of this file may alternatively be used under the terms
5bf0ee311caa414469f26237ff607cb1b3591508vboxsync * of the Common Development and Distribution License Version 1.0
5bf0ee311caa414469f26237ff607cb1b3591508vboxsync * (CDDL) only, as it comes in the "COPYING.CDDL" file of the
5bf0ee311caa414469f26237ff607cb1b3591508vboxsync * VirtualBox OSE distribution, in which case the provisions of the
5bf0ee311caa414469f26237ff607cb1b3591508vboxsync * CDDL are applicable instead of those of the GPL.
5bf0ee311caa414469f26237ff607cb1b3591508vboxsync *
5bf0ee311caa414469f26237ff607cb1b3591508vboxsync * You may elect to license modified versions of this file under the
5bf0ee311caa414469f26237ff607cb1b3591508vboxsync * terms and conditions of either the GPL or the CDDL or both.
5bf0ee311caa414469f26237ff607cb1b3591508vboxsync */
5bf0ee311caa414469f26237ff607cb1b3591508vboxsync
5bf0ee311caa414469f26237ff607cb1b3591508vboxsync
5bf0ee311caa414469f26237ff607cb1b3591508vboxsync/*******************************************************************************
5bf0ee311caa414469f26237ff607cb1b3591508vboxsync* Header Files *
5bf0ee311caa414469f26237ff607cb1b3591508vboxsync*******************************************************************************/
5bf0ee311caa414469f26237ff607cb1b3591508vboxsync#define LOG_GROUP RTLOGGROUP_PATH
5bf0ee311caa414469f26237ff607cb1b3591508vboxsync#include <iprt/assert.h>
5bf0ee311caa414469f26237ff607cb1b3591508vboxsync#include <iprt/string.h>
5bf0ee311caa414469f26237ff607cb1b3591508vboxsync#include "internal/iprt.h"
5bf0ee311caa414469f26237ff607cb1b3591508vboxsync
5bf0ee311caa414469f26237ff607cb1b3591508vboxsync#include "internal/path.h"
5bf0ee311caa414469f26237ff607cb1b3591508vboxsync
5bf0ee311caa414469f26237ff607cb1b3591508vboxsync
5bf0ee311caa414469f26237ff607cb1b3591508vboxsyncint rtPathToNative(char **ppszNativePath, const char *pszPath)
5bf0ee311caa414469f26237ff607cb1b3591508vboxsync{
5bf0ee311caa414469f26237ff607cb1b3591508vboxsync /** @todo We should decompose the string here, but the file system will do
5bf0ee311caa414469f26237ff607cb1b3591508vboxsync * that for us if we don't, so why bother. */
5bf0ee311caa414469f26237ff607cb1b3591508vboxsync *ppszNativePath = (char *)pszPath;
5bf0ee311caa414469f26237ff607cb1b3591508vboxsync return VINF_SUCCESS;
5bf0ee311caa414469f26237ff607cb1b3591508vboxsync}
5bf0ee311caa414469f26237ff607cb1b3591508vboxsync
5bf0ee311caa414469f26237ff607cb1b3591508vboxsync
5bf0ee311caa414469f26237ff607cb1b3591508vboxsyncint rtPathToNativeEx(char **ppszNativePath, const char *pszPath, const char *pszBasePath)
5bf0ee311caa414469f26237ff607cb1b3591508vboxsync{
5bf0ee311caa414469f26237ff607cb1b3591508vboxsync NOREF(pszBasePath);
5bf0ee311caa414469f26237ff607cb1b3591508vboxsync return rtPathToNative(ppszNativePath, pszPath);
5bf0ee311caa414469f26237ff607cb1b3591508vboxsync}
5bf0ee311caa414469f26237ff607cb1b3591508vboxsync
5bf0ee311caa414469f26237ff607cb1b3591508vboxsync
5bf0ee311caa414469f26237ff607cb1b3591508vboxsyncvoid rtPathFreeNative(char *pszNativePath, const char *pszPath)
5bf0ee311caa414469f26237ff607cb1b3591508vboxsync{
5bf0ee311caa414469f26237ff607cb1b3591508vboxsync Assert((const char *)pszNativePath == pszPath || !pszNativePath);
5bf0ee311caa414469f26237ff607cb1b3591508vboxsync NOREF(pszNativePath);
5bf0ee311caa414469f26237ff607cb1b3591508vboxsync NOREF(pszPath);
5bf0ee311caa414469f26237ff607cb1b3591508vboxsync}
5bf0ee311caa414469f26237ff607cb1b3591508vboxsync
5bf0ee311caa414469f26237ff607cb1b3591508vboxsync
5bf0ee311caa414469f26237ff607cb1b3591508vboxsyncint rtPathFromNative(char **ppszPath, const char *pszNativePath)
5bf0ee311caa414469f26237ff607cb1b3591508vboxsync{
5bf0ee311caa414469f26237ff607cb1b3591508vboxsync /** @todo We must compose the codepoints in the string here. We get file names
5bf0ee311caa414469f26237ff607cb1b3591508vboxsync * in normalization form D so we'll end up with normalization form C
5bf0ee311caa414469f26237ff607cb1b3591508vboxsync * whatever approach we take. */
5bf0ee311caa414469f26237ff607cb1b3591508vboxsync return RTStrDupEx(ppszPath, pszNativePath);
5bf0ee311caa414469f26237ff607cb1b3591508vboxsync}
5bf0ee311caa414469f26237ff607cb1b3591508vboxsync
5bf0ee311caa414469f26237ff607cb1b3591508vboxsync
5bf0ee311caa414469f26237ff607cb1b3591508vboxsyncint rtPathFromNativeEx(char **ppszPath, const char *pszNativePath, const char *pszBasePath)
5bf0ee311caa414469f26237ff607cb1b3591508vboxsync{
5bf0ee311caa414469f26237ff607cb1b3591508vboxsync NOREF(pszBasePath);
5bf0ee311caa414469f26237ff607cb1b3591508vboxsync return rtPathFromNative(ppszPath, pszNativePath);
5bf0ee311caa414469f26237ff607cb1b3591508vboxsync}
5bf0ee311caa414469f26237ff607cb1b3591508vboxsync
5bf0ee311caa414469f26237ff607cb1b3591508vboxsync