Back to index

lightning-sunbird  0.9+nobinonly
Public Types | Static Public Member Functions
nsDiskCache Class Reference

#include <nsDiskCache.h>

List of all members.

Public Types

enum  { kCurrentVersion = 0x00010008 }
enum  { kData, kMetaData }

Static Public Member Functions

static PLDHashNumber Hash (const char *key)
 nsDiskCache::Hash(const char * key)
static nsresult Truncate (PRFileDesc *fd, PRUint32 newEOF)

Detailed Description

Definition at line 49 of file nsDiskCache.h.

Member Enumeration Documentation

anonymous enum

Definition at line 51 of file nsDiskCache.h.

            kCurrentVersion = 0x00010008      // format = 16 bits major version/16 bits minor version
anonymous enum

Definition at line 55 of file nsDiskCache.h.

Member Function Documentation

PLDHashNumber nsDiskCache::Hash ( const char *  key) [static]

nsDiskCache::Hash(const char * key)

This algorithm of this method implies nsDiskCacheRecords will be stored in a certain order on disk. If the algorithm changes, existing cache map files may become invalid, and therefore the kCurrentVersion needs to be revised.

Definition at line 279 of file nsDiskCacheDevice.cpp.

    PLDHashNumber h = 0;
    for (const PRUint8* s = (PRUint8*) key; *s != '\0'; ++s)
        h = (h >> (PL_DHASH_BITS - 4)) ^ (h << 4) ^ *s;
    return (h == 0 ? ULONG_MAX : h);

Here is the caller graph for this function:

nsresult nsDiskCache::Truncate ( PRFileDesc fd,
PRUint32  newEOF 
) [static]

Definition at line 289 of file nsDiskCacheDevice.cpp.

    // use modified SetEOF from nsFileStreams::SetEOF()

#if defined(XP_UNIX) || defined(XP_BEOS)
    if (ftruncate(PR_FileDesc2NativeHandle(fd), newEOF) != 0) {
        NS_ERROR("ftruncate failed");
        return NS_ERROR_FAILURE;

#elif defined(XP_MAC)
    if (::SetEOF(PR_FileDesc2NativeHandle(fd), newEOF) != 0) {
        NS_ERROR("SetEOF failed");
        return NS_ERROR_FAILURE;

#elif defined(XP_WIN)
    PRInt32 cnt = PR_Seek(fd, newEOF, PR_SEEK_SET);
    if (cnt == -1)  return NS_ERROR_FAILURE;
    if (!SetEndOfFile((HANDLE) PR_FileDesc2NativeHandle(fd))) {
        NS_ERROR("SetEndOfFile failed");
        return NS_ERROR_FAILURE;

#elif defined(XP_OS2)
    if (DosSetFileSize((HFILE) PR_FileDesc2NativeHandle(fd), newEOF) != NO_ERROR) {
        NS_ERROR("DosSetFileSize failed");
        return NS_ERROR_FAILURE;
    // add implementations for other platforms here
    return NS_OK;

Here is the call graph for this function:

Here is the caller graph for this function:

The documentation for this class was generated from the following files: