991c9e5bee3cfd192c3a4b19855625f3ce1cc494vboxsync/* $Id$ */
991c9e5bee3cfd192c3a4b19855625f3ce1cc494vboxsync/** @file
991c9e5bee3cfd192c3a4b19855625f3ce1cc494vboxsync * IPRT - RTPathChangeToDosSlashes
991c9e5bee3cfd192c3a4b19855625f3ce1cc494vboxsync */
991c9e5bee3cfd192c3a4b19855625f3ce1cc494vboxsync
991c9e5bee3cfd192c3a4b19855625f3ce1cc494vboxsync/*
e64031e20c39650a7bc902a3e1aba613b9415deevboxsync * Copyright (C) 2010 Oracle Corporation
991c9e5bee3cfd192c3a4b19855625f3ce1cc494vboxsync *
991c9e5bee3cfd192c3a4b19855625f3ce1cc494vboxsync * This file is part of VirtualBox Open Source Edition (OSE), as
991c9e5bee3cfd192c3a4b19855625f3ce1cc494vboxsync * available from http://www.virtualbox.org. This file is free software;
991c9e5bee3cfd192c3a4b19855625f3ce1cc494vboxsync * you can redistribute it and/or modify it under the terms of the GNU
991c9e5bee3cfd192c3a4b19855625f3ce1cc494vboxsync * General Public License (GPL) as published by the Free Software
991c9e5bee3cfd192c3a4b19855625f3ce1cc494vboxsync * Foundation, in version 2 as it comes in the "COPYING" file of the
991c9e5bee3cfd192c3a4b19855625f3ce1cc494vboxsync * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
991c9e5bee3cfd192c3a4b19855625f3ce1cc494vboxsync * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
991c9e5bee3cfd192c3a4b19855625f3ce1cc494vboxsync *
991c9e5bee3cfd192c3a4b19855625f3ce1cc494vboxsync * The contents of this file may alternatively be used under the terms
991c9e5bee3cfd192c3a4b19855625f3ce1cc494vboxsync * of the Common Development and Distribution License Version 1.0
991c9e5bee3cfd192c3a4b19855625f3ce1cc494vboxsync * (CDDL) only, as it comes in the "COPYING.CDDL" file of the
991c9e5bee3cfd192c3a4b19855625f3ce1cc494vboxsync * VirtualBox OSE distribution, in which case the provisions of the
991c9e5bee3cfd192c3a4b19855625f3ce1cc494vboxsync * CDDL are applicable instead of those of the GPL.
991c9e5bee3cfd192c3a4b19855625f3ce1cc494vboxsync *
991c9e5bee3cfd192c3a4b19855625f3ce1cc494vboxsync * You may elect to license modified versions of this file under the
991c9e5bee3cfd192c3a4b19855625f3ce1cc494vboxsync * terms and conditions of either the GPL or the CDDL or both.
991c9e5bee3cfd192c3a4b19855625f3ce1cc494vboxsync */
991c9e5bee3cfd192c3a4b19855625f3ce1cc494vboxsync
991c9e5bee3cfd192c3a4b19855625f3ce1cc494vboxsync
991c9e5bee3cfd192c3a4b19855625f3ce1cc494vboxsync/*******************************************************************************
991c9e5bee3cfd192c3a4b19855625f3ce1cc494vboxsync* Header Files *
991c9e5bee3cfd192c3a4b19855625f3ce1cc494vboxsync*******************************************************************************/
991c9e5bee3cfd192c3a4b19855625f3ce1cc494vboxsync#include "internal/iprt.h"
991c9e5bee3cfd192c3a4b19855625f3ce1cc494vboxsync#include <iprt/path.h>
991c9e5bee3cfd192c3a4b19855625f3ce1cc494vboxsync
991c9e5bee3cfd192c3a4b19855625f3ce1cc494vboxsync
991c9e5bee3cfd192c3a4b19855625f3ce1cc494vboxsync/**
ad27e1d5e48ca41245120c331cc88b50464813cevboxsync * Changes all the slashes in the specified path to DOS style.
991c9e5bee3cfd192c3a4b19855625f3ce1cc494vboxsync *
991c9e5bee3cfd192c3a4b19855625f3ce1cc494vboxsync * Unless @a fForce is set, nothing will be done when on a UNIX flavored system
991c9e5bee3cfd192c3a4b19855625f3ce1cc494vboxsync * since paths wont work with DOS style slashes there.
991c9e5bee3cfd192c3a4b19855625f3ce1cc494vboxsync *
991c9e5bee3cfd192c3a4b19855625f3ce1cc494vboxsync * @returns @a pszPath.
991c9e5bee3cfd192c3a4b19855625f3ce1cc494vboxsync * @param pszPath The path to modify.
991c9e5bee3cfd192c3a4b19855625f3ce1cc494vboxsync * @param fForce Whether to force the conversion on non-DOS OSes.
991c9e5bee3cfd192c3a4b19855625f3ce1cc494vboxsync */
991c9e5bee3cfd192c3a4b19855625f3ce1cc494vboxsyncRTDECL(char *) RTPathChangeToDosSlashes(char *pszPath, bool fForce)
991c9e5bee3cfd192c3a4b19855625f3ce1cc494vboxsync{
991c9e5bee3cfd192c3a4b19855625f3ce1cc494vboxsync#if !defined(RT_OS_WINDOWS) && !defined(RT_OS_OS2)
991c9e5bee3cfd192c3a4b19855625f3ce1cc494vboxsync if (fForce)
991c9e5bee3cfd192c3a4b19855625f3ce1cc494vboxsync#endif
991c9e5bee3cfd192c3a4b19855625f3ce1cc494vboxsync {
991c9e5bee3cfd192c3a4b19855625f3ce1cc494vboxsync char ch;
991c9e5bee3cfd192c3a4b19855625f3ce1cc494vboxsync char *psz = pszPath;
991c9e5bee3cfd192c3a4b19855625f3ce1cc494vboxsync while ((ch = *psz) != '\0')
991c9e5bee3cfd192c3a4b19855625f3ce1cc494vboxsync {
7b3afd2ded72ec334541b330aa65588a65bc794evboxsync if (ch == '/')
7b3afd2ded72ec334541b330aa65588a65bc794evboxsync *psz = '\\';
991c9e5bee3cfd192c3a4b19855625f3ce1cc494vboxsync psz++;
991c9e5bee3cfd192c3a4b19855625f3ce1cc494vboxsync }
991c9e5bee3cfd192c3a4b19855625f3ce1cc494vboxsync }
991c9e5bee3cfd192c3a4b19855625f3ce1cc494vboxsync return pszPath;
991c9e5bee3cfd192c3a4b19855625f3ce1cc494vboxsync}
991c9e5bee3cfd192c3a4b19855625f3ce1cc494vboxsync