summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBent Bisballe Nyeng <deva@aasimon.org>2018-10-06 12:37:44 +0200
committerBent Bisballe Nyeng <deva@aasimon.org>2018-10-06 12:37:44 +0200
commitfa5b7e32e12b6310c93a9d3c1c4654f61c0f6679 (patch)
treed00adbf15d1393b127b83b8e415128c9b849456c
parent0e2db9214ff3d6cbe4388224f405bc5d67d6a8d3 (diff)
Make relative paths cross-platform.
-rw-r--r--src/audioextractor.cc6
-rw-r--r--src/localehandler.cc3
-rw-r--r--src/project.cc7
-rw-r--r--src/projectrenderer.cc5
4 files changed, 13 insertions, 8 deletions
diff --git a/src/audioextractor.cc b/src/audioextractor.cc
index cf6e9e9..b9b743a 100644
--- a/src/audioextractor.cc
+++ b/src/audioextractor.cc
@@ -168,12 +168,12 @@ void AudioExtractor::exportSelections()
}
// Create output path:
- QString path = exportpath + "/" + prefix + "/samples";
+ QString path = exportpath + QDir::separator() + prefix + QDir::separator() + "samples";
QDir d;
d.mkpath(path);
// Write all sample chunks to single output file:
- QString file = path + "/" + QString::number(idx) + "-" + prefix + ".wav";
+ QString file = path + QDir::separator() + QString::number(idx) + "-" + prefix + ".wav";
SF_INFO sf_info;
sf_info.format = SF_FORMAT_WAV | SF_FORMAT_FLOAT;
@@ -274,7 +274,7 @@ void AudioExtractor::exportSelections()
}
}
- QFile xmlfile(exportpath + "/" + prefix + "/" + prefix + ".xml");
+ QFile xmlfile(exportpath + QDir::separator() + prefix + QDir::separator() + prefix + ".xml");
xmlfile.open(QIODevice::WriteOnly);
xmlfile.write(doc.toByteArray());
xmlfile.close();
diff --git a/src/localehandler.cc b/src/localehandler.cc
index 9bc08c8..37eb4ef 100644
--- a/src/localehandler.cc
+++ b/src/localehandler.cc
@@ -31,13 +31,14 @@
#include <QTranslator>
#include <QString>
#include <QFile>
+#include <QDir>
LocaleHandler::LocaleHandler(QApplication& app)
{
QString locale = QLocale().name().section('_', 0, 0);
if(!locale.isEmpty() && locale != "C")
{
- QString file = LOCALEDIR"/dgedit_" + locale + ".qm";
+ QString file = QString(LOCALEDIR) + QDir::separator() + "dgedit_" + locale + ".qm";
if(QFile::exists(file))
{
translator.load(file);
diff --git a/src/project.cc b/src/project.cc
index e592439..9cac537 100644
--- a/src/project.cc
+++ b/src/project.cc
@@ -27,6 +27,8 @@
#include "project.h"
#include <QtGlobal>
+#include <QFileInfo>
+#include <QDir>
#include <iostream>
@@ -61,10 +63,11 @@ void AudioFile::setFile(const QString& file)
QString AudioFile::getAbsoluteFile() const
{
- if(file.left(1) != "/")
+ QFileInfo info(file);
+ if(info.isRelative())
{
// Prepend root path
- return instrument.getProject().getRawFileRoot() + "/" + file;
+ return instrument.getProject().getRawFileRoot() + QDir::separator() + file;
}
return file;
diff --git a/src/projectrenderer.cc b/src/projectrenderer.cc
index 4d87b73..c6f24b0 100644
--- a/src/projectrenderer.cc
+++ b/src/projectrenderer.cc
@@ -29,6 +29,7 @@
#include <QDomDocument>
#include <QFile>
#include <QApplication>
+#include <QDir>
#include "project.h"
#include "audioextractor.h"
@@ -98,7 +99,7 @@ void ProjectRenderer::render()
QDomElement instrument_node = doc.createElement("instrument");
instrument_node.setAttribute("name", instrument.getInstrumentName());
- QString file = instrument.getPrefix() + "/" + instrument.getPrefix() + ".xml";
+ QString file = instrument.getPrefix() + QDir::separator() + instrument.getPrefix() + ".xml";
instrument_node.setAttribute("file", file);
instruments.appendChild(instrument_node);
auto audiofile_ids = instrument.getAudioFileList();
@@ -125,7 +126,7 @@ void ProjectRenderer::render()
qApp->processEvents();
}
- QFile xmlfile(project.getExportPath() + "/drumkit.xml");
+ QFile xmlfile(project.getExportPath() + QDir::separator() + "drumkit.xml");
xmlfile.open(QIODevice::WriteOnly);
xmlfile.write(doc.toByteArray());
xmlfile.close();