13d5283df73f9ca38aa591e10f2129e771924dbevboxsync/* $Id$ */
13d5283df73f9ca38aa591e10f2129e771924dbevboxsync/** @file
1f5867c6a115bbb281bcdc0b2c90eefe1de81134vboxsync * IPRT - RTPathJoin.
13d5283df73f9ca38aa591e10f2129e771924dbevboxsync */
13d5283df73f9ca38aa591e10f2129e771924dbevboxsync
13d5283df73f9ca38aa591e10f2129e771924dbevboxsync/*
e64031e20c39650a7bc902a3e1aba613b9415deevboxsync * Copyright (C) 2010 Oracle Corporation
13d5283df73f9ca38aa591e10f2129e771924dbevboxsync *
13d5283df73f9ca38aa591e10f2129e771924dbevboxsync * This file is part of VirtualBox Open Source Edition (OSE), as
13d5283df73f9ca38aa591e10f2129e771924dbevboxsync * available from http://www.virtualbox.org. This file is free software;
13d5283df73f9ca38aa591e10f2129e771924dbevboxsync * you can redistribute it and/or modify it under the terms of the GNU
13d5283df73f9ca38aa591e10f2129e771924dbevboxsync * General Public License (GPL) as published by the Free Software
13d5283df73f9ca38aa591e10f2129e771924dbevboxsync * Foundation, in version 2 as it comes in the "COPYING" file of the
13d5283df73f9ca38aa591e10f2129e771924dbevboxsync * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
13d5283df73f9ca38aa591e10f2129e771924dbevboxsync * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
13d5283df73f9ca38aa591e10f2129e771924dbevboxsync *
13d5283df73f9ca38aa591e10f2129e771924dbevboxsync * The contents of this file may alternatively be used under the terms
13d5283df73f9ca38aa591e10f2129e771924dbevboxsync * of the Common Development and Distribution License Version 1.0
13d5283df73f9ca38aa591e10f2129e771924dbevboxsync * (CDDL) only, as it comes in the "COPYING.CDDL" file of the
13d5283df73f9ca38aa591e10f2129e771924dbevboxsync * VirtualBox OSE distribution, in which case the provisions of the
13d5283df73f9ca38aa591e10f2129e771924dbevboxsync * CDDL are applicable instead of those of the GPL.
13d5283df73f9ca38aa591e10f2129e771924dbevboxsync *
13d5283df73f9ca38aa591e10f2129e771924dbevboxsync * You may elect to license modified versions of this file under the
13d5283df73f9ca38aa591e10f2129e771924dbevboxsync * terms and conditions of either the GPL or the CDDL or both.
13d5283df73f9ca38aa591e10f2129e771924dbevboxsync */
13d5283df73f9ca38aa591e10f2129e771924dbevboxsync
13d5283df73f9ca38aa591e10f2129e771924dbevboxsync
13d5283df73f9ca38aa591e10f2129e771924dbevboxsync/*******************************************************************************
13d5283df73f9ca38aa591e10f2129e771924dbevboxsync* Header Files *
13d5283df73f9ca38aa591e10f2129e771924dbevboxsync*******************************************************************************/
13d5283df73f9ca38aa591e10f2129e771924dbevboxsync#include "internal/iprt.h"
13d5283df73f9ca38aa591e10f2129e771924dbevboxsync#include <iprt/path.h>
13d5283df73f9ca38aa591e10f2129e771924dbevboxsync#include <iprt/assert.h>
13d5283df73f9ca38aa591e10f2129e771924dbevboxsync#include <iprt/err.h>
13d5283df73f9ca38aa591e10f2129e771924dbevboxsync#include <iprt/string.h>
13d5283df73f9ca38aa591e10f2129e771924dbevboxsync
13d5283df73f9ca38aa591e10f2129e771924dbevboxsync
13d5283df73f9ca38aa591e10f2129e771924dbevboxsync
13d5283df73f9ca38aa591e10f2129e771924dbevboxsync
13d5283df73f9ca38aa591e10f2129e771924dbevboxsyncRTDECL(int) RTPathJoin(char *pszPathDst, size_t cbPathDst, const char *pszPathSrc,
13d5283df73f9ca38aa591e10f2129e771924dbevboxsync const char *pszAppend)
13d5283df73f9ca38aa591e10f2129e771924dbevboxsync{
13d5283df73f9ca38aa591e10f2129e771924dbevboxsync AssertPtr(pszPathDst);
13d5283df73f9ca38aa591e10f2129e771924dbevboxsync AssertPtr(pszPathSrc);
1f5867c6a115bbb281bcdc0b2c90eefe1de81134vboxsync AssertPtr(pszAppend);
13d5283df73f9ca38aa591e10f2129e771924dbevboxsync
13d5283df73f9ca38aa591e10f2129e771924dbevboxsync /*
13d5283df73f9ca38aa591e10f2129e771924dbevboxsync * The easy way: Copy the path into the buffer and call RTPathAppend.
13d5283df73f9ca38aa591e10f2129e771924dbevboxsync */
13d5283df73f9ca38aa591e10f2129e771924dbevboxsync size_t cchPathSrc = strlen(pszPathSrc);
13d5283df73f9ca38aa591e10f2129e771924dbevboxsync if (cchPathSrc >= cbPathDst)
13d5283df73f9ca38aa591e10f2129e771924dbevboxsync return VERR_BUFFER_OVERFLOW;
13d5283df73f9ca38aa591e10f2129e771924dbevboxsync memcpy(pszPathDst, pszPathSrc, cchPathSrc + 1);
13d5283df73f9ca38aa591e10f2129e771924dbevboxsync
13d5283df73f9ca38aa591e10f2129e771924dbevboxsync return RTPathAppend(pszPathDst, cbPathDst, pszAppend);
13d5283df73f9ca38aa591e10f2129e771924dbevboxsync}
13d5283df73f9ca38aa591e10f2129e771924dbevboxsync