30 #include <QtCore/QDir>
31 #include <QtCore/QDirIterator>
32 #include <QtCore/QFileInfo>
42 LARGE_INTEGER TotalFileSize,
43 LARGE_INTEGER TotalBytesTransferred,
44 LARGE_INTEGER StreamSize,
45 LARGE_INTEGER StreamBytesTransferred,
47 DWORD dwCallbackReason,
49 HANDLE hDestinationFile,
53 f->processedSize( TotalBytesTransferred.QuadPart );
54 return PROGRESS_CONTINUE;
62 if( fileInfo.isSymLink() ) {
80 if( fileInfo.isDir() )
82 else if( fileInfo.isSymLink() )
84 if( fileInfo.isReadable() )
86 if( fileInfo.isWritable() )
88 if( fileInfo.isExecutable() )
94 if( fileInfo.isHidden() )
106 int _mode, JobFlags _flags )
108 kDebug(7101) <<
"copy(): " << src <<
" -> " << dest <<
", mode=" << _mode;
112 DWORD dwFlags = COPY_FILE_FAIL_IF_EXISTS;
114 if( _src == _dest ) {
119 if( !_src.exists() ) {
124 if ( _src.isDir() ) {
129 if( _dest.exists() ) {
130 if( _dest.isDir() ) {
144 if( !QFileInfo(_dest.dir().absolutePath()).exists() )
146 _dest.dir().mkdir(_dest.dir().absolutePath());
149 if ( CopyFileExW( ( LPCWSTR ) _src.filePath().utf16(),
150 ( LPCWSTR ) _dest.filePath().utf16(),
156 DWORD dwLastErr = GetLastError();
157 if ( dwLastErr == ERROR_FILE_NOT_FOUND )
159 else if ( dwLastErr == ERROR_ACCESS_DENIED )
166 FORMAT_MESSAGE_ALLOCATE_BUFFER |
167 FORMAT_MESSAGE_FROM_SYSTEM |
168 FORMAT_MESSAGE_IGNORE_INSERTS,
171 MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
174 OutputDebugString((WCHAR*)lpMsgBuf);
177 kDebug( 7101 ) <<
"Copying file "
190 kDebug(7101) <<
"========= LIST " << url.
url() <<
" =========";
194 redir.setProtocol(
config()->
readEntry(
"DefaultRemoteProtocol",
"smb"));
196 kDebug(7101) <<
"redirecting to " << redir.url();
202 dir.setFilter( QDir::AllEntries|QDir::Hidden );
204 if ( !
dir.exists() ) {
205 kDebug(7101) <<
"========= ERR_DOES_NOT_EXIST =========";
210 if ( !
dir.isReadable() ) {
211 kDebug(7101) <<
"========= ERR_CANNOT_ENTER_DIRECTORY =========";
215 QDirIterator it( dir );
217 while( it.hasNext() ) {
221 listEntry( entry,
false );
225 listEntry( entry,
true );
227 kDebug(7101) <<
"============= COMPLETED LIST ============";
233 KIO::JobFlags _flags )
235 kDebug(7101) <<
"rename(): " << src <<
" -> " << dest;
238 QFileInfo _dest(dest.toLocalFile());
241 if( _src == _dest ) {
246 if( !_src.exists() ) {
251 if( _dest.exists() ) {
252 if( _dest.isDir() ) {
257 if (!(_flags & KIO::Overwrite))
264 dwFlags = MOVEFILE_REPLACE_EXISTING;
269 dwFlags |= MOVEFILE_COPY_ALLOWED;
272 if ( MoveFileExW( ( LPCWSTR ) _src.filePath().utf16(),
273 ( LPCWSTR ) _dest.filePath().utf16(), dwFlags) == 0 )
275 if ( MoveFileW( ( LPCWSTR ) _src.filePath().utf16(),
276 ( LPCWSTR ) _dest.filePath().utf16()) == 0 )
279 DWORD dwLastErr = GetLastError();
280 if ( dwLastErr == ERROR_FILE_NOT_FOUND )
282 else if ( dwLastErr == ERROR_ACCESS_DENIED )
286 kDebug( 7101 ) <<
"Renaming file "
312 kDebug( 7101 ) <<
"Deleting file " << _path;
314 if( DeleteFileW( ( LPCWSTR ) _path.utf16() ) == 0 ) {
315 DWORD dwLastErr = GetLastError();
316 if ( dwLastErr == ERROR_PATH_NOT_FOUND )
318 else if( dwLastErr == ERROR_ACCESS_DENIED )
322 kDebug( 7101 ) <<
"Deleting file "
329 kDebug( 7101 ) <<
"Deleting directory " << _path;
330 if (!deleteRecursive(_path))
332 if( RemoveDirectoryW( ( LPCWSTR ) _path.utf16() ) == 0 ) {
333 DWORD dwLastErr = GetLastError();
334 if ( dwLastErr == ERROR_FILE_NOT_FOUND )
336 else if( dwLastErr == ERROR_ACCESS_DENIED )
340 kDebug( 7101 ) <<
"Deleting directory "
359 redir.setProtocol(
config()->
readEntry(
"DefaultRemoteProtocol",
"smb"));
361 kDebug(7101) <<
"redirecting to " << redir.url();
366 const QString sDetails = metaData(QLatin1String(
"details"));
367 int details = sDetails.isEmpty() ? 2 : sDetails.toInt();
368 kDebug(7101) <<
"FileProtocol::stat details=" << details;
KAutostart::StartPhase readEntry(const KConfigGroup &group, const char *key, const KAutostart::StartPhase &aDefault)
virtual void listDir(const KUrl &url)
virtual void symlink(const QString &target, const KUrl &dest, KIO::JobFlags flags)
void insert(uint field, const QString &value)
static UDSEntry createUDSEntryWin(const QFileInfo &fileInfo)
QString toLocalFile(AdjustPathOption trailing=LeaveTrailingSlash) const
virtual void chown(const KUrl &url, const QString &owner, const QString &group)
static QDebug kDebug(bool cond, int area=KDE_DEFAULT_DEBUG_AREA)
KSharedConfigPtr config()
virtual void copy(const KUrl &src, const KUrl &dest, int mode, KIO::JobFlags flags)
virtual void rename(const KUrl &src, const KUrl &dest, KIO::JobFlags flags)
static DWORD CALLBACK CopyProgressRoutine(LARGE_INTEGER TotalFileSize, LARGE_INTEGER TotalBytesTransferred, LARGE_INTEGER StreamSize, LARGE_INTEGER StreamBytesTransferred, DWORD dwStreamNumber, DWORD dwCallbackReason, HANDLE hSourceFile, HANDLE hDestinationFile, LPVOID lpData)
virtual void stat(const KUrl &url)
QString dir(const QString &fileClass)
int access(const QString &path, int mode)
QString url(AdjustPathOption trailing=LeaveTrailingSlash) const
virtual void del(const KUrl &url, bool isfile)