diff --git a/src/common/pathTools.cpp b/src/common/pathTools.cpp new file mode 100644 index 000000000..424d64983 --- /dev/null +++ b/src/common/pathTools.cpp @@ -0,0 +1,34 @@ +/* + * Copyright 2011 Emmanuel Engelhart + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301, USA. + */ + +#include "pathTools.h" + +const char *nsStringToCString(const nsAString &str) { + const char *cStr; + nsCString tmpStr; + +#ifdef _WIN32 + LossyCopyUTF16toASCII(str, tmpStr): +#else + CopyUTF16toUTF8(str, tmpStr); +#endif + + NS_CStringGetData(tmpStr, &cStr); + return cStr; +} diff --git a/src/common/pathTools.h b/src/common/pathTools.h new file mode 100644 index 000000000..9713d4fcb --- /dev/null +++ b/src/common/pathTools.h @@ -0,0 +1,27 @@ +/* + * Copyright 2011 Emmanuel Engelhart + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301, USA. + */ + +#ifndef KIWIX_PATHTOOLS_H +#define KIWIX_PATHTOOLS_H + +#include "nsStringAPI.h" + +const char *nsStringToCString(const nsAString &path); + +#endif