Re: Replacement for KMimeType::isBinaryData?

2015-01-04 Thread David Faure
On Wednesday 29 October 2014 00:30:04 Kevin Funk wrote:
 Heya,
 
 I didn't find a suitable replacement for KMimeType::isBinaryData in KF5. Is
 there some?
 
 http://lxr.kde.org/ident?v=kf5-qt5_i=isBinaryData_remember=1 shows exactly
 two users of this function.
 
 Worth considering upstreaming to Qt?

Well, you tell me :)
Upstreaming requires providing use cases for it, so tell me what your use case 
is.

Looking at the implementation of the function, I fear that it is hard to prove 
that it's correct and useful.

It only checks the first 32 bytes of the file, so it's not like this could 
become a QByteArray method as I first thought when you talked about 
upstreaming it (e.g. QByteArray::isText(), isPrintable() or isBinaryData())

It would have to stay file-specific, i.e. in QMimeType.

Then, there are non-printable characters outside of the 0-31 range, so this 
method is rather isBinaryData - true means it is, false means we don't know, 
maybe it is. That makes me uneasy about the usefulness of the method.
It is there because XDG shared-mime-info specifies this is what we should 
fallback to, in the absence of a known extension or a known file content, to 
choose between a fallback to text/plain and a fallback to application/octet-
stream, but it's really an imperfect heuristic. I'm not sure we want more code 
depending on that imperfect heuristic, by making it public API again.

Which goes back to -- what's your use case for it :-)

-- 
David Faure, fa...@kde.org, http://www.davidfaure.fr
Working on KDE Frameworks 5

___
Kde-frameworks-devel mailing list
Kde-frameworks-devel@kde.org
https://mail.kde.org/mailman/listinfo/kde-frameworks-devel


Replacement for KMimeType::isBinaryData?

2014-10-28 Thread Kevin Funk
Heya,

I didn't find a suitable replacement for KMimeType::isBinaryData in KF5. Is 
there some?

http://lxr.kde.org/ident?v=kf5-qt5_i=isBinaryData_remember=1 shows exactly 
two users of this function.

Worth considering upstreaming to Qt?

-- 
Kevin Funk | kf...@kde.org | http://kfunk.org
___
Kde-frameworks-devel mailing list
Kde-frameworks-devel@kde.org
https://mail.kde.org/mailman/listinfo/kde-frameworks-devel