[haiku-commits] r33694 - haiku/trunk/src/apps/text_search

  • From: axeld@xxxxxxxxxxxxxxxx
  • To: haiku-commits@xxxxxxxxxxxxx
  • Date: Wed, 21 Oct 2009 11:47:26 +0200 (CEST)

Author: axeld
Date: 2009-10-21 11:47:26 +0200 (Wed, 21 Oct 2009)
New Revision: 33694
Changeset: http://dev.haiku-os.org/changeset/33694/haiku

Modified:
   haiku/trunk/src/apps/text_search/FileIterator.cpp
Log:
* 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.


Modified: haiku/trunk/src/apps/text_search/FileIterator.cpp
===================================================================
--- haiku/trunk/src/apps/text_search/FileIterator.cpp   2009-10-21 09:27:13 UTC 
(rev 33693)
+++ haiku/trunk/src/apps/text_search/FileIterator.cpp   2009-10-21 09:47:26 UTC 
(rev 33694)
@@ -1,26 +1,11 @@
 /*
- * Copyright (c) 2008 Stephan Aßmus <superstippi@xxxxxx>
- * 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@xxxxxx>.
+ * 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 @@
        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;
 
-       BMimeType mimeType(mimeTypeString);
-       BMimeType superType;
+               nodeInfo.SetType(mimeType.Type());
+       } else
+               mimeType.SetTo(mimeTypeString);
 
+       BMimeType superType;
        if (mimeType.GetSupertype(&superType) == B_OK) {
                if (strcmp("text", superType.Type()) == 0
                        || strcmp("message", superType.Type()) == 0) {


Other related posts:

  • » [haiku-commits] r33694 - haiku/trunk/src/apps/text_search - axeld