Back to index

lightning-sunbird  0.9+nobinonly
Public Member Functions | Static Public Member Functions | Public Attributes | Private Member Functions | Private Attributes
nsLocalFile Class Reference

#include <nsLocalFileWin.h>

Inheritance diagram for nsLocalFile:
Inheritance graph
[legend]
Collaboration diagram for nsLocalFile:
Collaboration graph
[legend]

List of all members.

Public Member Functions

 nsLocalFile ()
AString getVersionInfoField (in string aField)
 getVersionInfoValue
void initWithPath (in AString filePath)
 initWith[Native]Path
void initWithNativePath (in ACString filePath)
void initWithFile (in nsILocalFile aFile)
 initWithFile
PRFileDescStar openNSPRFileDesc (in long flags, in long mode)
FILE openANSIFileDesc (in string mode)
PRLibraryStar load ()
void appendRelativePath (in AString relativeFilePath)
 appendRelative[Native]Path
void appendRelativeNativePath (in ACString relativeFilePath)
void reveal ()
 reveal
void launch ()
 launch
ACString getRelativeDescriptor (in nsILocalFile fromFile)
 getRelativeDescriptor
void setRelativeDescriptor (in nsILocalFile fromFile, in ACString relativeDesc)
 setRelativeDescriptor
void append (in AString node)
 append[Native]
void appendNative (in ACString node)
void normalize ()
 Normalize the pathName (e.g.
void create (in unsigned long type, in unsigned long permissions)
 create
void copyTo (in nsIFile newParentDir, in AString newName)
 copyTo[Native]
void CopyToNative (in nsIFile newParentDir, in ACString newName)
void copyToFollowingLinks (in nsIFile newParentDir, in AString newName)
 copyToFollowingLinks[Native]
void copyToFollowingLinksNative (in nsIFile newParentDir, in ACString newName)
void moveTo (in nsIFile newParentDir, in AString newName)
 moveTo[Native]
void moveToNative (in nsIFile newParentDir, in ACString newName)
void remove (in boolean recursive)
 This will try to delete this file.
boolean exists ()
boolean isWritable ()
boolean isReadable ()
boolean isExecutable ()
boolean isHidden ()
boolean isDirectory ()
boolean isFile ()
boolean isSymlink ()
boolean isSpecial ()
 Not a regular file, not a directory, not a symlink.
void createUnique (in unsigned long type, in unsigned long permissions)
 createUnique
nsIFile clone ()
 clone()
boolean equals (in nsIFile inFile)
 Will determine if the inFile equals this.
boolean contains (in nsIFile inFile, in boolean recur)
 Will determine if inFile is a descendant of this file If |recur| is true, look in subdirectories too.

Static Public Member Functions

static NS_METHOD nsLocalFileConstructor (nsISupports *outer, const nsIID &aIID, void **aInstancePtr)
static void GlobalInit ()
static void GlobalShutdown ()

Public Attributes

attribute PRBool followLinks
 followLinks
readonly attribute PRInt64 diskSpaceAvailable
attribute ACString persistentDescriptor
 Accessor to a null terminated string which will specify the file in a persistent manner for disk storage.
const unsigned long NORMAL_FILE_TYPE = 0
 Create Types.
const unsigned long DIRECTORY_TYPE = 1
attribute AString leafName
 Accessor to the leaf name of the file itself.
attribute ACString nativeLeafName
attribute unsigned long permissions
 Attributes of nsIFile.
attribute unsigned long permissionsOfLink
attribute PRInt64 lastModifiedTime
 File Times are to be in milliseconds from midnight (00:00:00), January 1, 1970 Greenwich Mean Time (GMT).
attribute PRInt64 lastModifiedTimeOfLink
attribute PRInt64 fileSize
 WARNING! On the Mac, getting/setting the file size with nsIFile only deals with the size of the data fork.
readonly attribute PRInt64 fileSizeOfLink
readonly attribute AString target
 target & path
readonly attribute ACString nativeTarget
readonly attribute AString path
readonly attribute ACString nativePath
readonly attribute nsIFile parent
 Parent will be null when this is at the top of the volume.
readonly attribute
nsISimpleEnumerator 
directoryEntries
 Returns an enumeration of the elements in a directory.

Private Member Functions

 nsLocalFile (const nsLocalFile &other)
 ~nsLocalFile ()
void MakeDirty ()
nsresult ResolveAndStat ()
nsresult ResolveShortcut ()
nsresult CopyMove (nsIFile *newParentDir, const nsAString &newName, PRBool followSymlinks, PRBool move)
nsresult CopySingleFile (nsIFile *source, nsIFile *dest, const nsAString &newName, PRBool followSymlinks, PRBool move)
nsresult SetModDate (PRInt64 aLastModifiedTime, const PRUnichar *filePath)
nsresult HasFileAttribute (DWORD fileAttrib, PRBool *_retval)
nsresult AppendInternal (const nsAFlatString &node, PRBool multipleComponents)

Private Attributes

PRPackedBool mDirty
PRPackedBool mFollowSymlinks
nsString mWorkingPath
nsString mResolvedPath
PRFileInfo64 mFileInfo64

Detailed Description

Definition at line 64 of file nsLocalFileWin.h.


Constructor & Destructor Documentation

Definition at line 927 of file nsLocalFileMac.cpp.

                         :
    mFollowLinks(PR_TRUE),
    mFollowLinksDirty(PR_TRUE),
    mSpecDirty(PR_TRUE),
    mCatInfoDirty(PR_TRUE),
    mType('TEXT'),
    mCreator(kDefaultCreator)
{
    ClearFSSpec(mSpec);
    ClearFSSpec(mTargetSpec);
    
    InitClassStatics();
    if (sCurrentProcessSignature != 0)
        mCreator = sCurrentProcessSignature;
}

Here is the caller graph for this function:

nsLocalFile::nsLocalFile ( const nsLocalFile other) [private]

Definition at line 943 of file nsLocalFileMac.cpp.

{
    *this = srcFile;
}
nsLocalFile::~nsLocalFile ( ) [inline, private]

Definition at line 91 of file nsLocalFileWin.h.

{}

Member Function Documentation

void nsIFile::append ( in AString  node) [inherited]

append[Native]

This function is used for constructing a descendent of the current nsIFile.

Parameters:
nodeA string which is intended to be a child node of the nsIFile. For the |appendNative| method, the node must be in the native filesystem charset.
nsresult nsLocalFile::AppendInternal ( const nsAFlatString node,
PRBool  multipleComponents 
) [private]

Definition at line 1119 of file nsLocalFileWin.cpp.

{
    if (node.IsEmpty())
        return NS_OK;

    // check the relative path for validity
    if (node.First() == L'\\'                                   // can't start with an '\'
        || node.FindChar(L'/') != kNotFound                     // can't contain /
        || node.EqualsASCII(".."))                              // can't be ..
        return NS_ERROR_FILE_UNRECOGNIZED_PATH;

#ifndef WINCE  // who cares?
    if (multipleComponents)
    {
        // can't contain .. as a path component. Ensure that the valid components
        // "foo..foo", "..foo", and "foo.." are not falsely detected,
        // but the invalid paths "..\", "foo\..", "foo\..\foo", 
        // "..\foo", etc are.
        NS_NAMED_LITERAL_STRING(doubleDot, "\\.."); 
        nsAString::const_iterator start, end, offset;
        node.BeginReading(start);
        node.EndReading(end);
        offset = end; 
        while (FindInReadable(doubleDot, start, offset))
        {
            if (offset == end || *offset == L'\\')
                return NS_ERROR_FILE_UNRECOGNIZED_PATH;
            start = offset;
            offset = end;
        }
        
        // catches the remaining cases of prefixes 
        if (StringBeginsWith(node, NS_LITERAL_STRING("..\\")))
            return NS_ERROR_FILE_UNRECOGNIZED_PATH;
    }
    // single components can't contain '\'
    else if (node.FindChar(L'\\') != kNotFound)
        return NS_ERROR_FILE_UNRECOGNIZED_PATH;
#endif

    MakeDirty();
    
    mWorkingPath.Append(NS_LITERAL_STRING("\\") + node);
    
    return NS_OK;
}

Here is the call graph for this function:

void nsIFile::appendNative ( in ACString  node) [inherited]
void nsILocalFile::appendRelativeNativePath ( in ACString  relativeFilePath) [inherited]
void nsILocalFile::appendRelativePath ( in AString  relativeFilePath) [inherited]

appendRelative[Native]Path

Append a relative path to the current path of the nsILocalFile object.

Parameters:
relativeFilePathrelativeFilePath is a native relative path. For security reasons, this cannot contain .. or cannot start with a directory separator. For the |appendRelativeNativePath| method, the relativeFilePath must be in the native filesystem charset.
nsIFile nsIFile::clone ( ) [inherited]

clone()

This function will allocate and initialize a nsIFile object to the exact location of the |this| nsIFile.

Parameters:
fileA nsIFile which this object will be initialize with.
boolean nsIFile::contains ( in nsIFile  inFile,
in boolean  recur 
) [inherited]

Will determine if inFile is a descendant of this file If |recur| is true, look in subdirectories too.

nsresult nsLocalFile::CopyMove ( nsIFile newParentDir,
const nsAString &  newName,
PRBool  followSymlinks,
PRBool  move 
) [private]

Definition at line 1456 of file nsLocalFileOS2.cpp.

{
    nsCOMPtr<nsIFile> newParentDir = aParentDir;

    nsresult rv  = Stat();
    if (NS_FAILED(rv))
        return rv;

    if (!newParentDir)
    {
        // no parent was specified.  We must rename.

        if (newName.IsEmpty())
            return NS_ERROR_INVALID_ARG;

        rv = GetParent(getter_AddRefs(newParentDir));
        if (NS_FAILED(rv))
            return rv;
    }

    if (!newParentDir)
        return NS_ERROR_FILE_DESTINATION_NOT_DIR;

    // make sure it exists and is a directory.  Create it if not there.
    PRBool exists;
    newParentDir->Exists(&exists);
    if (!exists)
    {
        rv = newParentDir->Create(DIRECTORY_TYPE, 0644);  // TODO, what permissions should we use
        if (NS_FAILED(rv))
            return rv;
    }
    else
    {
        PRBool isDir;
        newParentDir->IsDirectory(&isDir);
        if (isDir == PR_FALSE)
        {
            return NS_ERROR_FILE_DESTINATION_NOT_DIR;
        }
    }

    // Try different ways to move/copy files/directories
    PRBool done = PR_FALSE;
    PRBool isDir;
    IsDirectory(&isDir);

    // Try to move the file or directory, or try to copy a single file
    if (move || !isDir)
    {
        // when moving things, first try to just MoveFile it,
        // even if it is a directory
        rv = CopySingleFile(this, newParentDir, newName, move);
        done = NS_SUCCEEDED(rv);
        // If we are moving a directory and that fails, fallback on directory
        // enumeration.  See bug 231300 for details.
        if (!done && !(move && isDir))
            return rv;
    }

    // Not able to copy or move directly, so enumerate it
    if (!done)
    {
        // create a new target destination in the new parentDir;
        nsCOMPtr<nsIFile> target;
        rv = newParentDir->Clone(getter_AddRefs(target));

        if (NS_FAILED(rv))
            return rv;

        nsCAutoString allocatedNewName;
        if (newName.IsEmpty())
        {
            GetNativeLeafName(allocatedNewName);
        }
        else
        {
            allocatedNewName = newName;
        }

        rv = target->AppendNative(allocatedNewName);
        if (NS_FAILED(rv))
            return rv;

        allocatedNewName.Truncate();

        // check if the destination directory already exists
        target->Exists(&exists);
        if (!exists)
        {
            // if the destination directory cannot be created, return an error
            rv = target->Create(DIRECTORY_TYPE, 0644);  // TODO, what permissions should we use
            if (NS_FAILED(rv))
                return rv;
        }
        else
        {
            // check if the destination directory is writable and empty
            PRBool isWritable;

            target->IsWritable(&isWritable);
            if (!isWritable)
                return NS_ERROR_FILE_ACCESS_DENIED;

            nsCOMPtr<nsISimpleEnumerator> targetIterator;
            rv = target->GetDirectoryEntries(getter_AddRefs(targetIterator));

            PRBool more;
            targetIterator->HasMoreElements(&more);
            // return error if target directory is not empty
            if (more)
                return NS_ERROR_FILE_DIR_NOT_EMPTY;
        }

        nsDirEnumerator dirEnum;

        rv = dirEnum.Init(this);
        if (NS_FAILED(rv)) {
            NS_WARNING("dirEnum initalization failed");
            return rv;
        }

        PRBool more;
        while (NS_SUCCEEDED(dirEnum.HasMoreElements(&more)) && more)
        {
            nsCOMPtr<nsISupports> item;
            nsCOMPtr<nsIFile> file;
            dirEnum.GetNext(getter_AddRefs(item));
            file = do_QueryInterface(item);
            if (file)
            {
                if (move)
                {
                    rv = file->MoveToNative(target, EmptyCString());
                    NS_ENSURE_SUCCESS(rv,rv);
                }
                else
                {
                    rv = file->CopyToNative(target, EmptyCString());
                    NS_ENSURE_SUCCESS(rv,rv);
                }
            }
        }
        // we've finished moving all the children of this directory
        // in the new directory.  so now delete the directory
        // note, we don't need to do a recursive delete.
        // MoveTo() is recursive.  At this point,
        // we've already moved the children of the current folder
        // to the new location.  nothing should be left in the folder.
        if (move)
        {
          rv = Remove(PR_FALSE); // recursive
          NS_ENSURE_SUCCESS(rv,rv);
        }
    }


    // If we moved, we want to adjust this.
    if (move)
    {
        MakeDirty();

        nsCAutoString newParentPath;
        newParentDir->GetNativePath(newParentPath);

        if (newParentPath.IsEmpty())
            return NS_ERROR_FAILURE;

        if (newName.IsEmpty())
        {
            nsCAutoString aFileName;
            GetNativeLeafName(aFileName);

            InitWithNativePath(newParentPath);
            AppendNative(aFileName);
        }
        else
        {
            InitWithNativePath(newParentPath);
            AppendNative(newName);
        }
    }

    return NS_OK;
}

Here is the call graph for this function:

nsresult nsLocalFile::CopySingleFile ( nsIFile source,
nsIFile dest,
const nsAString &  newName,
PRBool  followSymlinks,
PRBool  move 
) [private]

Definition at line 1370 of file nsLocalFileOS2.cpp.

{
    nsresult rv;
    nsCAutoString filePath;

    nsCAutoString destPath;
    destParent->GetNativeTarget(destPath);

    destPath.Append("\\");

    if (newName.IsEmpty())
    {
        nsCAutoString aFileName;
        sourceFile->GetNativeLeafName(aFileName);
        destPath.Append(aFileName);
    }
    else
    {
        destPath.Append(newName);
    }

    rv = sourceFile->GetNativePath(filePath);

    if (NS_FAILED(rv))
        return rv;

    APIRET rc = NO_ERROR;

    if (move)
        rc = DosMove(filePath.get(), (PSZ)NS_CONST_CAST(char*, destPath.get()));

    if (!move || rc == ERROR_NOT_SAME_DEVICE || rc == ERROR_ACCESS_DENIED)
    {
        // will get an error if the destination and source files aren't on
        // the same drive.  "MoveFile()" on Windows will go ahead and move
        // the file without error, so we need to do the same   IBM-AKR

        do {
            rc = DosCopy(filePath.get(), (PSZ)NS_CONST_CAST(char*, destPath.get()), DCPY_EXISTING);
            if (rc == ERROR_TOO_MANY_OPEN_FILES) {
                ULONG CurMaxFH = 0;
                LONG ReqCount = 20;
                APIRET rc2;
                rc2 = DosSetRelMaxFH(&ReqCount, &CurMaxFH);
                if (rc2 != NO_ERROR)
                    break;
            }
        } while (rc == ERROR_TOO_MANY_OPEN_FILES);

        // WSOD2 HACK - NETWORK_ACCESS_DENIED
        if (rc == 65)
        {
            CHAR         achProgram[CCHMAXPATH];  // buffer for program name, parameters
            RESULTCODES  rescResults;             // buffer for results of dosexecpgm

            strcpy(achProgram, "CMD.EXE  /C ");
            strcat(achProgram, """COPY ");
            strcat(achProgram, filePath.get());
            strcat(achProgram, " ");
            strcat(achProgram, (PSZ)NS_CONST_CAST(char*, destPath.get()));
            strcat(achProgram, """");
            achProgram[strlen(achProgram) + 1] = '\0';
            achProgram[7] = '\0';
            DosExecPgm(NULL, 0,
                       EXEC_SYNC, achProgram, (PSZ)NULL,
                       &rescResults, achProgram);
            rc = 0; // Assume it worked

        } // rc == 65

        // moving the file is supposed to act like a rename, so delete the
        // original file if we got this far without error
        if(move && (rc == NO_ERROR))
            DosDelete( filePath.get());

    } // !move or ERROR

    if (rc)
        rv = ConvertOS2Error(rc);

    return rv;
}

Here is the call graph for this function:

Here is the caller graph for this function:

void nsIFile::copyTo ( in nsIFile  newParentDir,
in AString  newName 
) [inherited]

copyTo[Native]

This will copy this file to the specified newParentDir. If a newName is specified, the file will be renamed. If 'this' is not created we will return an error (NS_ERROR_FILE_TARGET_DOES_NOT_EXIST).

copyTo may fail if the file already exists in the destination directory.

copyTo will NOT resolve aliases/shortcuts during the copy.

Parameters:
newParentDirThis param is the destination directory. If the newParentDir is null, copyTo() will use the parent directory of this file. If the newParentDir is not empty and is not a directory, an error will be returned (NS_ERROR_FILE_DESTINATION_NOT_DIR). For the |CopyToNative| method, the newName must be in the native filesystem charset.
newNameThis param allows you to specify a new name for the file to be copied. This param may be empty, in which case the current leaf name will be used.
void nsIFile::copyToFollowingLinks ( in nsIFile  newParentDir,
in AString  newName 
) [inherited]

copyToFollowingLinks[Native]

This function is identical to copyTo with the exception that, as the name implies, it follows symbolic links. The XP_UNIX implementation always follow symbolic links when copying. For the |CopyToFollowingLinks| method, the newName must be in the native filesystem charset.

void nsIFile::copyToFollowingLinksNative ( in nsIFile  newParentDir,
in ACString  newName 
) [inherited]
void nsIFile::CopyToNative ( in nsIFile  newParentDir,
in ACString  newName 
) [inherited]

Here is the caller graph for this function:

void nsIFile::create ( in unsigned long  type,
in unsigned long  permissions 
) [inherited]

create

This function will create a new file or directory in the file system. Any nodes that have not been created or resolved, will be. If the file or directory already exists create() will return NS_ERROR_FILE_ALREADY_EXISTS.

Parameters:
typeThis specifies the type of file system object to be made. The only two types at this time are file and directory which are defined above. If the type is unrecongnized, we will return an error (NS_ERROR_FILE_UNKNOWN_TYPE).
permissionsThe unix style octal permissions. This may be ignored on systems that do not need to do permissions.
void nsIFile::createUnique ( in unsigned long  type,
in unsigned long  permissions 
) [inherited]

createUnique

This function will create a new file or directory in the file system. Any nodes that have not been created or resolved, will be. If this file already exists, we try variations on the leaf name "suggestedName" until we find one that did not already exist.

If the search for nonexistent files takes too long (thousands of the variants already exist), we give up and return NS_ERROR_FILE_TOO_BIG.

Parameters:
typeThis specifies the type of file system object to be made. The only two types at this time are file and directory which are defined above. If the type is unrecongnized, we will return an error (NS_ERROR_FILE_UNKNOWN_TYPE).
permissionsThe unix style octal permissions. This may be ignored on systems that do not need to do permissions.
boolean nsIFile::equals ( in nsIFile  inFile) [inherited]

Will determine if the inFile equals this.

boolean nsIFile::exists ( ) [inherited]

Here is the caller graph for this function:

ACString nsILocalFile::getRelativeDescriptor ( in nsILocalFile  fromFile) [inherited]

getRelativeDescriptor

Returns a relative file path in an opaque, XP format. It is therefore not a native path.

The character set of the string returned from this function is undefined. DO NOT TRY TO INTERPRET IT AS HUMAN READABLE TEXT!

Parameters:
fromFilethe file from which the descriptor is relative. There is no defined result if this param is null.
AString nsILocalFileWin::getVersionInfoField ( in string  aField) [inherited]

getVersionInfoValue

Retrieve a metadata field from the file's VERSIONINFO block. Throws NS_ERROR_FAILURE if no value is found, or the value is empty.

Parameters:
aFieldThe field to look up.

Definition at line 3547 of file nsLocalFileMac.cpp.

{
}

Here is the caller graph for this function:

Definition at line 3552 of file nsLocalFileMac.cpp.

{
}

Here is the caller graph for this function:

nsresult nsLocalFile::HasFileAttribute ( DWORD  fileAttrib,
PRBool _retval 
) [private]

Definition at line 2475 of file nsLocalFileWin.cpp.

{
    NS_ENSURE_ARG(_retval);

    nsresult rv = ResolveAndStat();
    if (NS_FAILED(rv))
        return rv;

    // get the file attributes for the correct item depending on following symlinks
    const PRUnichar *filePath = mFollowSymlinks ? 
                                mResolvedPath.get() : mWorkingPath.get();
    DWORD word = nsWinAPIs::mGetFileAttributes(filePath);

    *_retval = ((word & fileAttrib) != 0);
    return NS_OK;
}

Here is the call graph for this function:

initWithFile

Initialize this object with another file

Parameters:
aFilethe file this becomes equivalent to
void nsILocalFile::initWithNativePath ( in ACString  filePath) [inherited]
void nsILocalFile::initWithPath ( in AString  filePath) [inherited]

initWith[Native]Path

This function will initialize the nsILocalFile object. Any internal state information will be reset.

NOTE: This function has a known bug on the macintosh and other OSes which do not represent file locations as paths. If you do use this function, be very aware of this problem!

Parameters:
filePathA string which specifies a full file path to a location. Relative paths will be treated as an error (NS_ERROR_FILE_UNRECOGNIZED_PATH). For initWithNativePath, the filePath must be in the native filesystem charset.
boolean nsIFile::isDirectory ( ) [inherited]
boolean nsIFile::isExecutable ( ) [inherited]
boolean nsIFile::isFile ( ) [inherited]
boolean nsIFile::isHidden ( ) [inherited]
boolean nsIFile::isReadable ( ) [inherited]
boolean nsIFile::isSpecial ( ) [inherited]

Not a regular file, not a directory, not a symlink.

boolean nsIFile::isSymlink ( ) [inherited]
boolean nsIFile::isWritable ( ) [inherited]

Here is the caller graph for this function:

void nsILocalFile::launch ( ) [inherited]

launch

Ask the operating system to attempt to open the file. this really just simulates "double clicking" the file on your platform. This routine only works on platforms which support this functionality.

void nsLocalFile::MakeDirty ( ) [inline, private]

Definition at line 105 of file nsLocalFileWin.h.

{ mDirty = PR_TRUE; }

Here is the caller graph for this function:

void nsIFile::moveTo ( in nsIFile  newParentDir,
in AString  newName 
) [inherited]

moveTo[Native]

A method to move this file or directory to newParentDir. If a newName is specified, the file or directory will be renamed. If 'this' is not created we will return an error (NS_ERROR_FILE_TARGET_DOES_NOT_EXIST). If 'this' is a file, and the destination file already exists, moveTo will replace the old file.

moveTo will NOT resolve aliases/shortcuts during the copy. moveTo will do the right thing and allow copies across volumes. moveTo will return an error (NS_ERROR_FILE_DIR_NOT_EMPTY) if 'this' is a directory and the destination directory is not empty. moveTo will return an error (NS_ERROR_FILE_ACCESS_DENIED) if 'this' is a directory and the destination directory is not writable.

Parameters:
newParentDirThis param is the destination directory. If the newParentDir is empty, moveTo() will rename the file within its current directory. If the newParentDir is not empty and does not name a directory, an error will be returned (NS_ERROR_FILE_DESTINATION_NOT_DIR). For the |moveToNative| method, the newName must be in the native filesystem charset.
newNameThis param allows you to specify a new name for the file to be moved. This param may be empty, in which case the current leaf name will be used.
void nsIFile::moveToNative ( in nsIFile  newParentDir,
in ACString  newName 
) [inherited]
void nsIFile::normalize ( ) [inherited]

Normalize the pathName (e.g.

removing .. and . components on Unix).

NS_METHOD nsLocalFile::nsLocalFileConstructor ( nsISupports *  outer,
const nsIID aIID,
void **  aInstancePtr 
) [static]

Definition at line 588 of file nsLocalFileOS2.cpp.

{
    NS_ENSURE_ARG_POINTER(aInstancePtr);
    NS_ENSURE_NO_AGGREGATION(outer);

    nsLocalFile* inst = new nsLocalFile();
    if (inst == NULL)
        return NS_ERROR_OUT_OF_MEMORY;

    nsresult rv = inst->QueryInterface(aIID, aInstancePtr);
    if (NS_FAILED(rv))
    {
        delete inst;
        return rv;
    }
    return NS_OK;
}

Here is the call graph for this function:

PRFileDescStar nsILocalFile::openNSPRFileDesc ( in long  flags,
in long  mode 
) [inherited]
void nsIFile::remove ( in boolean  recursive) [inherited]

This will try to delete this file.

The 'recursive' flag must be PR_TRUE to delete directories which are not empty.

This will not resolve any symlinks.

Definition at line 1043 of file nsLocalFileMac.cpp.

{
    OSErr   err = noErr;
    FSSpec  resolvedSpec;
    
    // fnfErr means target spec is valid but doesn't exist.
    // If the end result is fnfErr, we're cleanly resolved.
    
    if (mSpecDirty)
    {
        if (mAppendedPath.Length())
        {
            err = ResolvePathAndSpec(mAppendedPath.get(), &mSpec, PR_FALSE, &resolvedSpec);
            if (err == noErr)
                mAppendedPath.Truncate(0);
        }
        else
            err = ::FSMakeFSSpec(mSpec.vRefNum, mSpec.parID, mSpec.name, &resolvedSpec);
           if (err == noErr)
           {
               mSpec = resolvedSpec;
               mSpecDirty = PR_FALSE;
           }
        mFollowLinksDirty = PR_TRUE;
    }
    if (mFollowLinksDirty && (err == noErr))
    {
        if (mFollowLinks)
        {
            // Resolve the alias to the original file.
            resolvedSpec = mSpec;
            Boolean resolvedWasFolder, resolvedWasAlias;
            err = ::ResolveAliasFile(&resolvedSpec, TRUE, &resolvedWasFolder, &resolvedWasAlias);
            if (err == noErr || err == fnfErr) {
                err = noErr;
                mTargetSpec = resolvedSpec;
                mFollowLinksDirty = PR_FALSE;
            }
        }
        else
        {
            mTargetSpec = mSpec;
            mFollowLinksDirty = PR_FALSE;
        }
        mCatInfoDirty = PR_TRUE;
    }       
    
    return (MacErrorMapper(err));
}

Here is the caller graph for this function:

Definition at line 825 of file nsLocalFileWin.cpp.

{
#ifndef WINCE
    // we can't do anything without the resolver
    if (!gResolver)
        return NS_ERROR_FAILURE;

    mResolvedPath.SetLength(MAX_PATH);
    if (mResolvedPath.Length() != MAX_PATH)
        return NS_ERROR_OUT_OF_MEMORY;

    PRUnichar *resolvedPath = mResolvedPath.BeginWriting();

    // resolve this shortcut
    nsresult rv = gResolver->Resolve(mWorkingPath.get(), resolvedPath);

    size_t len = NS_FAILED(rv) ? 0 : wcslen(resolvedPath);
    mResolvedPath.SetLength(len);

    return rv;
#else
    return NS_OK;
#endif
}

Here is the call graph for this function:

void nsILocalFile::reveal ( ) [inherited]

reveal

Ask the operating system to open the folder which contains this file or folder. This routine only works on platforms which support the ability to open a folder...

nsresult nsLocalFile::SetModDate ( PRInt64  aLastModifiedTime,
const PRUnichar filePath 
) [private]

Definition at line 1763 of file nsLocalFileOS2.cpp.

{
    nsresult rv = Stat();

    if (NS_FAILED(rv))
        return rv;

    PRExplodedTime pret;
    FILESTATUS3 pathInfo;

    // Level 1 info
    rv = DosQueryPathInfo(mWorkingPath.get(), FIL_STANDARD,
                          &pathInfo, sizeof(pathInfo));

    if (NS_FAILED(rv))
    {
       rv = ConvertOS2Error(rv);
       return rv;
    }

    // PR_ExplodeTime expects usecs...
    PR_ExplodeTime(aLastModifiedTime * PR_USEC_PER_MSEC, PR_LocalTimeParameters, &pret);

    // fdateLastWrite.year is based off of 1980
    if (pret.tm_year >= 1980)
        pathInfo.fdateLastWrite.year    = pret.tm_year-1980;
    else
        pathInfo.fdateLastWrite.year    = pret.tm_year;

    // Convert start offset -- OS/2: Jan=1; NSPR: Jan=0
    pathInfo.fdateLastWrite.month       = pret.tm_month + 1;
    pathInfo.fdateLastWrite.day         = pret.tm_mday;
    pathInfo.ftimeLastWrite.hours       = pret.tm_hour;
    pathInfo.ftimeLastWrite.minutes     = pret.tm_min;
    pathInfo.ftimeLastWrite.twosecs     = pret.tm_sec / 2;

    rv = DosSetPathInfo(mWorkingPath.get(), FIL_STANDARD,
                        &pathInfo, sizeof(pathInfo), 0UL);

    if (NS_FAILED(rv))
       return rv;

    MakeDirty();
    return rv;
}

Here is the call graph for this function:

void nsILocalFile::setRelativeDescriptor ( in nsILocalFile  fromFile,
in ACString  relativeDesc 
) [inherited]

setRelativeDescriptor

Initializes the file to the location relative to fromFile using a string returned by getRelativeDescriptor.

Parameters:
fromFilethe file to which the descriptor is relative
relativethe relative descriptor obtained from getRelativeDescriptor

Member Data Documentation

const unsigned long nsIFile::DIRECTORY_TYPE = 1 [inherited]

Definition at line 71 of file nsIFile.idl.

Returns an enumeration of the elements in a directory.

Each element in the enumeration is an nsIFile.

Returns:
NS_ERROR_FILE_NOT_DIRECTORY if the current nsIFile does not specify a directory.

Definition at line 336 of file nsIFile.idl.

Definition at line 109 of file nsILocalFile.idl.

WARNING! On the Mac, getting/setting the file size with nsIFile only deals with the size of the data fork.

If you need to know the size of the combined data and resource forks use the GetFileSizeWithResFork() method defined on nsILocalFileMac.

Definition at line 227 of file nsIFile.idl.

Definition at line 228 of file nsIFile.idl.

followLinks

This 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.

Definition at line 102 of file nsILocalFile.idl.

File Times are to be in milliseconds from midnight (00:00:00), January 1, 1970 Greenwich Mean Time (GMT).

Definition at line 218 of file nsIFile.idl.

Definition at line 219 of file nsIFile.idl.

attribute AString nsIFile::leafName [inherited]

Accessor to the leaf name of the file itself.

For the |nativeLeafName| method, the nativeLeafName must be in the native filesystem charset.

Definition at line 119 of file nsIFile.idl.

Definition at line 93 of file nsLocalFileWin.h.

Definition at line 103 of file nsLocalFileWin.h.

Definition at line 94 of file nsLocalFileWin.h.

Definition at line 101 of file nsLocalFileWin.h.

Definition at line 97 of file nsLocalFileWin.h.

attribute ACString nsIFile::nativeLeafName [inherited]

Definition at line 120 of file nsIFile.idl.

readonly attribute ACString nsIFile::nativePath [inherited]

Definition at line 258 of file nsIFile.idl.

readonly attribute ACString nsIFile::nativeTarget [inherited]

Definition at line 256 of file nsIFile.idl.

const unsigned long nsIFile::NORMAL_FILE_TYPE = 0 [inherited]

Create Types.

NORMAL_FILE_TYPE - A normal file. DIRECTORY_TYPE - A directory/folder.

Definition at line 70 of file nsIFile.idl.

readonly attribute nsIFile nsIFile::parent [inherited]

Parent will be null when this is at the top of the volume.

Definition at line 327 of file nsIFile.idl.

readonly attribute AString nsIFile::path [inherited]

Definition at line 257 of file nsIFile.idl.

attribute unsigned long nsIFile::permissions [inherited]

Attributes of nsIFile.

Definition at line 210 of file nsIFile.idl.

Definition at line 211 of file nsIFile.idl.

Accessor to a null terminated string which will specify the file in a persistent manner for disk storage.

The character set of this attribute is undefined. DO NOT TRY TO INTERPRET IT AS HUMAN READABLE TEXT!

Definition at line 132 of file nsILocalFile.idl.

readonly attribute AString nsIFile::target [inherited]

target & path

Accessor to the string path. The native version of these strings are not guaranteed to be a usable path to pass to NSPR or the C stdlib. There are problems that affect platforms on which a path does not fully specify a file because two volumes can have the same name (e.g., XP_MAC). This is solved by holding "private", native data in the nsIFile implementation. This native data is lost when you convert to a string.

DO NOT PASS TO USE WITH NSPR OR STDLIB!

target Find out what the symlink points at. Will give error (NS_ERROR_FILE_INVALID_PATH) if not a symlink.

path Find out what the nsIFile points at.

Note that the ACString attributes are returned in the native filesystem charset.

Definition at line 255 of file nsIFile.idl.


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