Proposal: Extended Attribute support in Kioslave: File

Richard Moore richmoore44 at gmail.com
Fri May 5 11:37:36 BST 2006


On 5/5/06, Daniel Nakata <dnakata at nerdshack.com> wrote:
> Well, it would look something like this:
>
> ...
>    // Determine the mimetype of the file to be retrieved, and emit it.
>    // This is mandatory in all slaves (for KRun/BrowserRun to work).
> #ifdef HAVE_XATTR
>    char *outBuf = NULL;
>    ssize_t getxattrResult = fgetxattr( fd, "user.mime_type", NULL, 0 );
>    if( getxattrResult > 0 ) {
>        outBuf = malloc( getxattrResult + 1 );

s/malloc/new/ (we're C++ not C).

>        memset( outBuf, 0, getxattrResult + 1 );
>        fgetxattr( fd, "user.mime_type", outBuf, getxattrResult+1 );
>        emit mimeType( QString::fromLatin1(outBuf) );

Should this be from latin1 or is the attribute utf8?

>        free( outBuf );

s/free/delete/

>    } else {
> #endif
>    KMimeType::Ptr mt = KMimeType::findByURL( url, buff.st_mode, true /* local
> URL */ );
>    emit mimeType( mt->name() );
> #ifdef HAVE_XATTR
>    }
> #endif
>
>    KIO::filesize_t processed_size = 0;

Cheers

Rich.




More information about the kde-core-devel mailing list