Back to index

lightning-sunbird  0.9+nobinonly
Classes | Defines | Typedefs | Functions
nsLocalFileOS2.cpp File Reference
#include "nsCOMPtr.h"
#include "nsMemory.h"
#include "nsLocalFile.h"
#include "nsNativeCharsetUtils.h"
#include "nsISimpleEnumerator.h"
#include "nsIDirectoryEnumerator.h"
#include "nsIComponentManager.h"
#include "prtypes.h"
#include "prio.h"
#include "nsReadableUtils.h"
#include "nsISupportsPrimitives.h"
#include "nsArray.h"

Go to the source code of this file.

Classes

class  nsDirEnumerator
class  nsDriveEnumerator
struct  _MVHDR
class  TypeEaEnumerator
struct  _TYPEEA
struct  _TYPEEA2
struct  _SUBJEA
struct  _TYPEEA.hdr
struct  _TYPEEA.info
struct  _SUBJEA.hdr
struct  _SUBJEA.info

Defines

#define EABUFSIZE   512
#define OPEN_DEFAULT   0
#define OPEN_CONTENTS   1

Typedefs

typedef struct _MVHDR MVHDR
typedef MVHDRPMVHDR
typedef struct _TYPEEA TYPEEA
typedef struct _TYPEEA2 TYPEEA2
typedef struct _SUBJEA SUBJEA

Functions

static nsresult ConvertOS2Error (int err)
static void myLL_L2II (PRInt64 result, PRInt32 *hi, PRInt32 *lo)
static unsigned char *PR_CALLBACK _mbschr (const unsigned char *stringToSearch, int charToSearchFor)
static unsigned char *PR_CALLBACK _mbsstr (const unsigned char *stringToSearch, const unsigned char *subString)
unsigned char * _mbsrchr (const unsigned char *stringToSearch, int charToSearchFor)
static nsresult PR_CALLBACK CreateDirectoryA (PSZ path, PEAOP2 ppEABuf)
static int isleadbyte (int c)
nsresult NS_NewNativeLocalFile (const nsACString &path, PRBool followLinks, nsILocalFile **result)
nsresult NS_NewLocalFile (const nsAString &path, PRBool followLinks, nsILocalFile **result)
 Public Method to create an instance of a nsILocalFile.

Class Documentation

struct _MVHDR

Definition at line 485 of file nsLocalFileOS2.cpp.

Class Members
char data
USHORT usCodePage
USHORT usDataLth
USHORT usDataType
USHORT usEAType
USHORT usNumEntries
struct _TYPEEA

Definition at line 1212 of file nsLocalFileOS2.cpp.

Class Members
char data
struct _TYPEEA hdr
struct _TYPEEA info
struct _TYPEEA2

Definition at line 1231 of file nsLocalFileOS2.cpp.

Class Members
USHORT usDataLth
USHORT usDataType
struct _SUBJEA

Definition at line 1308 of file nsLocalFileOS2.cpp.

Class Members
char data
struct _SUBJEA hdr
struct _SUBJEA info
struct _TYPEEA.hdr

Definition at line 1213 of file nsLocalFileOS2.cpp.

Class Members
BYTE bcbName
BYTE bfEA
char chszName
ULONG ulcbList
ULONG uloNextEntryOffset
USHORT uscbValue
struct _TYPEEA.info

Definition at line 1221 of file nsLocalFileOS2.cpp.

Class Members
USHORT usCodePage
USHORT usDataLth
USHORT usDataType
USHORT usEAType
USHORT usNumEntries
struct _SUBJEA.hdr

Definition at line 1309 of file nsLocalFileOS2.cpp.

Class Members
BYTE bcbName
BYTE bfEA
char chszName
ULONG ulcbList
ULONG uloNextEntryOffset
USHORT uscbValue
struct _SUBJEA.info

Definition at line 1317 of file nsLocalFileOS2.cpp.

Class Members
USHORT usDataLth
USHORT usEAType

Define Documentation

#define EABUFSIZE   512

Definition at line 2316 of file nsLocalFileOS2.cpp.

Definition at line 2315 of file nsLocalFileOS2.cpp.


Typedef Documentation

typedef struct _MVHDR MVHDR
typedef MVHDR* PMVHDR

