569 CleanupStack::PopAndDestroy( array ); |
569 CleanupStack::PopAndDestroy( array ); |
570 } |
570 } |
571 |
571 |
572 QString FmUtils::fillPathWithSplash( const QString &filePath ) |
572 QString FmUtils::fillPathWithSplash( const QString &filePath ) |
573 { |
573 { |
574 QString newFilePath = filePath ; |
574 QString newFilePath; |
575 if( filePath.isEmpty() ) { |
575 if( filePath.isEmpty() ) { |
576 return newFilePath; |
576 return newFilePath; |
577 } |
577 } |
578 |
578 |
579 QString tempString; |
579 foreach( QChar ch, filePath ) { |
580 for( int i=0; i<newFilePath.length(); i++ ) { |
580 if( ch == QChar('\\') || ch == QChar('/') ) { |
581 QChar ch( newFilePath[i] ); |
581 newFilePath.append( QDir::separator() ); |
582 if( ch == QChar('\\') ) { |
|
583 tempString.append( QChar('/') ); |
|
584 } else { |
582 } else { |
585 tempString.append( ch ); |
583 newFilePath.append( ch ); |
586 } |
584 } |
587 } |
585 } |
588 newFilePath = tempString; |
586 |
589 |
587 if( newFilePath.right( 1 )!= QDir::separator() ){ |
590 if( newFilePath.right( 1 )!= QChar('/') ){ |
588 newFilePath.append( QDir::separator() ); |
591 newFilePath.append( QChar('/') ); |
|
592 } |
589 } |
593 |
590 |
594 return newFilePath; |
591 return newFilePath; |
595 } |
592 } |
596 |
593 |
639 QString checkedPath = fillPathWithSplash( path ); |
636 QString checkedPath = fillPathWithSplash( path ); |
640 |
637 |
641 logString = QString( "checkFolderToDriveFilter_fillPathWithSplash: " ) + checkedPath; |
638 logString = QString( "checkFolderToDriveFilter_fillPathWithSplash: " ) + checkedPath; |
642 FmLogger::log( logString ); |
639 FmLogger::log( logString ); |
643 |
640 |
644 if( checkedPath.compare( QString( "C:/data/"), Qt::CaseInsensitive ) == 0 ) { |
641 if( checkedPath.compare( Folder_C_Data, Qt::CaseInsensitive ) == 0 ) { |
645 FmLogger::log( QString( " change from c:/data/ to C:/" ) ); |
642 FmLogger::log( QString( " change from c:/data/ to C:/" ) ); |
646 return QString( "C:/" ); |
643 return Drive_C; |
647 } |
644 } |
648 return path; |
645 return path; |
649 |
646 |
650 } |
647 } |
651 |
648 |
655 if( path.length() <= 3 && !isDriveAvailable( path ) ) { //used to filter locked drive |
652 if( path.length() <= 3 && !isDriveAvailable( path ) ) { //used to filter locked drive |
656 FmLogger::log( QString( "isPathAccessabel false: path is drive and not available" ) ); |
653 FmLogger::log( QString( "isPathAccessabel false: path is drive and not available" ) ); |
657 return false; |
654 return false; |
658 } |
655 } |
659 QFileInfo fileInfo( path ); |
656 QFileInfo fileInfo( path ); |
660 if( fileInfo.absoluteFilePath().contains( QString( Drive_C ), Qt::CaseInsensitive ) && |
657 if( fileInfo.absoluteFilePath().contains( Drive_C, Qt::CaseInsensitive ) && |
661 !fileInfo.absoluteFilePath().contains( QString( Folder_C_Data ), Qt::CaseInsensitive ) ) { |
658 !fileInfo.absoluteFilePath().contains( Folder_C_Data, Qt::CaseInsensitive ) ) { |
662 FmLogger::log( QString( "isPathAccessabel false: path contain C and not in data folder" ) ); |
659 FmLogger::log( QString( "isPathAccessabel false: path contain C and not in data folder" ) ); |
663 return false; |
660 return false; |
664 } |
661 } |
665 if( fileInfo.absoluteFilePath().contains( QString( Drive_D ), Qt::CaseInsensitive ) ) { |
662 if( fileInfo.absoluteFilePath().contains( Drive_D, Qt::CaseInsensitive ) ) { |
666 FmLogger::log( QString( "isPathAccessabel false: path contain D" ) ); |
663 FmLogger::log( QString( "isPathAccessabel false: path contain D" ) ); |
667 return false; |
664 return false; |
668 } |
665 } |
669 if( fileInfo.absoluteFilePath().contains( QString( Drive_Z ), Qt::CaseInsensitive ) ) { |
666 if( fileInfo.absoluteFilePath().contains( Drive_Z, Qt::CaseInsensitive ) ) { |
670 FmLogger::log( QString( "isPathAccessabel false: path contain Z" ) ); |
667 FmLogger::log( QString( "isPathAccessabel false: path contain Z" ) ); |
671 return false; |
668 return false; |
672 } |
669 } |
673 if( !fileInfo.exists() ) { |
670 if( !fileInfo.exists() ) { |
674 FmLogger::log( QString( "isPathAccessabel false: path not exist" ) ); |
671 FmLogger::log( QString( "isPathAccessabel false: path not exist" ) ); |
842 return QString(); |
839 return QString(); |
843 } |
840 } |
844 |
841 |
845 QString FmUtils::formatPath( const QString &path ) |
842 QString FmUtils::formatPath( const QString &path ) |
846 { |
843 { |
847 QString formatPath = path; |
844 QString formatPath; |
848 QRegExp regExp( "/" ); |
845 foreach( QChar ch, path ) { |
849 formatPath.replace( regExp, "\\" ); |
846 if( ch == QChar('\\') || ch == QChar('/') ) { |
850 |
847 formatPath.append( QDir::separator() ); |
851 if( formatPath.right( 1 ) != QChar('\\') ){ |
848 } else { |
852 formatPath.append( QChar('\\') ); |
849 formatPath.append( ch ); |
|
850 } |
|
851 } |
|
852 |
|
853 if( formatPath.right( 1 ) != QDir::separator() ){ |
|
854 formatPath.append( QDir::separator() ); |
853 } |
855 } |
854 return formatPath; |
856 return formatPath; |
855 } |
857 } |
856 |
858 |
857 int FmUtils::getMaxFileNameLength() |
859 int FmUtils::getMaxFileNameLength() |