Bug 361351: nsIFile.exists() should throw NOT_INITIALIZED if nsIFile is not initialized, patch by Ryan Jones <sciguyryan+bugzilla@gmail.com>, r+sr=darin
This commit is contained in:
@@ -59,6 +59,12 @@
|
||||
#include "nsIMutableArray.h"
|
||||
#include "nsTraceRefcntImpl.h"
|
||||
|
||||
#define CHECK_mWorkingPath() \
|
||||
PR_BEGIN_MACRO \
|
||||
if (mWorkingPath.IsEmpty()) \
|
||||
return NS_ERROR_NOT_INITIALIZED; \
|
||||
PR_END_MACRO
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// static helper functions
|
||||
//-----------------------------------------------------------------------------
|
||||
@@ -1453,6 +1459,9 @@ nsLocalFile::CopySingleFile(nsIFile *sourceFile, nsIFile *destParent,
|
||||
nsresult
|
||||
nsLocalFile::CopyMove(nsIFile *aParentDir, const nsACString &newName, PRBool move)
|
||||
{
|
||||
// Check we are correctly initialized.
|
||||
CHECK_mWorkingPath();
|
||||
|
||||
nsCOMPtr<nsIFile> newParentDir = aParentDir;
|
||||
|
||||
nsresult rv = Stat();
|
||||
@@ -1658,6 +1667,9 @@ nsLocalFile::MoveToNative(nsIFile *newParentDir, const nsACString &newName)
|
||||
NS_IMETHODIMP
|
||||
nsLocalFile::Load(PRLibrary * *_retval)
|
||||
{
|
||||
// Check we are correctly initialized.
|
||||
CHECK_mWorkingPath();
|
||||
|
||||
PRBool isFile;
|
||||
nsresult rv = IsFile(&isFile);
|
||||
|
||||
@@ -1686,6 +1698,9 @@ nsLocalFile::Load(PRLibrary * *_retval)
|
||||
NS_IMETHODIMP
|
||||
nsLocalFile::Remove(PRBool recursive)
|
||||
{
|
||||
// Check we are correctly initialized.
|
||||
CHECK_mWorkingPath();
|
||||
|
||||
PRBool isDir = PR_FALSE;
|
||||
|
||||
nsresult rv = IsDirectory(&isDir);
|
||||
@@ -1730,6 +1745,9 @@ nsLocalFile::Remove(PRBool recursive)
|
||||
NS_IMETHODIMP
|
||||
nsLocalFile::GetLastModifiedTime(PRInt64 *aLastModifiedTime)
|
||||
{
|
||||
// Check we are correctly initialized.
|
||||
CHECK_mWorkingPath();
|
||||
|
||||
NS_ENSURE_ARG(aLastModifiedTime);
|
||||
|
||||
*aLastModifiedTime = 0;
|
||||
@@ -1755,6 +1773,9 @@ nsLocalFile::GetLastModifiedTimeOfLink(PRInt64 *aLastModifiedTime)
|
||||
NS_IMETHODIMP
|
||||
nsLocalFile::SetLastModifiedTime(PRInt64 aLastModifiedTime)
|
||||
{
|
||||
// Check we are correctly initialized.
|
||||
CHECK_mWorkingPath();
|
||||
|
||||
return nsLocalFile::SetModDate(aLastModifiedTime);
|
||||
}
|
||||
|
||||
@@ -1847,6 +1868,9 @@ nsLocalFile::GetPermissionsOfLink(PRUint32 *aPermissionsOfLink)
|
||||
NS_IMETHODIMP
|
||||
nsLocalFile::SetPermissions(PRUint32 aPermissions)
|
||||
{
|
||||
// Check we are correctly initialized.
|
||||
CHECK_mWorkingPath();
|
||||
|
||||
nsresult rv = Stat();
|
||||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
@@ -1889,6 +1913,9 @@ nsLocalFile::SetPermissionsOfLink(PRUint32 aPermissions)
|
||||
NS_IMETHODIMP
|
||||
nsLocalFile::GetFileSize(PRInt64 *aFileSize)
|
||||
{
|
||||
// Check we are correctly initialized.
|
||||
CHECK_mWorkingPath();
|
||||
|
||||
NS_ENSURE_ARG(aFileSize);
|
||||
*aFileSize = 0;
|
||||
|
||||
@@ -1951,6 +1978,9 @@ nsLocalFile::SetFileSize(PRInt64 aFileSize)
|
||||
NS_IMETHODIMP
|
||||
nsLocalFile::GetDiskSpaceAvailable(PRInt64 *aDiskSpaceAvailable)
|
||||
{
|
||||
// Check we are correctly initialized.
|
||||
CHECK_mWorkingPath();
|
||||
|
||||
NS_ENSURE_ARG(aDiskSpaceAvailable);
|
||||
*aDiskSpaceAvailable = 0;
|
||||
|
||||
@@ -1978,6 +2008,9 @@ nsLocalFile::GetDiskSpaceAvailable(PRInt64 *aDiskSpaceAvailable)
|
||||
NS_IMETHODIMP
|
||||
nsLocalFile::GetParent(nsIFile * *aParent)
|
||||
{
|
||||
// Check we are correctly initialized.
|
||||
CHECK_mWorkingPath();
|
||||
|
||||
NS_ENSURE_ARG_POINTER(aParent);
|
||||
|
||||
nsCAutoString parentPath(mWorkingPath);
|
||||
@@ -2014,6 +2047,9 @@ nsLocalFile::GetParent(nsIFile * *aParent)
|
||||
NS_IMETHODIMP
|
||||
nsLocalFile::Exists(PRBool *_retval)
|
||||
{
|
||||
// Check we are correctly initialized.
|
||||
CHECK_mWorkingPath();
|
||||
|
||||
NS_ENSURE_ARG(_retval);
|
||||
*_retval = PR_FALSE;
|
||||
|
||||
@@ -2027,6 +2063,9 @@ nsLocalFile::Exists(PRBool *_retval)
|
||||
NS_IMETHODIMP
|
||||
nsLocalFile::IsWritable(PRBool *_retval)
|
||||
{
|
||||
// Check we are correctly initialized.
|
||||
CHECK_mWorkingPath();
|
||||
|
||||
NS_ENSURE_ARG(_retval);
|
||||
*_retval = PR_FALSE;
|
||||
|
||||
@@ -2056,6 +2095,9 @@ nsLocalFile::IsWritable(PRBool *_retval)
|
||||
NS_IMETHODIMP
|
||||
nsLocalFile::IsReadable(PRBool *_retval)
|
||||
{
|
||||
// Check we are correctly initialized.
|
||||
CHECK_mWorkingPath();
|
||||
|
||||
NS_ENSURE_ARG(_retval);
|
||||
*_retval = PR_FALSE;
|
||||
|
||||
@@ -2071,6 +2113,9 @@ nsLocalFile::IsReadable(PRBool *_retval)
|
||||
NS_IMETHODIMP
|
||||
nsLocalFile::IsExecutable(PRBool *_retval)
|
||||
{
|
||||
// Check we are correctly initialized.
|
||||
CHECK_mWorkingPath();
|
||||
|
||||
NS_ENSURE_ARG(_retval);
|
||||
*_retval = PR_FALSE;
|
||||
|
||||
@@ -2190,6 +2235,9 @@ nsLocalFile::IsHidden(PRBool *_retval)
|
||||
NS_IMETHODIMP
|
||||
nsLocalFile::IsSymlink(PRBool *_retval)
|
||||
{
|
||||
// Check we are correctly initialized.
|
||||
CHECK_mWorkingPath();
|
||||
|
||||
NS_ENSURE_ARG_POINTER(_retval);
|
||||
|
||||
// No Symlinks on OS/2
|
||||
@@ -2223,6 +2271,9 @@ nsLocalFile::Equals(nsIFile *inFile, PRBool *_retval)
|
||||
NS_IMETHODIMP
|
||||
nsLocalFile::Contains(nsIFile *inFile, PRBool recur, PRBool *_retval)
|
||||
{
|
||||
// Check we are correctly initialized.
|
||||
CHECK_mWorkingPath();
|
||||
|
||||
*_retval = PR_FALSE;
|
||||
|
||||
nsCAutoString myFilePath;
|
||||
@@ -2253,6 +2304,9 @@ nsLocalFile::Contains(nsIFile *inFile, PRBool recur, PRBool *_retval)
|
||||
NS_IMETHODIMP
|
||||
nsLocalFile::GetNativeTarget(nsACString &_retval)
|
||||
{
|
||||
// Check we are correctly initialized.
|
||||
CHECK_mWorkingPath();
|
||||
|
||||
_retval = mWorkingPath;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
@@ -72,6 +72,12 @@
|
||||
#define GetAliasSizeFromRecord(aliasRecord) GetAliasSizeFromPtr(&aliasRecord)
|
||||
#endif
|
||||
|
||||
#define CHECK_mBaseRef() \
|
||||
PR_BEGIN_MACRO \
|
||||
if (mBaseRef.IsEmpty()) \
|
||||
return NS_ERROR_NOT_INITIALIZED; \
|
||||
PR_END_MACRO
|
||||
|
||||
//*****************************************************************************
|
||||
// Static Function Prototypes
|
||||
//*****************************************************************************
|
||||
@@ -378,8 +384,8 @@ NS_IMETHODIMP nsLocalFile::Append(const nsAString& aNode)
|
||||
/* [noscript] void appendNative (in ACString node); */
|
||||
NS_IMETHODIMP nsLocalFile::AppendNative(const nsACString& aNode)
|
||||
{
|
||||
if (!mBaseRef)
|
||||
return NS_ERROR_NOT_INITIALIZED;
|
||||
// Check we are correctly initialized.
|
||||
CHECK_mBaseRef();
|
||||
|
||||
nsACString::const_iterator start, end;
|
||||
aNode.BeginReading(start);
|
||||
@@ -414,8 +420,9 @@ NS_IMETHODIMP nsLocalFile::Create(PRUint32 type, PRUint32 permissions)
|
||||
{
|
||||
if (type != NORMAL_FILE_TYPE && type != DIRECTORY_TYPE)
|
||||
return NS_ERROR_FILE_UNKNOWN_TYPE;
|
||||
if (!mBaseRef)
|
||||
return NS_ERROR_NOT_INITIALIZED;
|
||||
|
||||
// Check we are correctly initialized.
|
||||
CHECK_mBaseRef();
|
||||
|
||||
nsStringArray nonExtantNodes;
|
||||
CFURLRef pathURLRef = mBaseRef;
|
||||
@@ -508,8 +515,9 @@ NS_IMETHODIMP nsLocalFile::SetLeafName(const nsAString& aLeafName)
|
||||
/* [noscript] attribute ACString nativeLeafName; */
|
||||
NS_IMETHODIMP nsLocalFile::GetNativeLeafName(nsACString& aNativeLeafName)
|
||||
{
|
||||
if (!mBaseRef)
|
||||
return NS_ERROR_NOT_INITIALIZED;
|
||||
// Check we are correctly initialized.
|
||||
CHECK_mBaseRef();
|
||||
|
||||
nsresult rv = NS_ERROR_FAILURE;
|
||||
CFStringRef leafStrRef = ::CFURLCopyLastPathComponent(mBaseRef);
|
||||
if (leafStrRef) {
|
||||
@@ -521,8 +529,9 @@ NS_IMETHODIMP nsLocalFile::GetNativeLeafName(nsACString& aNativeLeafName)
|
||||
|
||||
NS_IMETHODIMP nsLocalFile::SetNativeLeafName(const nsACString& aNativeLeafName)
|
||||
{
|
||||
if (!mBaseRef)
|
||||
return NS_ERROR_NOT_INITIALIZED;
|
||||
// Check we are correctly initialized.
|
||||
CHECK_mBaseRef();
|
||||
|
||||
nsresult rv = NS_ERROR_FAILURE;
|
||||
CFURLRef parentURLRef = ::CFURLCreateCopyDeletingLastPathComponent(kCFAllocatorDefault, mBaseRef);
|
||||
if (parentURLRef) {
|
||||
@@ -578,6 +587,9 @@ NS_IMETHODIMP nsLocalFile::MoveTo(nsIFile *newParentDir, const nsAString& newNam
|
||||
/* [noscript] void moveToNative (in nsIFile newParentDir, in ACString newName); */
|
||||
NS_IMETHODIMP nsLocalFile::MoveToNative(nsIFile *newParentDir, const nsACString& newName)
|
||||
{
|
||||
// Check we are correctly initialized.
|
||||
CHECK_mBaseRef();
|
||||
|
||||
StFollowLinksState followLinks(*this, PR_FALSE);
|
||||
|
||||
PRBool isDirectory;
|
||||
@@ -659,6 +671,9 @@ NS_IMETHODIMP nsLocalFile::MoveToNative(nsIFile *newParentDir, const nsACString&
|
||||
/* void remove (in boolean recursive); */
|
||||
NS_IMETHODIMP nsLocalFile::Remove(PRBool recursive)
|
||||
{
|
||||
// Check we are correctly initialized.
|
||||
CHECK_mBaseRef();
|
||||
|
||||
// XXX If we're an alias, never remove target
|
||||
StFollowLinksState followLinks(*this, PR_FALSE);
|
||||
|
||||
@@ -752,6 +767,9 @@ NS_IMETHODIMP nsLocalFile::SetPermissionsOfLink(PRUint32 aPermissionsOfLink)
|
||||
/* attribute PRInt64 lastModifiedTime; */
|
||||
NS_IMETHODIMP nsLocalFile::GetLastModifiedTime(PRInt64 *aLastModifiedTime)
|
||||
{
|
||||
// Check we are correctly initialized.
|
||||
CHECK_mBaseRef();
|
||||
|
||||
NS_ENSURE_ARG_POINTER(aLastModifiedTime);
|
||||
|
||||
FSRef fsRef;
|
||||
@@ -770,6 +788,9 @@ NS_IMETHODIMP nsLocalFile::GetLastModifiedTime(PRInt64 *aLastModifiedTime)
|
||||
|
||||
NS_IMETHODIMP nsLocalFile::SetLastModifiedTime(PRInt64 aLastModifiedTime)
|
||||
{
|
||||
// Check we are correctly initialized.
|
||||
CHECK_mBaseRef();
|
||||
|
||||
OSErr err;
|
||||
nsresult rv;
|
||||
FSRef fsRef;
|
||||
@@ -842,6 +863,9 @@ NS_IMETHODIMP nsLocalFile::GetFileSize(PRInt64 *aFileSize)
|
||||
|
||||
NS_IMETHODIMP nsLocalFile::SetFileSize(PRInt64 aFileSize)
|
||||
{
|
||||
// Check we are correctly initialized.
|
||||
CHECK_mBaseRef();
|
||||
|
||||
FSRef fsRef;
|
||||
nsresult rv = GetFSRefInternal(fsRef);
|
||||
if (NS_FAILED(rv))
|
||||
@@ -860,6 +884,9 @@ NS_IMETHODIMP nsLocalFile::SetFileSize(PRInt64 aFileSize)
|
||||
/* readonly attribute PRInt64 fileSizeOfLink; */
|
||||
NS_IMETHODIMP nsLocalFile::GetFileSizeOfLink(PRInt64 *aFileSizeOfLink)
|
||||
{
|
||||
// Check we are correctly initialized.
|
||||
CHECK_mBaseRef();
|
||||
|
||||
NS_ENSURE_ARG_POINTER(aFileSizeOfLink);
|
||||
|
||||
StFollowLinksState followLinks(*this, PR_FALSE);
|
||||
@@ -894,8 +921,9 @@ NS_IMETHODIMP nsLocalFile::GetPath(nsAString& aPath)
|
||||
/* [noscript] readonly attribute ACString nativePath; */
|
||||
NS_IMETHODIMP nsLocalFile::GetNativePath(nsACString& aNativePath)
|
||||
{
|
||||
if (!mBaseRef)
|
||||
return NS_ERROR_NOT_INITIALIZED;
|
||||
// Check we are correctly initialized.
|
||||
CHECK_mBaseRef();
|
||||
|
||||
nsresult rv = NS_ERROR_FAILURE;
|
||||
CFStringRef pathStrRef = ::CFURLCopyFileSystemPath(mBaseRef, kCFURLPOSIXPathStyle);
|
||||
if (pathStrRef) {
|
||||
@@ -908,6 +936,9 @@ NS_IMETHODIMP nsLocalFile::GetNativePath(nsACString& aNativePath)
|
||||
/* boolean exists (); */
|
||||
NS_IMETHODIMP nsLocalFile::Exists(PRBool *_retval)
|
||||
{
|
||||
// Check we are correctly initialized.
|
||||
CHECK_mBaseRef();
|
||||
|
||||
NS_ENSURE_ARG_POINTER(_retval);
|
||||
*_retval = PR_FALSE;
|
||||
|
||||
@@ -922,6 +953,9 @@ NS_IMETHODIMP nsLocalFile::Exists(PRBool *_retval)
|
||||
/* boolean isWritable (); */
|
||||
NS_IMETHODIMP nsLocalFile::IsWritable(PRBool *_retval)
|
||||
{
|
||||
// Check we are correctly initialized.
|
||||
CHECK_mBaseRef();
|
||||
|
||||
NS_ENSURE_ARG_POINTER(_retval);
|
||||
*_retval = PR_FALSE;
|
||||
|
||||
@@ -942,6 +976,9 @@ NS_IMETHODIMP nsLocalFile::IsWritable(PRBool *_retval)
|
||||
/* boolean isReadable (); */
|
||||
NS_IMETHODIMP nsLocalFile::IsReadable(PRBool *_retval)
|
||||
{
|
||||
// Check we are correctly initialized.
|
||||
CHECK_mBaseRef();
|
||||
|
||||
NS_ENSURE_ARG_POINTER(_retval);
|
||||
*_retval = PR_FALSE;
|
||||
|
||||
@@ -956,6 +993,9 @@ NS_IMETHODIMP nsLocalFile::IsReadable(PRBool *_retval)
|
||||
/* boolean isExecutable (); */
|
||||
NS_IMETHODIMP nsLocalFile::IsExecutable(PRBool *_retval)
|
||||
{
|
||||
// Check we are correctly initialized.
|
||||
CHECK_mBaseRef();
|
||||
|
||||
NS_ENSURE_ARG_POINTER(_retval);
|
||||
*_retval = PR_FALSE;
|
||||
|
||||
@@ -1046,10 +1086,14 @@ NS_IMETHODIMP nsLocalFile::IsFile(PRBool *_retval)
|
||||
/* boolean isSymlink (); */
|
||||
NS_IMETHODIMP nsLocalFile::IsSymlink(PRBool *_retval)
|
||||
{
|
||||
// Check we are correctly initialized.
|
||||
CHECK_mBaseRef();
|
||||
|
||||
NS_ENSURE_ARG(_retval);
|
||||
*_retval = PR_FALSE;
|
||||
if (!mBaseRef)
|
||||
return NS_ERROR_NOT_INITIALIZED;
|
||||
|
||||
// Check we are correctly initialized.
|
||||
CHECK_mBaseRef();
|
||||
|
||||
FSRef fsRef;
|
||||
if (::CFURLGetFSRef(mBaseRef, &fsRef)) {
|
||||
@@ -1126,6 +1170,9 @@ nsLocalFile::EqualsInternal(nsISupports* inFile, PRBool aUpdateCache,
|
||||
/* boolean contains (in nsIFile inFile, in boolean recur); */
|
||||
NS_IMETHODIMP nsLocalFile::Contains(nsIFile *inFile, PRBool recur, PRBool *_retval)
|
||||
{
|
||||
// Check we are correctly initialized.
|
||||
CHECK_mBaseRef();
|
||||
|
||||
NS_ENSURE_ARG_POINTER(_retval);
|
||||
*_retval = PR_FALSE;
|
||||
|
||||
@@ -1154,8 +1201,9 @@ NS_IMETHODIMP nsLocalFile::GetParent(nsIFile * *aParent)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(aParent);
|
||||
*aParent = nsnull;
|
||||
if (!mBaseRef)
|
||||
return NS_ERROR_NOT_INITIALIZED;
|
||||
|
||||
// Check we are correctly initialized.
|
||||
CHECK_mBaseRef();
|
||||
|
||||
nsLocalFile *newFile = nsnull;
|
||||
|
||||
@@ -1339,6 +1387,9 @@ NS_IMETHODIMP nsLocalFile::OpenANSIFileDesc(const char *mode, FILE **_retval)
|
||||
/* [noscript] PRLibraryStar load (); */
|
||||
NS_IMETHODIMP nsLocalFile::Load(PRLibrary **_retval)
|
||||
{
|
||||
// Check we are correctly initialized.
|
||||
CHECK_mBaseRef();
|
||||
|
||||
NS_ENSURE_ARG_POINTER(_retval);
|
||||
|
||||
NS_TIMELINE_START_TIMER("PR_LoadLibrary");
|
||||
@@ -1370,6 +1421,9 @@ NS_IMETHODIMP nsLocalFile::Load(PRLibrary **_retval)
|
||||
/* readonly attribute PRInt64 diskSpaceAvailable; */
|
||||
NS_IMETHODIMP nsLocalFile::GetDiskSpaceAvailable(PRInt64 *aDiskSpaceAvailable)
|
||||
{
|
||||
// Check we are correctly initialized.
|
||||
CHECK_mBaseRef();
|
||||
|
||||
NS_ENSURE_ARG_POINTER(aDiskSpaceAvailable);
|
||||
|
||||
FSRef fsRef;
|
||||
@@ -1664,8 +1718,9 @@ NS_IMETHODIMP nsLocalFile::GetFSRef(FSRef *_retval)
|
||||
NS_IMETHODIMP nsLocalFile::GetFSSpec(FSSpec *_retval)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(_retval);
|
||||
if (!mBaseRef)
|
||||
return NS_ERROR_NOT_INITIALIZED;
|
||||
|
||||
// Check we are correctly initialized.
|
||||
CHECK_mBaseRef();
|
||||
|
||||
OSErr err;
|
||||
FSRef fsRef;
|
||||
@@ -1984,8 +2039,8 @@ nsresult nsLocalFile::SetBaseRef(CFURLRef aCFURLRef)
|
||||
|
||||
nsresult nsLocalFile::UpdateTargetRef()
|
||||
{
|
||||
if (!mBaseRef)
|
||||
return NS_ERROR_NOT_INITIALIZED;
|
||||
// Check we are correctly initialized.
|
||||
CHECK_mBaseRef();
|
||||
|
||||
if (mFollowLinksDirty) {
|
||||
if (mTargetRef) {
|
||||
@@ -2051,6 +2106,9 @@ nsresult nsLocalFile::CopyInternal(nsIFile* aParentDir,
|
||||
const nsAString& newName,
|
||||
PRBool followLinks)
|
||||
{
|
||||
// Check we are correctly initialized.
|
||||
CHECK_mBaseRef();
|
||||
|
||||
StFollowLinksState srcFollowState(*this, followLinks);
|
||||
|
||||
nsresult rv;
|
||||
|
||||
@@ -80,6 +80,12 @@
|
||||
|
||||
#include "nsTraceRefcntImpl.h"
|
||||
|
||||
#define CHECK_mWorkingPath() \
|
||||
PR_BEGIN_MACRO \
|
||||
if (mWorkingPath.IsEmpty()) \
|
||||
return NS_ERROR_NOT_INITIALIZED; \
|
||||
PR_END_MACRO
|
||||
|
||||
// _mbsstr isn't declared in w32api headers but it's there in the libs
|
||||
#ifdef __MINGW32__
|
||||
extern "C" {
|
||||
@@ -1737,6 +1743,9 @@ nsLocalFile::MoveTo(nsIFile *newParentDir, const nsAString &newName)
|
||||
NS_IMETHODIMP
|
||||
nsLocalFile::Load(PRLibrary * *_retval)
|
||||
{
|
||||
// Check we are correctly initialized.
|
||||
CHECK_mWorkingPath();
|
||||
|
||||
PRBool isFile;
|
||||
nsresult rv = IsFile(&isFile);
|
||||
|
||||
@@ -1791,6 +1800,9 @@ nsLocalFile::Remove(PRBool recursive)
|
||||
// pointing to a directory, only the mWorkingPath value is used and so
|
||||
// only the shortcut file will be deleted.
|
||||
|
||||
// Check we are correctly initialized.
|
||||
CHECK_mWorkingPath();
|
||||
|
||||
PRBool isDir, isLink;
|
||||
nsresult rv;
|
||||
|
||||
@@ -1845,6 +1857,9 @@ nsLocalFile::Remove(PRBool recursive)
|
||||
NS_IMETHODIMP
|
||||
nsLocalFile::GetLastModifiedTime(PRInt64 *aLastModifiedTime)
|
||||
{
|
||||
// Check we are correctly initialized.
|
||||
CHECK_mWorkingPath();
|
||||
|
||||
NS_ENSURE_ARG(aLastModifiedTime);
|
||||
|
||||
// get the modified time of the target as determined by mFollowSymlinks
|
||||
@@ -1867,6 +1882,9 @@ nsLocalFile::GetLastModifiedTime(PRInt64 *aLastModifiedTime)
|
||||
NS_IMETHODIMP
|
||||
nsLocalFile::GetLastModifiedTimeOfLink(PRInt64 *aLastModifiedTime)
|
||||
{
|
||||
// Check we are correctly initialized.
|
||||
CHECK_mWorkingPath();
|
||||
|
||||
NS_ENSURE_ARG(aLastModifiedTime);
|
||||
|
||||
// The caller is assumed to have already called IsSymlink
|
||||
@@ -1888,6 +1906,9 @@ nsLocalFile::GetLastModifiedTimeOfLink(PRInt64 *aLastModifiedTime)
|
||||
NS_IMETHODIMP
|
||||
nsLocalFile::SetLastModifiedTime(PRInt64 aLastModifiedTime)
|
||||
{
|
||||
// Check we are correctly initialized.
|
||||
CHECK_mWorkingPath();
|
||||
|
||||
nsresult rv = ResolveAndStat();
|
||||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
@@ -1991,6 +2012,9 @@ nsLocalFile::GetPermissions(PRUint32 *aPermissions)
|
||||
NS_IMETHODIMP
|
||||
nsLocalFile::GetPermissionsOfLink(PRUint32 *aPermissions)
|
||||
{
|
||||
// Check we are correctly initialized.
|
||||
CHECK_mWorkingPath();
|
||||
|
||||
NS_ENSURE_ARG(aPermissions);
|
||||
|
||||
// The caller is assumed to have already called IsSymlink
|
||||
@@ -2013,6 +2037,9 @@ nsLocalFile::GetPermissionsOfLink(PRUint32 *aPermissions)
|
||||
NS_IMETHODIMP
|
||||
nsLocalFile::SetPermissions(PRUint32 aPermissions)
|
||||
{
|
||||
// Check we are correctly initialized.
|
||||
CHECK_mWorkingPath();
|
||||
|
||||
// set the permissions of the target as determined by mFollowSymlinks
|
||||
// If PR_TRUE, then this will be for the target of the shortcut file,
|
||||
// otherwise it will be for the shortcut file itself (i.e. the same
|
||||
@@ -2071,6 +2098,9 @@ nsLocalFile::GetFileSize(PRInt64 *aFileSize)
|
||||
NS_IMETHODIMP
|
||||
nsLocalFile::GetFileSizeOfLink(PRInt64 *aFileSize)
|
||||
{
|
||||
// Check we are correctly initialized.
|
||||
CHECK_mWorkingPath();
|
||||
|
||||
NS_ENSURE_ARG(aFileSize);
|
||||
|
||||
// The caller is assumed to have already called IsSymlink
|
||||
@@ -2087,6 +2117,9 @@ nsLocalFile::GetFileSizeOfLink(PRInt64 *aFileSize)
|
||||
NS_IMETHODIMP
|
||||
nsLocalFile::SetFileSize(PRInt64 aFileSize)
|
||||
{
|
||||
// Check we are correctly initialized.
|
||||
CHECK_mWorkingPath();
|
||||
|
||||
nsresult rv = ResolveAndStat();
|
||||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
@@ -2120,6 +2153,9 @@ nsLocalFile::SetFileSize(PRInt64 aFileSize)
|
||||
NS_IMETHODIMP
|
||||
nsLocalFile::GetDiskSpaceAvailable(PRInt64 *aDiskSpaceAvailable)
|
||||
{
|
||||
// Check we are correctly initialized.
|
||||
CHECK_mWorkingPath();
|
||||
|
||||
#ifndef WINCE
|
||||
NS_ENSURE_ARG(aDiskSpaceAvailable);
|
||||
|
||||
@@ -2141,6 +2177,9 @@ nsLocalFile::GetDiskSpaceAvailable(PRInt64 *aDiskSpaceAvailable)
|
||||
NS_IMETHODIMP
|
||||
nsLocalFile::GetParent(nsIFile * *aParent)
|
||||
{
|
||||
// Check we are correctly initialized.
|
||||
CHECK_mWorkingPath();
|
||||
|
||||
NS_ENSURE_ARG_POINTER(aParent);
|
||||
|
||||
nsAutoString parentPath(mWorkingPath);
|
||||
@@ -2175,6 +2214,9 @@ nsLocalFile::GetParent(nsIFile * *aParent)
|
||||
NS_IMETHODIMP
|
||||
nsLocalFile::Exists(PRBool *_retval)
|
||||
{
|
||||
// Check we are correctly initialized.
|
||||
CHECK_mWorkingPath();
|
||||
|
||||
NS_ENSURE_ARG(_retval);
|
||||
*_retval = PR_FALSE;
|
||||
|
||||
@@ -2188,6 +2230,9 @@ nsLocalFile::Exists(PRBool *_retval)
|
||||
NS_IMETHODIMP
|
||||
nsLocalFile::IsWritable(PRBool *aIsWritable)
|
||||
{
|
||||
// Check we are correctly initialized.
|
||||
CHECK_mWorkingPath();
|
||||
|
||||
//TODO: extend to support NTFS file permissions
|
||||
|
||||
// The read-only attribute on a FAT directory only means that it can't
|
||||
@@ -2210,6 +2255,9 @@ nsLocalFile::IsWritable(PRBool *aIsWritable)
|
||||
NS_IMETHODIMP
|
||||
nsLocalFile::IsReadable(PRBool *_retval)
|
||||
{
|
||||
// Check we are correctly initialized.
|
||||
CHECK_mWorkingPath();
|
||||
|
||||
NS_ENSURE_ARG(_retval);
|
||||
*_retval = PR_FALSE;
|
||||
|
||||
@@ -2225,6 +2273,9 @@ nsLocalFile::IsReadable(PRBool *_retval)
|
||||
NS_IMETHODIMP
|
||||
nsLocalFile::IsExecutable(PRBool *_retval)
|
||||
{
|
||||
// Check we are correctly initialized.
|
||||
CHECK_mWorkingPath();
|
||||
|
||||
NS_ENSURE_ARG(_retval);
|
||||
*_retval = PR_FALSE;
|
||||
|
||||
@@ -2406,6 +2457,9 @@ nsLocalFile::HasFileAttribute(DWORD fileAttrib, PRBool *_retval)
|
||||
NS_IMETHODIMP
|
||||
nsLocalFile::IsSymlink(PRBool *_retval)
|
||||
{
|
||||
// Check we are correctly initialized.
|
||||
CHECK_mWorkingPath();
|
||||
|
||||
NS_ENSURE_ARG(_retval);
|
||||
|
||||
// unless it is a valid shortcut path it's not a symlink
|
||||
@@ -2458,6 +2512,9 @@ nsLocalFile::Equals(nsIFile *inFile, PRBool *_retval)
|
||||
NS_IMETHODIMP
|
||||
nsLocalFile::Contains(nsIFile *inFile, PRBool recur, PRBool *_retval)
|
||||
{
|
||||
// Check we are correctly initialized.
|
||||
CHECK_mWorkingPath();
|
||||
|
||||
*_retval = PR_FALSE;
|
||||
|
||||
nsAutoString myFilePath;
|
||||
@@ -2774,6 +2831,9 @@ nsLocalFile::GetNativeCanonicalPath(nsACString &aResult)
|
||||
NS_IMETHODIMP
|
||||
nsLocalFile::CopyToNative(nsIFile *newParentDir, const nsACString &newName)
|
||||
{
|
||||
// Check we are correctly initialized.
|
||||
CHECK_mWorkingPath();
|
||||
|
||||
if (newName.IsEmpty())
|
||||
return CopyTo(newParentDir, EmptyString());
|
||||
|
||||
@@ -2802,6 +2862,9 @@ nsLocalFile::CopyToFollowingLinksNative(nsIFile *newParentDir, const nsACString
|
||||
NS_IMETHODIMP
|
||||
nsLocalFile::MoveToNative(nsIFile *newParentDir, const nsACString &newName)
|
||||
{
|
||||
// Check we are correctly initialized.
|
||||
CHECK_mWorkingPath();
|
||||
|
||||
if (newName.IsEmpty())
|
||||
return MoveTo(newParentDir, EmptyString());
|
||||
|
||||
@@ -2816,6 +2879,9 @@ nsLocalFile::MoveToNative(nsIFile *newParentDir, const nsACString &newName)
|
||||
NS_IMETHODIMP
|
||||
nsLocalFile::GetNativeTarget(nsACString &_retval)
|
||||
{
|
||||
// Check we are correctly initialized.
|
||||
CHECK_mWorkingPath();
|
||||
|
||||
NS_WARNING("This API is lossy. Use GetTarget !");
|
||||
nsAutoString tmp;
|
||||
nsresult rv = GetTarget(tmp);
|
||||
|
||||
Reference in New Issue
Block a user