94 ret = FmErrCannotRemove; |
95 ret = FmErrCannotRemove; |
95 break; |
96 break; |
96 } |
97 } |
97 destFi.setFile( destFi.absoluteFilePath() ); |
98 destFi.setFile( destFi.absoluteFilePath() ); |
98 } else { |
99 } else { |
99 emit askForRename( destFi.absoluteFilePath(), &newName ); |
100 queryForRename( destFi.absoluteFilePath(), &newName ); |
100 if( newName.isEmpty() ) { |
101 if( newName.isEmpty() ) { |
101 ret = FmErrCancel; |
102 ret = FmErrCancel; |
102 break; |
103 break; |
103 } |
104 } |
104 QString targetName = mTargetPath + newName; |
105 QString targetName = mTargetPath + newName; |
105 destFi.setFile( targetName ); |
106 destFi.setFile( targetName ); |
106 } |
107 } |
107 } else{ |
108 } else{ |
108 // destination is dir |
109 // destination is dir |
109 emit askForRename( destFi.absoluteFilePath(), &newName ); |
110 queryForRename( destFi.absoluteFilePath(), &newName ); |
110 if( newName.isEmpty() ) { |
111 if( newName.isEmpty() ) { |
111 ret = FmErrCancel; |
112 ret = FmErrCancel; |
112 break; |
113 break; |
113 } |
114 } |
114 QString targetName = mTargetPath + newName; |
115 QString targetName = mTargetPath + newName; |
153 quint64 fileSize = fi.size(); |
154 quint64 fileSize = fi.size(); |
154 if ( !QFile::copy( source, newName )) { |
155 if ( !QFile::copy( source, newName )) { |
155 *mErrString = source; |
156 *mErrString = source; |
156 ret = FmErrCannotCopy; |
157 ret = FmErrCannotCopy; |
157 } else { |
158 } else { |
158 IncreaseProgress( fileSize ); |
159 increaseProgress( fileSize ); |
159 } |
160 } |
160 } else if (fi.isDir()) { |
161 } else if (fi.isDir()) { |
161 ret = copyDirInsideContent( source, newName ); |
162 ret = copyDirInsideContent( source, newName ); |
162 } else { |
163 } else { |
163 qWarning( "Things other than file and directory are not copied" ); |
164 qWarning( "Things other than file and directory are not copied" ); |
169 |
170 |
170 |
171 |
171 |
172 |
172 int FmOperationCopy::copyDirInsideContent( const QString &srcPath, const QString &destPath ) |
173 int FmOperationCopy::copyDirInsideContent( const QString &srcPath, const QString &destPath ) |
173 { |
174 { |
174 if( destPath.contains( srcPath, Qt::CaseInsensitive ) ) { |
175 QFileInfo srcInfo( srcPath ); |
|
176 QFileInfo destInfo( destPath ); |
|
177 |
|
178 QString destUpPath = FmUtils::fillPathWithSplash( destInfo.absolutePath() ); |
|
179 if( destUpPath.contains( srcPath, Qt::CaseInsensitive ) ) { |
175 *mErrString = destPath; |
180 *mErrString = destPath; |
176 return FmErrCopyDestToSubFolderInSrc; |
181 return FmErrCopyDestToSubFolderInSrc; |
177 } |
182 } |
178 |
183 |
179 QFileInfo srcInfo( srcPath ); |
184 |
180 if( !srcInfo.isDir() || !srcInfo.exists() ) { |
185 if( !srcInfo.isDir() || !srcInfo.exists() ) { |
181 *mErrString = srcPath; |
186 *mErrString = srcPath; |
182 return FmErrSrcPathDoNotExist; |
187 return FmErrSrcPathDoNotExist; |
183 } |
188 } |
184 |
189 |
185 QFileInfo destInfo( destPath ); |
|
186 if( !destInfo.exists() ) { |
190 if( !destInfo.exists() ) { |
187 if( !destInfo.dir().mkdir( destInfo.absoluteFilePath() ) ) { |
191 if( !destInfo.dir().mkdir( destInfo.absoluteFilePath() ) ) { |
188 *mErrString = destPath; |
192 *mErrString = destPath; |
189 return FmErrCannotMakeDir; |
193 return FmErrCannotMakeDir; |
190 } |
194 } |
208 QString newFilePath = destPath + fileInfo.absoluteFilePath().mid( srcPath.length() ); |
212 QString newFilePath = destPath + fileInfo.absoluteFilePath().mid( srcPath.length() ); |
209 if (!QFile::copy( fileInfo.absoluteFilePath(), newFilePath ) ) { |
213 if (!QFile::copy( fileInfo.absoluteFilePath(), newFilePath ) ) { |
210 *mErrString = fileInfo.absoluteFilePath(); |
214 *mErrString = fileInfo.absoluteFilePath(); |
211 return FmErrCannotCopy; |
215 return FmErrCannotCopy; |
212 } |
216 } |
213 IncreaseProgress( fileInfo.size() ); |
217 increaseProgress( fileInfo.size() ); |
214 } else if( fileInfo.isDir() ) { |
218 } else if( fileInfo.isDir() ) { |
215 //makedir |
219 //makedir |
216 QString newDirPath = destPath + fileInfo.absoluteFilePath().mid( srcPath.length() ); |
220 QString newDirPath = destPath + fileInfo.absoluteFilePath().mid( srcPath.length() ); |
217 if( !QDir( newDirPath ).exists() && !QDir( destPath ).mkdir( newDirPath ) ) { |
221 if( !QDir( newDirPath ).exists() && !QDir( destPath ).mkdir( newDirPath ) ) { |
218 *mErrString = newDirPath; |
222 *mErrString = newDirPath; |