* 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:
Axel Dörfler 2009-10-21 09:47:26 +00:00
parent 10075eae29
commit 823808b52b

View File

@ -1,26 +1,11 @@
/*
* Copyright (c) 2008 Stephan Aßmus <superstippi@gmx.de>
* Copyright (c) 1998-2007 Matthijs Hollemans
*
* Permission is hereby granted, free of charge, to any person obtaining a
* 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.
* Copyright 2008, Stephan Aßmus <superstippi@gmx.de>.
* Copyright 1998-2007, Matthijs Hollemans.
*
* Distributed under the terms of the MIT License.
*/
#include "FileIterator.h"
#include <string.h>
@ -30,7 +15,7 @@
#include <Path.h>
FileIterator::FileIterator()
FileIterator::FileIterator()
{
}
@ -52,16 +37,21 @@ FileIterator::_ExamineFile(BEntry& entry, char* buffer, bool textFilesOnly)
if (!textFilesOnly)
return true;
BMimeType mimeType;
BNode node(&entry);
BNodeInfo nodeInfo(&node);
char mimeTypeString[B_MIME_TYPE_LENGTH];
if (nodeInfo.GetType(mimeTypeString) != B_OK)
return false;
if (nodeInfo.GetType(mimeTypeString) != B_OK) {
// 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;
if (mimeType.GetSupertype(&superType) == B_OK) {
if (strcmp("text", superType.Type()) == 0
|| strcmp("message", superType.Type()) == 0) {