78 *mErrString = source; |
78 *mErrString = source; |
79 ret = FmErrSrcPathDoNotExist; |
79 ret = FmErrSrcPathDoNotExist; |
80 return ret; |
80 return ret; |
81 } |
81 } |
82 QString newName; |
82 QString newName; |
|
83 bool isAcceptReplace = false; |
83 QFileInfo destFi( mTargetPath + fi.fileName() ); |
84 QFileInfo destFi( mTargetPath + fi.fileName() ); |
|
85 |
|
86 // while for duplicated file/dir |
84 while( destFi.exists() ) { |
87 while( destFi.exists() ) { |
85 emit askForRename( destFi.absoluteFilePath(), &newName ); |
88 if( destFi.isFile() && destFi.absoluteFilePath().compare( fi.absoluteFilePath(), Qt::CaseInsensitive ) != 0 ) { |
86 if( newName.isEmpty() ) { |
89 emit askForReplace( destFi.absoluteFilePath(), fi.absoluteFilePath(), &isAcceptReplace ); |
87 ret = FmErrCancel; |
90 if( isAcceptReplace ) { |
88 break; |
91 //delete src file |
89 } |
92 if( !QFile::remove( destFi.absoluteFilePath() ) ) { |
90 QString targetName = mTargetPath + newName; |
93 *mErrString = destFi.absoluteFilePath(); |
91 destFi.setFile( targetName ); |
94 ret = FmErrCannotRemove; |
|
95 break; |
|
96 } |
|
97 destFi.setFile( destFi.absoluteFilePath() ); |
|
98 } else { |
|
99 emit askForRename( destFi.absoluteFilePath(), &newName ); |
|
100 if( newName.isEmpty() ) { |
|
101 ret = FmErrCancel; |
|
102 break; |
|
103 } |
|
104 QString targetName = mTargetPath + newName; |
|
105 destFi.setFile( targetName ); |
|
106 } |
|
107 } else{ |
|
108 // destination is dir |
|
109 emit askForRename( destFi.absoluteFilePath(), &newName ); |
|
110 if( newName.isEmpty() ) { |
|
111 ret = FmErrCancel; |
|
112 break; |
|
113 } |
|
114 QString targetName = mTargetPath + newName; |
|
115 destFi.setFile( targetName ); |
|
116 } |
92 } |
117 } |
93 if( ret != FmErrNone ) { |
118 if( ret != FmErrNone ) { |
94 return ret; |
119 return ret; |
95 } |
120 } |
96 ret = copy( source, mTargetPath, newName ); |
121 ret = copy( source, mTargetPath, newName ); |