Definition at line 494 of file nsLocalFileOS2.cpp.

typedef struct _SUBJEA SUBJEA
typedef struct _TYPEEA TYPEEA
typedef struct _TYPEEA2 TYPEEA2

Function Documentation

static unsigned char* PR_CALLBACK _mbschr ( const unsigned char *  stringToSearch,
int  charToSearchFor 
) [static]

Definition at line 130 of file nsLocalFileOS2.cpp.

{
    const unsigned char* p = stringToSearch;

    do {
        if (*p == charToSearchFor)
            break;
        p  = (const unsigned char*)WinNextChar(0,0,0,(char*)p);
    } while (*p);

    // Result is p or NULL
    return *p ? (unsigned char*)p : NULL;
}
unsigned char* _mbsrchr ( const unsigned char *  stringToSearch,
int  charToSearchFor 
)

Definition at line 178 of file nsLocalFileOS2.cpp.

{
    int length = strlen((const char*)stringToSearch);
    const unsigned char* p = stringToSearch+length;

    do {
        if (*p == charToSearchFor)
            break;
        p  = (const unsigned char*)WinPrevChar(0,0,0,(char*)stringToSearch,(char*)p);
    } while (p > stringToSearch);

    // Result is p or NULL
    return (*p == charToSearchFor) ? (unsigned char*)p : NULL;
}

Here is the caller graph for this function:

static unsigned char* PR_CALLBACK _mbsstr ( const unsigned char *  stringToSearch,
const unsigned char *  subString 
) [static]

Definition at line 146 of file nsLocalFileOS2.cpp.

{
    const unsigned char* pStr = stringToSearch;
    const unsigned char* pSub = subString;

    do {
        while (*pStr && *pStr != *pSub)
            pStr = (const unsigned char*)WinNextChar(0,0,0,(char*)pStr);

        if (!*pStr)
            break;

        const unsigned char* pNxt = pStr;
        do {
            pSub = (const unsigned char*)WinNextChar(0,0,0,(char*)pSub);
            pNxt = (const unsigned char*)WinNextChar(0,0,0,(char*)pNxt);
        } while (*pSub && *pSub == *pNxt);

        if (!*pSub)
            break;

        pSub = subString;
        pStr = (const unsigned char*)WinNextChar(0,0,0,(char*)pStr);

    } while (*pStr);

    // if we got to the end of pSub, we've found it
    return *pSub ? NULL : (unsigned char*)pStr;
}
static nsresult ConvertOS2Error ( int  err) [static]

Definition at line 65 of file nsLocalFileOS2.cpp.

{
    nsresult rv;

    switch (err)
    {
        case ERROR_FILE_NOT_FOUND:
        case ERROR_PATH_NOT_FOUND:
        case ERROR_INVALID_DRIVE:
            rv = NS_ERROR_FILE_NOT_FOUND;
            break;
        case ERROR_ACCESS_DENIED:
        case ERROR_NOT_SAME_DEVICE:
            rv = NS_ERROR_FILE_ACCESS_DENIED;
            break;
        case ERROR_NOT_ENOUGH_MEMORY:
        case ERROR_INVALID_BLOCK:
        case ERROR_INVALID_HANDLE:
        case ERROR_ARENA_TRASHED:
            rv = NS_ERROR_OUT_OF_MEMORY;
            break;
        case ERROR_CURRENT_DIRECTORY:
            rv = NS_ERROR_FILE_DIR_NOT_EMPTY;
            break;
        case ERROR_WRITE_PROTECT:
            rv = NS_ERROR_FILE_READ_ONLY;
            break;
        case ERROR_HANDLE_DISK_FULL:
            rv = NS_ERROR_FILE_TOO_BIG;
            break;
        case ERROR_FILE_EXISTS:
        case ERROR_ALREADY_EXISTS:
        case ERROR_CANNOT_MAKE:
            rv = NS_ERROR_FILE_ALREADY_EXISTS;
            break;
        case ERROR_FILENAME_EXCED_RANGE:
            rv = NS_ERROR_FILE_NAME_TOO_LONG;
            break;
        case 0:
            rv = NS_OK;
        default:
            rv = NS_ERROR_FAILURE;
    }
    return rv;
}

Here is the caller graph for this function:

