Back to index

lightning-sunbird  0.9+nobinonly
Classes | Functions
nsILocalFileMac.idl File Reference
import "nsILocalFile.idl";
#include <Files.h>
#include <CFURL.h>

Go to the source code of this file.

Classes

interface  nsILocalFileMac
interface  nsILocalFileMac_MOZILLA_1_8_BRANCH

Functions

native OSType (OSType)
native FSSpec (FSSpec)
native FSSpecPtr (FSSpec)
native FSRef (FSRef)
native FSRefPtr (FSRef)
native CFURLRef (CFURLRef)
NS_EXPORT const char * NS_TruncNodeName (const char *aNode, char *outBuf)
NS_EXPORT nsresult NS_NewLocalFileWithFSSpec (const FSSpec *inSpec, PRBool followSymlinks, nsILocalFileMac **result)

Function Documentation

native CFURLRef ( CFURLRef  )

Here is the caller graph for this function:

native FSRef ( FSRef  )

Here is the caller graph for this function:

native FSRefPtr ( FSRef  )
native FSSpec ( FSSpec  )
native FSSpecPtr ( FSSpec  )
NS_EXPORT nsresult NS_NewLocalFileWithFSSpec ( const FSSpec inSpec,
PRBool  followSymlinks,
nsILocalFileMac **  result 
)

Definition at line 3528 of file nsLocalFileMac.cpp.

{
    nsLocalFile* file = new nsLocalFile();
    if (file == nsnull)
        return NS_ERROR_OUT_OF_MEMORY;
    NS_ADDREF(file);

    file->SetFollowLinks(followLinks);

    nsresult rv = file->InitWithFSSpec(inSpec);
    if (NS_FAILED(rv)) {
        NS_RELEASE(file);
        return rv;
    }
    *result = file;
    return NS_OK;
}

Here is the call graph for this function:

Here is the caller graph for this function:

NS_EXPORT const char* NS_TruncNodeName ( const char *  aNode,
char *  outBuf 
)

Definition at line 544 of file nsLocalFileMac.cpp.

{
    PRUint32 nodeLen;
    if ((nodeLen = strlen(aNode)) > 31)
    {
        static PRBool sInitialized = PR_FALSE;
        static CharByteTable sTable;
        // Init to "..." in case we fail to get the ellipsis token
        static char sEllipsisTokenStr[4] = { '.', '.', '.', 0 };
        static PRUint8 sEllipsisTokenLen = 3;
                
        if (!sInitialized)
        {
            // Entries in the table are:
            // 0 == 1 byte char
            // 1 == 2 byte char
            FillParseTable(sTable, smSystemScript);
            
            Handle itl4ResHandle = nsnull;
            long offset, len;
            ::GetIntlResourceTable(smSystemScript, smUnTokenTable, &itl4ResHandle, &offset, &len);
            if (itl4ResHandle)
            {
                UntokenTable *untokenTableRec = (UntokenTable *)(*itl4ResHandle + offset);
                if (untokenTableRec->lastToken >= tokenEllipsis)
                {
                    offset += untokenTableRec->index[tokenEllipsis];
                    char *tokenStr = (*itl4ResHandle + offset);
                    sEllipsisTokenLen = tokenStr[0];
                    memcpy(sEllipsisTokenStr, &tokenStr[1], sEllipsisTokenLen);
                }
                ::ReleaseResource(itl4ResHandle);
            }
            sInitialized = PR_TRUE;
        }

        PRInt32 halfLen = (31 - sEllipsisTokenLen) / 2;
        PRInt32 charSize = 0, srcPos, destPos;
        for (srcPos = 0; srcPos + charSize <= halfLen; srcPos += charSize)
            charSize = sTable[aNode[srcPos]] ? 2 : 1;
                    
        memcpy(outBuf, aNode, srcPos);
        memcpy(outBuf + srcPos, sEllipsisTokenStr, sEllipsisTokenLen);
        destPos = srcPos + sEllipsisTokenLen;
        
        for (; srcPos < nodeLen - halfLen; srcPos += charSize)
            charSize = sTable[aNode[srcPos]] ? 2 : 1;
            
        memcpy(outBuf + destPos, aNode + srcPos, nodeLen - srcPos);
        destPos += (nodeLen - srcPos);
        outBuf[destPos] = '\0';
        return outBuf;
    }
    return aNode;
}

Here is the caller graph for this function:

native OSType ( OSType  )

Here is the caller graph for this function: