/* * @(#)Support.cpp * * This file is part of webCDwriter - Network CD/DVD Writing. * * Copyright (C) 1999-2004 Jörg P. M. Haeger * * webCDwriter is free software. See CDWserver.cpp for details. */ #include #include #include #include #include #include "Support.h" boolean toBoolean(const char *str) { // skip initial whitespace while (*str == '\t' || *str == ' ') str++; // ignore trailing whitespace const char *str2 = str + strlen(str); while (str2 > str && (*str2 == '\t' || *str2 == ' ')) str2--; int n = str2 - str; char str3[n + 1]; strncpy(str3, str, n); str3[n] = 0; if (strcasecmp(str3, "1") == 0 || strcasecmp(str3, "on") == 0 || strcasecmp(str3, "true") == 0) return true; else if (strcasecmp(str3, "0") == 0 || strcasecmp(str3, "off") == 0 || strcasecmp(str3, "false") == 0) return false; else throw new Exception("invalid boolean"); } void makeDirs(const char *fileName) { char str[1024]; int i = 0; while (1) { for (; fileName[i] != 0 && fileName[i] != '/'; i++) str[i] = fileName[i]; str[i] = 0; if (fileName[i] == 0) break; mkdir(str, S_IRWXU); str[i++] = '/'; } }