dvander@251: /* dvander@251: * Copyright (C) 2012 David Anderson dvander@251: * dvander@251: * This file is part of SourcePawn. dvander@251: * dvander@251: * SourcePawn is free software: you can redistribute it and/or modify it under dvander@251: * the terms of the GNU General Public License as published by the Free dvander@251: * Software Foundation, either version 3 of the License, or (at your option) dvander@251: * any later version. dvander@251: * dvander@251: * SourcePawn is distributed in the hope that it will be useful, but WITHOUT ANY dvander@251: * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS dvander@251: * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. dvander@251: * dvander@251: * You should have received a copy of the GNU General Public License along with dvander@251: * SourcePawn. If not, see http://www.gnu.org/licenses/. dvander@251: */ dvander@251: #include dvander@251: #include "Zone.h" dvander@251: #include "FileSystem.h" dvander@255: #include "Heap-inl.h" dvander@255: #include "Handles-inl.h" dvander@251: dvander@251: bool dvander@251: ke::JoinPaths(Zone *zone, AutoFree &result, const char *base, const char *name) dvander@251: { dvander@251: const char *sep = OS::PathSeparator(); dvander@251: dvander@251: size_t baselen = strlen(base); dvander@251: size_t namelen = strlen(name); dvander@251: size_t seplen = strlen(sep); dvander@251: dvander@251: char *ptr = (char *)zone->malloc(baselen + seplen + namelen + 1); dvander@251: if (!ptr) dvander@251: return false; dvander@251: dvander@251: strcpy(ptr, base); dvander@251: strcpy(ptr + baselen, sep); dvander@251: strcpy(ptr + baselen + seplen, name); dvander@251: dvander@251: result = ptr; dvander@251: return true; dvander@251: }