1 /* 2 * Copyright 2002-2006, Haiku Inc. 3 * Distributed under the terms of the MIT License. 4 * 5 * Authors: 6 * Tyler Dauwalder 7 * Ingo Weinhold, bonefish@users.sf.net 8 */ 9 10 /*! 11 \file Mime.cpp 12 Mime type C functions implementation. 13 */ 14 15 #include <Entry.h> 16 #include <Messenger.h> 17 #include <Mime.h> 18 #if !defined(HAIKU_HOST_PLATFORM_DANO) && !defined(HAIKU_HOST_PLATFORM_BEOS) && !defined(HAIKU_HOST_PLATFORM_BONE) 19 # include <MimeType.h> 20 #endif 21 #include <mime/database_access.h> 22 #include <mime/UpdateMimeInfoThread.h> 23 #include <Node.h> 24 25 #include <unistd.h> 26 #include <sys/ioctl.h> 27 28 using namespace BPrivate; 29 30 // update_mime_info 31 /*! \brief Updates the MIME information (i.e MIME type) for one or more files. 32 If \a path points to a file, the MIME information for this file are 33 updated only. If it points to a directory and \a recursive is non-null, 34 the information for all the files in the given directory tree are updated. 35 If path is \c NULL all files are considered; \a recursive is ignored in 36 this case. 37 \param path The path to a file or directory, or \c NULL. 38 \param recursive Non-null to trigger recursive behavior. 39 \param synchronous If non-null update_mime_info() waits until the 40 operation is finished, otherwise it returns immediately and the 41 update is done asynchronously. 42 \param force If non-null, also the information for files are updated that 43 have already been updated. 44 \return 45 - \c B_OK: Everything went fine. 46 - An error code otherwise. 47 */ 48 int 49 update_mime_info(const char *path, int recursive, int synchronous, int force) 50 { 51 if (!path) 52 return B_BAD_VALUE; 53 54 entry_ref ref; 55 status_t error = get_ref_for_path(path, &ref); 56 if (error != B_OK) 57 return error; 58 59 BPrivate::Storage::Mime::UpdateMimeInfoThread updater("MIME update thread", 60 B_NORMAL_PRIORITY, BMessenger(), &ref, recursive, force, NULL); 61 return updater.DoUpdate(); 62 } 63 64 // create_app_meta_mime 65 /*! Creates a MIME database entry for one or more applications. 66 \a path should either point to an application file or should be \c NULL. 67 In the first case a MIME database entry for that application is created, 68 in the second case entries for all applications are created. 69 \param path The path to an application file, or \c NULL. 70 \param recursive Currently unused. 71 \param synchronous If non-null create_app_meta_mime() waits until the 72 operation is finished, otherwise it returns immediately and the 73 operation is done asynchronously. 74 \param force If non-null, entries are created even if they do already 75 exist. 76 \return 77 - \c B_OK: Everything went fine. 78 - An error code otherwise. 79 */ 80 status_t 81 create_app_meta_mime(const char *path, int recursive, int synchronous, 82 int force) 83 { 84 // We don't have a MIME DB... 85 return B_OK; 86 } 87 88