[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: Re: KDE/kdelibs/kioslave/file
From: Allen Winter <winter () kde ! org>
Date: 2009-02-16 13:44:20
Message-ID: 200902160844.21167.winter () kde ! org
[Download RAW message or body]
On Sunday 15 February 2009 11:14:30 am Christian Ehrlicher wrote:
> SVN commit 926538 by chehrlic:
>
Any or all of this backportable to 4.2?
> move KFileProtocol::stat to platform specific part. I don't like it but I'm unsure \
> what else will break when I use createUDSEntry() from file_win.cpp for unix. Maybe \
> others can take a look and convert createUDSEntry() for unix. + one small fix - \
> KMountPoint::findByPath() takes a QString, not a QByteArray
> M +1 -47 file.cpp
> M +42 -0 file_unix.cpp
> M +69 -40 file_win.cpp
>
>
> --- trunk/KDE/kdelibs/kioslave/file/file.cpp #926537:926538
> @@ -721,7 +721,7 @@
> if (::chmod(_dest_orig.data(), _mode) != 0)
> {
> // couldn't chmod. Eat the error if the filesystem apparently doesn't support it.
> - KMountPoint::Ptr mp = \
> KMountPoint::currentMountPoints().findByPath(_dest_orig); + \
> KMountPoint::Ptr mp = KMountPoint::currentMountPoints().findByPath(dest_orig); if \
> (mp && mp->testFileSystemFlag(KMountPoint::SupportsChmod)) warning( i18n( "Could \
> not change permissions for\n%1" , dest_orig ) ); }
> @@ -850,52 +850,6 @@
> return true;
> }
>
> -void FileProtocol::stat( const KUrl & url )
> -{
> - if (!url.isLocalFile()) {
> - KUrl redir(url);
> - redir.setProtocol(config()->readEntry("DefaultRemoteProtocol", "smb"));
> - redirection(redir);
> - kDebug(7101) << "redirecting to " << redir.url();
> - finished();
> - return;
> - }
> -
> - /* directories may not have a slash at the end if
> - * we want to stat() them; it requires that we
> - * change into it .. which may not be allowed
> - * stat("/is/unaccessible") -> rwx------
> - * stat("/is/unaccessible/") -> EPERM H.Z.
> - * This is the reason for the -1
> - */
> -#ifdef Q_WS_WIN
> - QByteArray _path( QFile::encodeName(url.toLocalFile()) );
> -#else
> - QByteArray _path( QFile::encodeName(url.path(KUrl::RemoveTrailingSlash)));
> -#endif
> - QString sDetails = metaData(QLatin1String("details"));
> - int details = sDetails.isEmpty() ? 2 : sDetails.toInt();
> - kDebug(7101) << "FileProtocol::stat details=" << details;
> -
> - UDSEntry entry;
> - if ( !createUDSEntry( url.fileName(), _path, entry, details, true /*with \
> acls*/ ) )
> - {
> - error( KIO::ERR_DOES_NOT_EXIST, _path );
> - return;
> - }
> -#if 0
> -///////// debug code
> - MetaData::iterator it1 = mOutgoingMetaData.begin();
> - for ( ; it1 != mOutgoingMetaData.end(); it1++ ) {
> - kDebug(7101) << it1.key() << " = " << it1.data();
> - }
> -/////////
> -#endif
> - statEntry( entry );
> -
> - finished();
> -}
> -
> /*
> void FileProtocol::testDir( const QString& path )
> {
> --- trunk/KDE/kdelibs/kioslave/file/file_unix.cpp #926537:926538
> @@ -571,3 +571,45 @@
> } else
> finished();
> }
> +
> +void FileProtocol::stat( const KUrl & url )
> +{
> + if (!url.isLocalFile()) {
> + KUrl redir(url);
> + redir.setProtocol(config()->readEntry("DefaultRemoteProtocol", "smb"));
> + redirection(redir);
> + kDebug(7101) << "redirecting to " << redir.url();
> + finished();
> + return;
> + }
> +
> + /* directories may not have a slash at the end if
> + * we want to stat() them; it requires that we
> + * change into it .. which may not be allowed
> + * stat("/is/unaccessible") -> rwx------
> + * stat("/is/unaccessible/") -> EPERM H.Z.
> + * This is the reason for the -1
> + */
> + QByteArray _path( QFile::encodeName(url.path(KUrl::RemoveTrailingSlash)));
> + QString sDetails = metaData(QLatin1String("details"));
> + int details = sDetails.isEmpty() ? 2 : sDetails.toInt();
> + kDebug(7101) << "FileProtocol::stat details=" << details;
> +
> + UDSEntry entry;
> + if ( !createUDSEntry( url.fileName(), _path, entry, details, true /*with \
> acls*/ ) ) + {
> + error( KIO::ERR_DOES_NOT_EXIST, _path );
> + return;
> + }
> +#if 0
> +///////// debug code
> + MetaData::iterator it1 = mOutgoingMetaData.begin();
> + for ( ; it1 != mOutgoingMetaData.end(); it1++ ) {
> + kDebug(7101) << it1.key() << " = " << it1.data();
> + }
> +/////////
> +#endif
> + statEntry( entry );
> +
> + finished();
> +}
> --- trunk/KDE/kdelibs/kioslave/file/file_win.cpp #926537:926538
> @@ -56,6 +56,52 @@
> return PROGRESS_CONTINUE;
> }
>
> +static UDSEntry createUDSEntryWin( const QFileInfo &fileInfo )
> +{
> + UDSEntry entry;
> +
> + entry.insert( KIO::UDSEntry::UDS_NAME, fileInfo.fileName() );
> + if( fileInfo.isSymLink() ) {
> + entry.insert( KIO::UDSEntry::UDS_TARGET_URL, fileInfo.symLinkTarget() );
> +/* TODO - or not useful on windows?
> + if ( details > 1 ) {
> + // It is a link pointing to nowhere
> + type = S_IFMT - 1;
> + access = S_IRWXU | S_IRWXG | S_IRWXO;
> +
> + entry.insert( KIO::UDSEntry::UDS_FILE_TYPE, type );
> + entry.insert( KIO::UDSEntry::UDS_ACCESS, access );
> + entry.insert( KIO::UDSEntry::UDS_SIZE, 0LL );
> + goto notype;
> +
> + }
> +*/
> + }
> + int type = S_IFREG;
> + int access = 0;
> + if( fileInfo.isDir() )
> + type = S_IFDIR;
> + else if( fileInfo.isSymLink() )
> + type = S_IFLNK;
> + if( fileInfo.isReadable() )
> + access |= S_IRUSR;
> + if( fileInfo.isWritable() )
> + access |= S_IWUSR;
> + if( fileInfo.isExecutable() )
> + access |= S_IXUSR;
> +
> + entry.insert( KIO::UDSEntry::UDS_FILE_TYPE, type );
> + entry.insert( KIO::UDSEntry::UDS_ACCESS, access );
> + entry.insert( KIO::UDSEntry::UDS_SIZE, fileInfo.size() );
> +
> + entry.insert( KIO::UDSEntry::UDS_MODIFICATION_TIME, \
> fileInfo.lastModified().toTime_t() ); + entry.insert( KIO::UDSEntry::UDS_USER, \
> fileInfo.owner() ); + entry.insert( KIO::UDSEntry::UDS_GROUP, fileInfo.group() \
> ); + entry.insert( KIO::UDSEntry::UDS_ACCESS_TIME, \
> fileInfo.lastRead().toTime_t() ); +
> + return entry;
> +}
> +
> void FileProtocol::copy( const KUrl &src, const KUrl &dest,
> int _mode, JobFlags _flags )
> {
> @@ -150,47 +196,8 @@
> UDSEntry entry;
> while( it.hasNext() ) {
> it.next();
> - QFileInfo fileInfo = it.fileInfo();
> + UDSEntry entry = createUDSEntryWin( it.fileInfo() );
>
> - entry.insert( KIO::UDSEntry::UDS_NAME, it.fileName() );
> - if( fileInfo.isSymLink() ) {
> - entry.insert( KIO::UDSEntry::UDS_TARGET_URL, fileInfo.symLinkTarget() \
> );
> -/* TODO - or not useful on windows?
> - if ( details > 1 ) {
> - // It is a link pointing to nowhere
> - type = S_IFMT - 1;
> - access = S_IRWXU | S_IRWXG | S_IRWXO;
> -
> - entry.insert( KIO::UDSEntry::UDS_FILE_TYPE, type );
> - entry.insert( KIO::UDSEntry::UDS_ACCESS, access );
> - entry.insert( KIO::UDSEntry::UDS_SIZE, 0LL );
> - goto notype;
> -
> - }
> -*/
> - }
> - int type = S_IFREG;
> - int access = 0;
> - if( fileInfo.isDir() )
> - type = S_IFDIR;
> - else if( fileInfo.isSymLink() )
> - type = S_IFLNK;
> - if( fileInfo.isReadable() )
> - access |= S_IRUSR;
> - if( fileInfo.isWritable() )
> - access |= S_IWUSR;
> - if( fileInfo.isExecutable() )
> - access |= S_IXUSR;
> -
> - entry.insert( KIO::UDSEntry::UDS_FILE_TYPE, type );
> - entry.insert( KIO::UDSEntry::UDS_ACCESS, access );
> - entry.insert( KIO::UDSEntry::UDS_SIZE, fileInfo.size() );
> -
> - entry.insert( KIO::UDSEntry::UDS_MODIFICATION_TIME, \
> fileInfo.lastModified().toTime_t() );
> - entry.insert( KIO::UDSEntry::UDS_USER, fileInfo.owner() );
> - entry.insert( KIO::UDSEntry::UDS_GROUP, fileInfo.group() );
> - entry.insert( KIO::UDSEntry::UDS_ACCESS_TIME, \
> fileInfo.lastRead().toTime_t() );
> -
> listEntry( entry, false );
> entry.clear();
> }
> @@ -312,3 +319,25 @@
> {
> error( KIO::ERR_CANNOT_CHOWN, url.toLocalFile() );
> }
> +
> +void FileProtocol::stat( const KUrl & url )
> +{
> + if (!url.isLocalFile()) {
> + KUrl redir(url);
> + redir.setProtocol(config()->readEntry("DefaultRemoteProtocol", "smb"));
> + redirection(redir);
> + kDebug(7101) << "redirecting to " << redir.url();
> + finished();
> + return;
> + }
> +
> + const QString sDetails = metaData(QLatin1String("details"));
> + int details = sDetails.isEmpty() ? 2 : sDetails.toInt();
> + kDebug(7101) << "FileProtocol::stat details=" << details;
> +
> + UDSEntry entry = createUDSEntryWin( QFileInfo(url.toLocalFile()) );
> +
> + statEntry( entry );
> +
> + finished();
> +}
>
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic