@ -105,11 +105,11 @@ void UBLibraryController::createDirectory(QUrl& pDirPath)
QDir ( ) . mkpath ( pDirPath . toLocalFile ( ) ) ;
QDir ( ) . mkpath ( pDirPath . toLocalFile ( ) ) ;
}
}
void UBLibraryController : : routeItem ( QString & pItem , QString pMiddleDirectory )
QString UBLibraryController : : getBaseDestinationForItem ( QString & pItem )
{
{
QFileInfo itemToRoute ( pItem ) ;
QString mimetype = UBFileSystemUtils : : mimeTypeFromFileName ( itemToRoute . fileName ( ) ) ;
QString destination ( " " ) ;
QString destination ( " " ) ;
QString mimetype = UBFileSystemUtils : : mimeTypeFromFileName ( pItem ) ;
if ( mimetype . contains ( " audio " ) )
if ( mimetype . contains ( " audio " ) )
destination = mAudioStandardDirectoryPath . toLocalFile ( ) ;
destination = mAudioStandardDirectoryPath . toLocalFile ( ) ;
@ -123,10 +123,30 @@ void UBLibraryController::routeItem(QString& pItem, QString pMiddleDirectory)
else
else
destination = mInteractiveUserDirectoryPath . toLocalFile ( ) ;
destination = mInteractiveUserDirectoryPath . toLocalFile ( ) ;
}
}
else {
return destination ;
return ;
}
}
void UBLibraryController : : routeDataItem ( QString & pItem , QByteArray pData )
{
QString fileName = QFileInfo ( pItem ) . fileName ( ) ;
QString destination = getBaseDestinationForItem ( pItem ) ;
if ( ! destination . isEmpty ( ) ) {
QString destinationPath = UBFileSystemUtils : : normalizeFilePath ( QString ( " %0/%1 " ) . arg ( destination ) . arg ( fileName ) ) ;
QFile file ( destinationPath ) ;
if ( file . open ( QIODevice : : WriteOnly ) ) {
file . write ( pData ) ;
file . close ( ) ;
}
}
else
qWarning ( ) < < " no destination found for pItem " < < pItem ;
}
void UBLibraryController : : routeItem ( QString & pItem , QString pMiddleDirectory )
{
QFileInfo itemToRoute ( pItem ) ;
QString destination = getBaseDestinationForItem ( pItem ) ;
if ( ! destination . isEmpty ( ) ) {
if ( ! destination . isEmpty ( ) ) {
if ( ! pMiddleDirectory . isEmpty ( ) ) {
if ( ! pMiddleDirectory . isEmpty ( ) ) {
destination = destination + " / " + pMiddleDirectory ;
destination = destination + " / " + pMiddleDirectory ;