Back to index

lightning-sunbird  0.9+nobinonly
Typedefs | Functions
nsPluginsDirBeOS.cpp File Reference
#include "nsPluginsDir.h"
#include "prlink.h"
#include "plstr.h"
#include "prmem.h"
#include "nsReadableUtils.h"
#include "nsString.h"
#include <File.h>
#include <AppFileInfo.h>
#include <Message.h>
#include <String.h>

Go to the source code of this file.

Typedefs

typedef char *(* BeOS_Plugin_GetMIMEDescription )()

Functions

static char * GetFileName (const char *pathname)
static nsresult GetMimeExtensions (const char *mimeType, char *extensions, int extLen)

Typedef Documentation

typedef char*(* BeOS_Plugin_GetMIMEDescription)()

Definition at line 158 of file nsPluginsDirBeOS.cpp.


Function Documentation

static char* GetFileName ( const char *  pathname) [static]

Definition at line 64 of file nsPluginsDirBeOS.cpp.

{
        const char* filename = nsnull;
                
        // this is most likely a path, so skip to the filename
        filename = PL_strrchr(pathname, '/');
        if(filename)
                ++filename;
        else
                filename = pathname;

        return PL_strdup(filename);
}

Here is the call graph for this function:

Here is the caller graph for this function:

static nsresult GetMimeExtensions ( const char *  mimeType,
char *  extensions,
int  extLen 
) [static]

Definition at line 78 of file nsPluginsDirBeOS.cpp.

{
    // check variables
    if (!mimeType || !extensions || extLen < 1) return NS_ERROR_FAILURE;
    extensions[0] = '\0';
    
    // make mime object
    BMimeType mime(mimeType) ;
    if (mime.InitCheck() != B_OK)
        return NS_ERROR_FAILURE;
    
    // get extensions : comma separated (if multiple extensions in a mime-type)
    // ex) "jpg,jpeg"
    BString extStr("");
    BMessage extMsg;
    mime.GetFileExtensions(&extMsg);
    uint32 type;
    int32 types_num;
    if (extMsg.GetInfo("extensions", &type, &types_num) != B_OK
        || type != B_STRING_TYPE || types_num == 0)
        return NS_ERROR_FAILURE;
    
    for (int i = 0 ; i < types_num ; i ++) {
        const char *ext;
        if (extMsg.FindString("extensions", i, &ext) != B_OK) {
            break;
        }
        if (i > 0)
            extStr.Append(",");
        extStr.Append(ext);
    }
    PL_strncpyz(extensions, extStr.String(), extLen) ;
    
    return NS_OK;
}

Here is the call graph for this function:

Here is the caller graph for this function: