Back to index

lightning-sunbird  0.9+nobinonly
Classes | Defines | Functions
nsLocalFileUnix.cpp File Reference
#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>
#include <fcntl.h>
#include <errno.h>
#include <utime.h>
#include <dirent.h>
#include <ctype.h>
#include <locale.h>
#include "nsDirectoryServiceDefs.h"
#include "nsCRT.h"
#include "nsCOMPtr.h"
#include "nsMemory.h"
#include "nsIFile.h"
#include "nsString.h"
#include "nsReadableUtils.h"
#include "nsLocalFile.h"
#include "nsIComponentManager.h"
#include "nsXPIDLString.h"
#include "prproces.h"
#include "nsIDirectoryEnumerator.h"
#include "nsISimpleEnumerator.h"
#include "nsITimelineService.h"
#include "nsNativeCharsetUtils.h"

Go to the source code of this file.

Classes

protocol  NS_COM
 A string set that takes up minimal size when there are 0 or 1 strings in the set. More...

Defines

#define FILE_STRCMP   strcmp
 Implementation of nsIFile for ``Unixy'' systems.
#define FILE_STRNCMP   strncmp
#define VALIDATE_STAT_CACHE()
#define CHECK_mPath()
#define NORMALIZE_PERMS(mode)   ((mode)& (S_IRWXU | S_IRWXG | S_IRWXO))
#define SET_UCS(func, ucsArg)
#define GET_UCS(func, ucsArg)
#define SET_UCS_2ARGS_2(func, opaqueArg, ucsArg)

Functions

 NS_IMPL_THREADSAFE_ISUPPORTS2 (nsLocalFile, nsIFile, nsILocalFile) nsresult nsLocalFile
static int do_create (const char *path, PRIntn flags, mode_t mode, PRFileDesc **_retval)
static int do_mkdir (const char *path, PRIntn flags, mode_t mode, PRFileDesc **_retval)
nsresult NS_NewNativeLocalFile (const nsACString &path, PRBool followSymlinks, nsILocalFile **result)
nsresult NS_NewLocalFile (const nsAString &path, PRBool followLinks, nsILocalFile **result)
 Public Method to create an instance of a nsILocalFile.

Define Documentation

Value:
PR_BEGIN_MACRO                              \
        if (mPath.IsEmpty())                    \
            return NS_ERROR_NOT_INITIALIZED;    \
    PR_END_MACRO

Definition at line 106 of file nsLocalFileUnix.cpp.

#define FILE_STRCMP   strcmp

Implementation of nsIFile for ``Unixy'' systems.

Definition at line 93 of file nsLocalFileUnix.cpp.

#define FILE_STRNCMP   strncmp

Definition at line 94 of file nsLocalFileUnix.cpp.

#define GET_UCS (   func,
  ucsArg 
)
Value:
{ \
        nsCAutoString buf; \
        nsresult rv = (func)(buf); \
        if (NS_FAILED(rv)) return rv; \
        return NS_CopyNativeToUnicode(buf, ucsArg); \
    }

Definition at line 1687 of file nsLocalFileUnix.cpp.

Definition at line 1045 of file nsLocalFileUnix.cpp.

#define SET_UCS (   func,
  ucsArg 
)
Value:
{ \
        nsCAutoString buf; \
        nsresult rv = NS_CopyUnicodeToNative(ucsArg, buf); \
        if (NS_FAILED(rv)) \
            return rv; \
        return (func)(buf); \
    }

Definition at line 1678 of file nsLocalFileUnix.cpp.

#define SET_UCS_2ARGS_2 (   func,
  opaqueArg,
  ucsArg 
)
Value:
{ \
        nsCAutoString buf; \
        nsresult rv = NS_CopyUnicodeToNative(ucsArg, buf); \
        if (NS_FAILED(rv)) \
            return rv; \
        return (func)(opaqueArg, buf); \
    }

Definition at line 1695 of file nsLocalFileUnix.cpp.

Value:
PR_BEGIN_MACRO                              \
        if (!mHaveCachedStat) {                 \
            FillStatCache();                    \
            if (!mHaveCachedStat)               \
                 return NSRESULT_FOR_ERRNO();   \
        }                                       \
    PR_END_MACRO

Definition at line 97 of file nsLocalFileUnix.cpp.


Function Documentation

static int do_create ( const char *  path,
PRIntn  flags,
mode_t  mode,
PRFileDesc **  _retval 
) [static]

Definition at line 417 of file nsLocalFileUnix.cpp.

{
    *_retval = PR_Open(path, flags, mode);
    return *_retval ? 0 : -1;
}
static int do_mkdir ( const char *  path,
PRIntn  flags,
mode_t  mode,
PRFileDesc **  _retval 
) [static]

Definition at line 424 of file nsLocalFileUnix.cpp.

{
    *_retval = nsnull;
    return mkdir(path, mode);
}

Definition at line 255 of file nsLocalFileUnix.cpp.

{
    NS_ENSURE_ARG_POINTER(aInstancePtr);
    NS_ENSURE_NO_AGGREGATION(outer);

    *aInstancePtr = nsnull;

    nsCOMPtr<nsIFile> inst = new nsLocalFile();
    if (!inst)
        return NS_ERROR_OUT_OF_MEMORY;
    return inst->QueryInterface(aIID, aInstancePtr);
}
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 1756 of file nsLocalFileUnix.cpp.

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

Here is the call graph for this function:

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

Definition at line 1656 of file nsLocalFileUnix.cpp.

{
    nsLocalFile *file = new nsLocalFile();
    if (!file)
        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: