Commit fd173bff authored by Hugo Beauzée-Luyssen's avatar Hugo Beauzée-Luyssen

Workspace: If possible, create a hard link instead of copying.

parent 5fb810b3
......@@ -25,6 +25,7 @@
#include "Media.h"
#include "SettingsManager.h"
#include <cerrno>
#include <QFile>
#include <QFileInfo>
......@@ -39,11 +40,30 @@ WorkspaceWorker::WorkspaceWorker( Media *media ) :
void
WorkspaceWorker::run()
{
QFile file( m_media->fileInfo()->absoluteFilePath() );
const QString &projectPath = VLMC_PROJECT_GET_STRING( "general/Workspace" );
const QString dest = projectPath + '/' + m_media->fileInfo()->fileName();
bool hardLinkOk = false;
file.copy( m_media->fileInfo()->absoluteFilePath(), dest );
qDebug() << "Media copied to:" << dest;
#ifdef Q_OS_UNIX
if ( link( m_media->fileInfo()->absoluteFilePath().toStdString().c_str(),
dest.toStdString().c_str() ) < 0 )
{
qDebug() << "Can't create hard link:" << strerror(errno) << "falling back to"
" hard copy mode.";
}
else
{
qDebug() << "Media hard linked to:" << dest;
hardLinkOk = true;
}
#endif
if ( hardLinkOk == false )
{
QFile file( m_media->fileInfo()->absoluteFilePath() );
file.copy( m_media->fileInfo()->absoluteFilePath(), dest );
qDebug() << "Media copied to:" << dest;
}
emit copied( m_media, dest );
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment