fixed error on remplacing file:/// depending on system os

preferencesAboutTextFull
Claudio Valerio 13 years ago
parent b85adf852c
commit 2a2d5669b1
  1. 22
      src/adaptors/UBSvgSubsetAdaptor.cpp
  2. 7
      src/domain/UBW3CWidget.cpp
  3. 16
      src/frameworks/UBFileSystemUtils.cpp
  4. 2
      src/frameworks/UBFileSystemUtils.h

@ -1806,12 +1806,10 @@ void UBSvgSubsetAdaptor::UBSvgSubsetWriter::audioItemToLinkedAudio(UBGraphicsAud
}
QString audioFileHref = audioItem->mediaFileUrl().toString();
//on windows
if(audioFileHref.startsWith("file:///"))
audioFileHref = audioFileHref.replace("file:///" + mDocumentPath + "/","");
//mac and linux
if(audioFileHref.startsWith("file://"))
audioFileHref = audioFileHref.replace("file://" + mDocumentPath + "/","");
audioFileHref = UBFileSystemUtils::removeLocalFilePrefix(audioFileHref);
if(audioFileHref.startsWith(mDocumentPath))
audioFileHref = audioFileHref.replace(mDocumentPath + "/","");
mXmlWriter.writeAttribute(nsXLink, "href", audioFileHref);
mXmlWriter.writeEndElement();
}
@ -1837,13 +1835,11 @@ void UBSvgSubsetAdaptor::UBSvgSubsetWriter::videoItemToLinkedVideo(UBGraphicsVid
}
QString videoFileHref = videoItem->mediaFileUrl().toString();
//on windows
if(videoFileHref.startsWith("file:///"))
videoFileHref = videoFileHref.replace("file:///" + mDocumentPath + "/","");
//on mac and linux
if(videoFileHref.startsWith("file://"))
videoFileHref = videoFileHref.replace("file://" + mDocumentPath + "/","");
mXmlWriter.writeAttribute(nsXLink, "href", videoFileHref);
videoFileHref = UBFileSystemUtils::removeLocalFilePrefix(videoFileHref);
if(videoFileHref.startsWith(mDocumentPath))
videoFileHref = videoFileHref.replace(mDocumentPath + "/","");
mXmlWriter.writeAttribute(nsXLink, "href", videoFileHref);
mXmlWriter.writeEndElement();
}

@ -246,9 +246,7 @@ QString UBW3CWidget::createNPAPIWrapperInDir(const QString& pUrl, const QDir& pD
const QString& pName)
{
QString url = pUrl;
// if the file name start with file:// it has be removed because QFileInfo doesn't support this form
url = url.replace("file:///","");
url = url.replace("file://","");
url = UBFileSystemUtils::removeLocalFilePrefix(url);
QString name = pName;
QFileInfo fi(url);
@ -305,8 +303,7 @@ QString UBW3CWidget::createNPAPIWrapperInDir(const QString& pUrl, const QDir& pD
if (fi.exists()){
QString target = widgetLibraryPath + "/" + fi.fileName();
QString source = pUrl;
source = source.replace("file:///","");
source = source.replace("file://","");
source = UBFileSystemUtils::removeLocalFilePrefix(source);
QFile::copy(source, target);
}

@ -39,6 +39,22 @@ UBFileSystemUtils::~UBFileSystemUtils()
// NOOP
}
QString UBFileSystemUtils::removeLocalFilePrefix(QString input)
{
#ifdef Q_WS_WIN
if(input.startsWith("file:///"))
return input.mid(8);
else
return input;
#else
if(input.startsWith("file://"))
return input.mid(7);
else
return input;
#endif
}
bool UBFileSystemUtils::isAZipFile(QString &filePath)
{
if(QFileInfo(filePath).isDir()) return false;

@ -28,6 +28,8 @@ class UBFileSystemUtils
UBFileSystemUtils();
virtual ~UBFileSystemUtils();
static QString removeLocalFilePrefix(QString input);
static QString defaultTempDirName() { return QCoreApplication::applicationName(); }
static QString defaultTempDirPath();
static QString createTempDir(const QString& templateString = defaultTempDirName(), bool autoDeleteOnExit = true);

Loading…
Cancel
Save