1 /* 2 * Copyright (c) 2008 Stephan Aßmus <superstippi@gmx.de> 3 * Copyright (c) 1998-2007 Matthijs Hollemans 4 * 5 * Permission is hereby granted, free of charge, to any person obtaining a 6 * copy of this software and associated documentation files (the "Software"), 7 * to deal in the Software without restriction, including without limitation 8 * the rights to use, copy, modify, merge, publish, distribute, sublicense, 9 * and/or sell copies of the Software, and to permit persons to whom the 10 * Software is furnished to do so, subject to the following conditions: 11 * 12 * The above copyright notice and this permission notice shall be included in 13 * all copies or substantial portions of the Software. 14 * 15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 20 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 21 * DEALINGS IN THE SOFTWARE. 22 */ 23 24 #include "FileIterator.h" 25 26 #include <string.h> 27 28 #include <Entry.h> 29 #include <NodeInfo.h> 30 #include <Path.h> 31 32 33 FileIterator::FileIterator() 34 { 35 } 36 37 38 FileIterator::~FileIterator() 39 { 40 } 41 42 43 bool 44 FileIterator::_ExamineFile(BEntry& entry, char* buffer, bool textFilesOnly) 45 { 46 BPath path; 47 if (entry.GetPath(&path) != B_OK) 48 return false; 49 50 strcpy(buffer, path.Path()); 51 52 if (!textFilesOnly) 53 return true; 54 55 BNode node(&entry); 56 BNodeInfo nodeInfo(&node); 57 char mimeTypeString[B_MIME_TYPE_LENGTH]; 58 59 if (nodeInfo.GetType(mimeTypeString) != B_OK) 60 return false; 61 62 BMimeType mimeType(mimeTypeString); 63 BMimeType superType; 64 65 if (mimeType.GetSupertype(&superType) == B_OK) { 66 if (strcmp("text", superType.Type()) == 0 67 || strcmp("message", superType.Type()) == 0) { 68 return true; 69 } 70 } 71 72 return false; 73 } 74 75