* If you only want to search in text files, TextSearch will now guess the MIME
type if a file doesn't have one yet (and set it), instead of ignoring it completely. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@33694 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -1,26 +1,11 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2008 Stephan Aßmus <[email protected]>
|
* Copyright 2008, Stephan Aßmus <[email protected]>.
|
||||||
* Copyright (c) 1998-2007 Matthijs Hollemans
|
* Copyright 1998-2007, Matthijs Hollemans.
|
||||||
*
|
*
|
||||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
* Distributed under the terms of the MIT License.
|
||||||
* copy of this software and associated documentation files (the "Software"),
|
|
||||||
* to deal in the Software without restriction, including without limitation
|
|
||||||
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
|
||||||
* and/or sell copies of the Software, and to permit persons to whom the
|
|
||||||
* Software is furnished to do so, subject to the following conditions:
|
|
||||||
*
|
|
||||||
* The above copyright notice and this permission notice shall be included in
|
|
||||||
* all copies or substantial portions of the Software.
|
|
||||||
*
|
|
||||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
||||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
||||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
||||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
||||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
|
||||||
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
|
||||||
* DEALINGS IN THE SOFTWARE.
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
#include "FileIterator.h"
|
#include "FileIterator.h"
|
||||||
|
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
@@ -30,7 +15,7 @@
|
|||||||
#include <Path.h>
|
#include <Path.h>
|
||||||
|
|
||||||
|
|
||||||
FileIterator::FileIterator()
|
FileIterator::FileIterator()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -52,16 +37,21 @@ FileIterator::_ExamineFile(BEntry& entry, char* buffer, bool textFilesOnly)
|
|||||||
if (!textFilesOnly)
|
if (!textFilesOnly)
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
|
BMimeType mimeType;
|
||||||
BNode node(&entry);
|
BNode node(&entry);
|
||||||
BNodeInfo nodeInfo(&node);
|
BNodeInfo nodeInfo(&node);
|
||||||
char mimeTypeString[B_MIME_TYPE_LENGTH];
|
char mimeTypeString[B_MIME_TYPE_LENGTH];
|
||||||
|
|
||||||
if (nodeInfo.GetType(mimeTypeString) != B_OK)
|
if (nodeInfo.GetType(mimeTypeString) != B_OK) {
|
||||||
return false;
|
// try to get a MIME type before failing
|
||||||
|
if (BMimeType::GuessMimeType(path.Path(), &mimeType) != B_OK)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
nodeInfo.SetType(mimeType.Type());
|
||||||
|
} else
|
||||||
|
mimeType.SetTo(mimeTypeString);
|
||||||
|
|
||||||
BMimeType mimeType(mimeTypeString);
|
|
||||||
BMimeType superType;
|
BMimeType superType;
|
||||||
|
|
||||||
if (mimeType.GetSupertype(&superType) == B_OK) {
|
if (mimeType.GetSupertype(&superType) == B_OK) {
|
||||||
if (strcmp("text", superType.Type()) == 0
|
if (strcmp("text", superType.Type()) == 0
|
||||||
|| strcmp("message", superType.Type()) == 0) {
|
|| strcmp("message", superType.Type()) == 0) {
|
||||||
|
|||||||
Reference in New Issue
Block a user