equal
deleted
inserted
replaced
220 void FmUtils::createDefaultFolders( const QString &driverName ) |
220 void FmUtils::createDefaultFolders( const QString &driverName ) |
221 { |
221 { |
222 Q_UNUSED( driverName ); |
222 Q_UNUSED( driverName ); |
223 } |
223 } |
224 |
224 |
|
225 /*! |
|
226 fill splash in the end of \a filePath if the path is not a file |
|
227 All "/" and "\" will be changed to QDir::separator |
|
228 \sa formatPath only changed "/" and "\" to QDir::separator |
|
229 */ |
225 QString FmUtils::fillPathWithSplash( const QString &filePath ) |
230 QString FmUtils::fillPathWithSplash( const QString &filePath ) |
226 { |
231 { |
227 QString newFilePath; |
232 QString newFilePath; |
228 if( filePath.isEmpty() ) { |
233 if( filePath.isEmpty() ) { |
229 return newFilePath; |
234 return newFilePath; |
230 } |
235 } |
231 |
236 |
232 foreach( QChar ch, filePath ) { |
237 newFilePath = formatPath( filePath ); |
233 if( ch == QChar('\\') || ch == QChar('/') ) { |
|
234 newFilePath.append( QDir::separator() ); |
|
235 } else { |
|
236 newFilePath.append( ch ); |
|
237 } |
|
238 } |
|
239 |
238 |
240 if( newFilePath.right( 1 )!= QDir::separator() ){ |
239 if( newFilePath.right( 1 )!= QDir::separator() ){ |
241 newFilePath.append( QDir::separator() ); |
240 newFilePath.append( QDir::separator() ); |
242 } |
241 } |
243 |
|
244 return newFilePath; |
242 return newFilePath; |
245 } |
243 } |
246 |
244 |
247 QString FmUtils::removePathSplash( const QString &filePath ) |
245 QString FmUtils::removePathSplash( const QString &filePath ) |
248 { |
246 { |
435 { |
433 { |
436 Q_UNUSED( folderPath ); |
434 Q_UNUSED( folderPath ); |
437 return false; |
435 return false; |
438 } |
436 } |
439 |
437 |
|
438 /*! |
|
439 All "/" and "\" in \a path will be changed to QDir::separator |
|
440 \sa fillPathWithSplash, fillPathWithSplash will append QDir::separator in the end if path is no a file |
|
441 */ |
440 QString FmUtils::formatPath( const QString &path ) |
442 QString FmUtils::formatPath( const QString &path ) |
441 { |
443 { |
442 QString formatPath; |
444 QString formatPath; |
443 foreach( QChar ch, path ) { |
445 if( path.isEmpty() ) { |
444 if( ch == QChar('\\') || ch == QChar('/') ) { |
446 return formatPath; |
445 formatPath.append( QDir::separator() ); |
447 } |
446 } else { |
448 |
447 formatPath.append( ch ); |
449 foreach( QChar ch, path ) { |
448 } |
450 if( ch == QChar('\\') || ch == QChar('/') ) { |
449 } |
451 formatPath.append( QDir::separator() ); |
450 |
452 } else { |
451 if( formatPath.right( 1 ) != QDir::separator() ){ |
453 formatPath.append( ch ); |
452 formatPath.append( QDir::separator() ); |
454 } |
453 } |
455 } |
|
456 |
454 return formatPath; |
457 return formatPath; |
455 } |
458 } |
456 |
459 |
457 int FmUtils::getMaxFileNameLength() |
460 int FmUtils::getMaxFileNameLength() |
458 { |
461 { |
520 |
523 |
521 // do not add default volume for win32 version as this is only the dummy implememnt for debug on windows |
524 // do not add default volume for win32 version as this is only the dummy implememnt for debug on windows |
522 return driverInfo.volumeName(); |
525 return driverInfo.volumeName(); |
523 } |
526 } |
524 |
527 |
|
528 /*! |
|
529 Check if \a dest is sub level path of \a src |
|
530 Used to check True/False when copy a folder to itself or its subfolder |
|
531 For example, c:\data\test is sub path of c:\data. |
|
532 But c:\data123\test is not sub path of c:\data. |
|
533 So after got right part of path, the first char must be \ or / |
|
534 */ |
|
535 bool FmUtils::isSubLevelPath( const QString &src, const QString &dest ) |
|
536 { |
|
537 FM_LOG("FmUtils::isSubFolder: src=" + src + " dest=" + dest); |
|
538 QString checkedSrc( FmUtils::fillPathWithSplash( src ) ); |
|
539 QString checkedDest( FmUtils::fillPathWithSplash( dest ) ); |
|
540 |
|
541 if( checkedDest.contains( checkedSrc, Qt::CaseInsensitive) && |
|
542 checkedDest.length() > checkedSrc.length() ) { |
|
543 // for example c:\data\ vs c:\data\123\ |
|
544 FM_LOG("FmUtils::isSubFolder: true"); |
|
545 return true; |
|
546 } |
|
547 // for example c:\data\ vs c:\data\ |
|
548 // for example c:\data\ vs c:\data123\ |
|
549 |
|
550 FM_LOG("FmUtils::isSubFolder: false"); |
|
551 return false; |
|
552 } |
|
553 |
|
554 int FmUtils::setFileAttributes( const QString &srcFile, const QString &desFile ) |
|
555 { |
|
556 return FmErrNone; |
|
557 } |