src/FileSystem.cpp
author Asher Baker <asherkin@gmail.com>
Mon Jun 10 00:46:29 2013 +0100 (2013-06-10)
changeset 262 c4b1341297e5
parent 255 b3cf7e052ddf
permissions -rw-r--r--
Fix warnings when building with clang.
dvander@251
     1
/*
dvander@251
     2
 * Copyright (C) 2012 David Anderson
dvander@251
     3
 *
dvander@251
     4
 * This file is part of SourcePawn.
dvander@251
     5
 *
dvander@251
     6
 * SourcePawn is free software: you can redistribute it and/or modify it under
dvander@251
     7
 * the terms of the GNU General Public License as published by the Free
dvander@251
     8
 * Software Foundation, either version 3 of the License, or (at your option)
dvander@251
     9
 * any later version.
dvander@251
    10
 * 
dvander@251
    11
 * SourcePawn is distributed in the hope that it will be useful, but WITHOUT ANY
dvander@251
    12
 * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
dvander@251
    13
 * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
dvander@251
    14
 *
dvander@251
    15
 * You should have received a copy of the GNU General Public License along with
dvander@251
    16
 * SourcePawn. If not, see http://www.gnu.org/licenses/.
dvander@251
    17
 */
dvander@251
    18
#include <string.h>
dvander@251
    19
#include "Zone.h"
dvander@251
    20
#include "FileSystem.h"
dvander@255
    21
#include "Heap-inl.h"
dvander@255
    22
#include "Handles-inl.h"
dvander@251
    23
dvander@251
    24
bool
dvander@251
    25
ke::JoinPaths(Zone *zone, AutoFree<char> &result, const char *base, const char *name)
dvander@251
    26
{
dvander@251
    27
    const char *sep = OS::PathSeparator();
dvander@251
    28
dvander@251
    29
    size_t baselen = strlen(base);
dvander@251
    30
    size_t namelen = strlen(name);
dvander@251
    31
    size_t seplen = strlen(sep);
dvander@251
    32
dvander@251
    33
    char *ptr = (char *)zone->malloc(baselen + seplen + namelen + 1);
dvander@251
    34
    if (!ptr)
dvander@251
    35
        return false;
dvander@251
    36
dvander@251
    37
    strcpy(ptr, base);
dvander@251
    38
    strcpy(ptr + baselen, sep);
dvander@251
    39
    strcpy(ptr + baselen + seplen, name);
dvander@251
    40
dvander@251
    41
    result = ptr;
dvander@251
    42
    return true;
dvander@251
    43
}