static nsresult PR_CALLBACK CreateDirectoryA ( PSZ  path,
PEAOP2  ppEABuf 
) [static]

Definition at line 195 of file nsLocalFileOS2.cpp.

{
    APIRET rc;
    nsresult rv;
    FILESTATUS3 pathInfo;

    rc = DosCreateDir(path, ppEABuf);
    if (rc != NO_ERROR)
    {
        rv = ConvertOS2Error(rc);

        // Check if directory already exists and if so,
        // reflect that in the return value
        rc = DosQueryPathInfo(path, FIL_STANDARD,
                              &pathInfo, sizeof(pathInfo));
        if (rc == NO_ERROR)
            rv = ERROR_FILE_EXISTS;
    }
    else
        rv = rc;

    return rv;
}

Here is the call graph for this function:

static int isleadbyte ( int  c) [static]

Definition at line 219 of file nsLocalFileOS2.cpp.

{
    static BOOL bDBCSFilled = FALSE;
    // According to the Control Program Guide&Ref, 12 bytes is sufficient
    static BYTE DBCSInfo[12] = { 0 };
    BYTE *curr;
    BOOL retval = FALSE;

    if(!bDBCSFilled)
    {
        COUNTRYCODE ctrycodeInfo = { 0 };
        APIRET rc = NO_ERROR;
        ctrycodeInfo.country = 0;     // Current Country
        ctrycodeInfo.codepage = 0;    // Current Codepage

        rc = DosQueryDBCSEnv(sizeof(DBCSInfo), &ctrycodeInfo, DBCSInfo);
        // we had an error, do something?
        if (rc != NO_ERROR)
            return FALSE;

        bDBCSFilled=TRUE;
    }

    // DBCSInfo returned by DosQueryDBCSEnv is terminated
    // with two '0' bytes in a row
    curr = DBCSInfo;
    while(*curr != 0 && *(curr+1) != 0)
    {
        if(c >= *curr && c <= *(curr+1))
        {
            retval=TRUE;
            break;
        }
        curr+=2;
    }

    return retval;
}
static void myLL_L2II ( PRInt64  result,
PRInt32 hi,
PRInt32 lo 
) [static]

Definition at line 112 of file nsLocalFileOS2.cpp.

{
    PRInt64 a64, b64;  // probably could have been done with
                       // only one PRInt64, but these are macros,
                       // and I am a wimp.

    // shift the hi word to the low word, then push it into a long.
    LL_SHR(a64, result, 32);
    LL_L2I(*hi, a64);

    // shift the low word to the hi word first, then shift it back.
    LL_SHL(b64, result, 32);
    LL_SHR(a64, b64, 32);
    LL_L2I(*lo, a64);
}
nsresult NS_NewLocalFile ( const nsAString &  path,
PRBool  followLinks,
nsILocalFile **  result 
)

Public Method to create an instance of a nsILocalFile.

This function may be called prior to NS_InitXPCOM.

FROZEN

Parameters:
pathA string which specifies a full file path to a location. Relative paths will be treated as an error (NS_ERROR_FILE_UNRECOGNIZED_PATH). |NS_NewNativeLocalFile|'s path must be in the filesystem charset.
followLinksThis attribute will determine if the nsLocalFile will auto resolve symbolic links. By default, this value will be false on all non unix systems. On unix, this attribute is effectively a noop.
resultInterface pointer to a new instance of an nsILocalFile
Returns:
NS_OK for success; other error codes indicate a failure.

Definition at line 2509 of file nsLocalFileOS2.cpp.

{
    nsCAutoString buf;
    nsresult rv = NS_CopyUnicodeToNative(path, buf);
    if (NS_FAILED(rv)) {
        *result = nsnull;
        return rv;
    }
    return NS_NewNativeLocalFile(buf, followLinks, result);
}

Here is the call graph for this function:

nsresult NS_NewNativeLocalFile ( const nsACString &  path,
PRBool  followLinks,
nsILocalFile **  result 
)

Definition at line 2359 of file nsLocalFileOS2.cpp.

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

    if (!path.IsEmpty()) {
        nsresult rv = file->InitWithNativePath(path);
        if (NS_FAILED(rv)) {
            NS_RELEASE(file);
            return rv;
        }
    }

    *result = file;
    return NS_OK;
}

Here is the call graph for this function: