changing GetDiskSpaceAvailable to return a signed 64 bit value
This commit is contained in:
Родитель
719cb1d7f5
Коммит
82c52d63e8
|
@ -143,7 +143,7 @@ class nsFileSpecWithUIImpl
|
|||
{ return mBaseFileSpec ? mBaseFileSpec->GetFileSize(aFileSize) : NS_ERROR_NOT_INITIALIZED; }
|
||||
|
||||
/* readonly attribute unsigned long DiskSpaceAvailable; */
|
||||
NS_IMETHOD GetDiskSpaceAvailable(PRUint64 *aDiskSpaceAvailable)
|
||||
NS_IMETHOD GetDiskSpaceAvailable(PRInt64 *aDiskSpaceAvailable)
|
||||
{ return mBaseFileSpec ? mBaseFileSpec->GetDiskSpaceAvailable(aDiskSpaceAvailable) : NS_ERROR_NOT_INITIALIZED; }
|
||||
|
||||
/* nsIFileSpec AppendRelativeUnixPath (in string relativePath); */
|
||||
|
|
|
@ -93,7 +93,7 @@ class nsFileSpecWithUIImpl
|
|||
NS_IMETHOD GetFileSize(PRUint32 *aFileSize);
|
||||
|
||||
/* readonly attribute unsigned long DiskSpaceAvailable; */
|
||||
NS_IMETHOD GetDiskSpaceAvailable(PRUint64 *aDiskSpaceAvailable);
|
||||
NS_IMETHOD GetDiskSpaceAvailable(PRInt64 *aDiskSpaceAvailable);
|
||||
|
||||
/* nsIFileSpec AppendRelativeUnixPath (in string relativePath); */
|
||||
NS_IMETHOD AppendRelativeUnixPath(const char *relativePath);
|
||||
|
|
|
@ -418,7 +418,7 @@ class NS_COM nsFileSpec
|
|||
}
|
||||
|
||||
PRUint32 GetFileSize() const;
|
||||
PRUint64 GetDiskSpaceAvailable() const;
|
||||
PRInt64 GetDiskSpaceAvailable() const;
|
||||
|
||||
nsFileSpec operator + (const char* inRelativeUnixPath) const;
|
||||
nsFileSpec operator + (const nsString& inRelativeUnixPath) const
|
||||
|
|
|
@ -421,7 +421,7 @@ nsresult nsFileSpec::Execute(const char* inArgs ) const
|
|||
} // nsFileSpec::Execute
|
||||
|
||||
//----------------------------------------------------------------------------------------
|
||||
PRUint64 nsFileSpec::GetDiskSpaceAvailable() const
|
||||
PRInt64 nsFileSpec::GetDiskSpaceAvailable() const
|
||||
//----------------------------------------------------------------------------------------
|
||||
{
|
||||
char curdir [MAXPATHLEN];
|
||||
|
|
|
@ -344,7 +344,7 @@ NS_IMETHODIMP nsFileSpecImpl::GetFileSize(PRUint32 *aFileSize)
|
|||
}
|
||||
|
||||
//----------------------------------------------------------------------------------------
|
||||
NS_IMETHODIMP nsFileSpecImpl::GetDiskSpaceAvailable(PRUint64 *aDiskSpaceAvailable)
|
||||
NS_IMETHODIMP nsFileSpecImpl::GetDiskSpaceAvailable(PRInt64 *aDiskSpaceAvailable)
|
||||
//----------------------------------------------------------------------------------------
|
||||
{
|
||||
TEST_OUT_PTR(aDiskSpaceAvailable)
|
||||
|
|
|
@ -1105,10 +1105,10 @@ OSErr nsFileSpec::GetFileTypeAndCreator(OSType* type, OSType* creator)
|
|||
|
||||
|
||||
//----------------------------------------------------------------------------------------
|
||||
PRUint64 nsFileSpec::GetDiskSpaceAvailable() const
|
||||
PRInt64 nsFileSpec::GetDiskSpaceAvailable() const
|
||||
//----------------------------------------------------------------------------------------
|
||||
{
|
||||
PRUint64 int64;
|
||||
PRInt64 int64;
|
||||
|
||||
LL_I2L(int64 , ULONG_MAX);
|
||||
|
||||
|
|
|
@ -242,9 +242,9 @@ PRUint32 nsFileSpec::GetFileSize() const
|
|||
}
|
||||
|
||||
// Okay, this is a really weird place to put this method!
|
||||
// And it ought to return a PRUint64.
|
||||
// And it ought to return a PRInt64.
|
||||
//
|
||||
PRUint64 nsFileSpec::GetDiskSpaceAvailable() const
|
||||
PRInt64 nsFileSpec::GetDiskSpaceAvailable() const
|
||||
{
|
||||
ULONG ulDriveNo = toupper(mPath[0]) + 1 - 'A';
|
||||
FSALLOCATE fsAllocate = { 0 };
|
||||
|
@ -262,7 +262,7 @@ PRUint64 nsFileSpec::GetDiskSpaceAvailable() const
|
|||
fsAllocate.cbSector;
|
||||
}
|
||||
|
||||
PRUint64 int64;
|
||||
PRInt64 int64;
|
||||
|
||||
LL_I2L(int64 , cbAvail);
|
||||
|
||||
|
|
|
@ -474,12 +474,10 @@ nsresult nsFileSpec::Execute(const char* inArgs ) const
|
|||
} // nsFileSpec::Execute
|
||||
|
||||
//----------------------------------------------------------------------------------------
|
||||
PRUint64 nsFileSpec::GetDiskSpaceAvailable() const
|
||||
PRInt64 nsFileSpec::GetDiskSpaceAvailable() const
|
||||
//----------------------------------------------------------------------------------------
|
||||
{
|
||||
PRUint64 bytes;
|
||||
LL_I2L(bytes, ULONG_MAX);
|
||||
|
||||
|
||||
#if defined(HAVE_SYS_STATFS_H) || defined(HAVE_SYS_STATVFS_H)
|
||||
|
||||
char curdir [MAXPATHLEN];
|
||||
|
|
|
@ -551,10 +551,10 @@ nsresult nsFileSpec::Execute(const char* inArgs ) const
|
|||
|
||||
|
||||
//----------------------------------------------------------------------------------------
|
||||
PRUint64 nsFileSpec::GetDiskSpaceAvailable() const
|
||||
PRInt64 nsFileSpec::GetDiskSpaceAvailable() const
|
||||
//----------------------------------------------------------------------------------------
|
||||
{
|
||||
PRUint64 int64;
|
||||
PRInt64 int64;
|
||||
|
||||
LL_I2L(int64 , ULONG_MAX);
|
||||
|
||||
|
@ -613,7 +613,7 @@ PRUint64 nsFileSpec::GetDiskSpaceAvailable() const
|
|||
{
|
||||
nBytes = (double)dwFreeClus*(double)dwSecPerClus*(double) dwBytesPerSec;
|
||||
}
|
||||
return (PRUint64)nBytes;
|
||||
return (PRInt64)nBytes;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -157,7 +157,7 @@ interface nsIFile : nsISupports
|
|||
readonly attribute unsigned long fileSizeOfLink;
|
||||
|
||||
|
||||
readonly attribute unsigned long long diskSpaceAvailable; // maybe we should put this somewhere else.
|
||||
readonly attribute long long diskSpaceAvailable; // maybe we should put this somewhere else.
|
||||
|
||||
/**
|
||||
* Parent will be nsnull when this is at the top of the volume.
|
||||
|
|
|
@ -86,7 +86,7 @@ interface nsIFileSpec : nsISupports
|
|||
boolean isHidden();
|
||||
|
||||
readonly attribute unsigned long fileSize;
|
||||
readonly attribute unsigned long long diskSpaceAvailable;
|
||||
readonly attribute long long diskSpaceAvailable;
|
||||
|
||||
void appendRelativeUnixPath(in string relativePath);
|
||||
|
||||
|
|
|
@ -48,6 +48,8 @@ struct FilesTest
|
|||
int Move(const char* sourceFile, const char* targDir);
|
||||
int Rename(const char* sourceFile, const char* newName);
|
||||
|
||||
int DiskSpace();
|
||||
|
||||
int Execute(const char* appName, const char* args);
|
||||
|
||||
int SpecialSystemDirectories();
|
||||
|
@ -597,6 +599,22 @@ int FilesTest::Move(const char* file, const char* dir)
|
|||
return Passed();
|
||||
}
|
||||
|
||||
|
||||
//----------------------------------------------------------------------------------------
|
||||
int FilesTest::DiskSpace()
|
||||
//----------------------------------------------------------------------------------------
|
||||
{
|
||||
|
||||
nsSpecialSystemDirectory systemDir(nsSpecialSystemDirectory::OS_DriveDirectory);
|
||||
if (!systemDir.Valid())
|
||||
return Failed();
|
||||
|
||||
PRInt64 bytes = systemDir.GetDiskSpaceAvailable();
|
||||
|
||||
printf("OS Drive has %ld bytes free\n", bytes);
|
||||
|
||||
return Inspect();
|
||||
}
|
||||
//----------------------------------------------------------------------------------------
|
||||
int FilesTest::Execute(const char* appName, const char* args)
|
||||
//----------------------------------------------------------------------------------------
|
||||
|
@ -934,6 +952,11 @@ int FilesTest::RunAllTests()
|
|||
rv = CanonicalPath("mumble/iotest.txt");
|
||||
if (rv)
|
||||
return rv;
|
||||
|
||||
Banner("Getting DiskSpace");
|
||||
rv = DiskSpace();
|
||||
if (rv)
|
||||
return rv;
|
||||
|
||||
Banner("OutputStream");
|
||||
rv = OutputStream("mumble/iotest.txt");
|
||||
|
|
|
@ -647,7 +647,7 @@ nsInstall::DeleteFile(const nsString& aFolder, const nsString& aRelativeFileName
|
|||
}
|
||||
|
||||
PRInt32
|
||||
nsInstall::DiskSpaceAvailable(const nsString& aFolder, PRUint64* aReturn)
|
||||
nsInstall::DiskSpaceAvailable(const nsString& aFolder, PRInt64* aReturn)
|
||||
{
|
||||
nsFileSpec fsFolder(aFolder);
|
||||
|
||||
|
@ -1574,7 +1574,7 @@ nsInstall::FileOpFileGetNativeVersion(nsFileSpec& aTarget, nsString* aReturn)
|
|||
}
|
||||
|
||||
PRInt32
|
||||
nsInstall::FileOpFileGetDiskSpaceAvailable(nsFileSpec& aTarget, PRUint64* aReturn)
|
||||
nsInstall::FileOpFileGetDiskSpaceAvailable(nsFileSpec& aTarget, PRInt64* aReturn)
|
||||
{
|
||||
*aReturn = aTarget.GetDiskSpaceAvailable();
|
||||
return NS_OK;
|
||||
|
|
|
@ -180,7 +180,7 @@ class nsInstall
|
|||
|
||||
PRInt32 DeleteComponent(const nsString& aRegistryName, PRInt32* aReturn);
|
||||
PRInt32 DeleteFile(const nsString& aFolder, const nsString& aRelativeFileName, PRInt32* aReturn);
|
||||
PRInt32 DiskSpaceAvailable(const nsString& aFolder, PRUint64* aReturn);
|
||||
PRInt32 DiskSpaceAvailable(const nsString& aFolder, PRInt64* aReturn);
|
||||
PRInt32 Execute(const nsString& aJarSource, const nsString& aArgs, PRInt32* aReturn);
|
||||
PRInt32 Execute(const nsString& aJarSource, PRInt32* aReturn);
|
||||
PRInt32 FinalizeInstall(PRInt32* aReturn);
|
||||
|
@ -209,7 +209,7 @@ class nsInstall
|
|||
PRInt32 FileOpFileExists(nsFileSpec& aTarget, PRBool* aReturn);
|
||||
PRInt32 FileOpFileExecute(nsFileSpec& aTarget, nsString& aParams, PRInt32* aReturn);
|
||||
PRInt32 FileOpFileGetNativeVersion(nsFileSpec& aTarget, nsString* aReturn);
|
||||
PRInt32 FileOpFileGetDiskSpaceAvailable(nsFileSpec& aTarget, PRUint64* aReturn);
|
||||
PRInt32 FileOpFileGetDiskSpaceAvailable(nsFileSpec& aTarget, PRInt64* aReturn);
|
||||
PRInt32 FileOpFileGetModDate(nsFileSpec& aTarget, nsFileSpec::TimeStamp* aReturn);
|
||||
PRInt32 FileOpFileGetSize(nsFileSpec& aTarget, PRUint32* aReturn);
|
||||
PRInt32 FileOpFileIsDirectory(nsFileSpec& aTarget, PRBool* aReturn);
|
||||
|
|
|
@ -640,7 +640,7 @@ PR_STATIC_CALLBACK(JSBool)
|
|||
InstallDiskSpaceAvailable(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
|
||||
{
|
||||
nsInstall *nativeThis = (nsInstall*)JS_GetPrivate(cx, obj);
|
||||
PRUint64 nativeRet;
|
||||
PRInt64 nativeRet;
|
||||
nsAutoString b0;
|
||||
|
||||
*rval = JSVAL_NULL;
|
||||
|
@ -661,11 +661,10 @@ InstallDiskSpaceAvailable(JSContext *cx, JSObject *obj, uintN argc, jsval *argv,
|
|||
return JS_FALSE;
|
||||
}
|
||||
|
||||
#if 0
|
||||
jsdouble d;
|
||||
LL_L2F(d, nativeRet);
|
||||
JS_NewDoubleValue( cx, d, rval );
|
||||
#endif
|
||||
double d;
|
||||
|
||||
LL_L2D(d, nativeRet);
|
||||
JS_NewDoubleValue( cx, d, rval );
|
||||
|
||||
}
|
||||
else
|
||||
|
@ -1743,7 +1742,7 @@ InstallFileOpFileGetDiskSpaceAvailable(JSContext *cx, JSObject *obj, uintN argc,
|
|||
{
|
||||
|
||||
nsInstall* nativeThis = (nsInstall*)JS_GetPrivate(cx, obj);
|
||||
PRUint64 nativeRet;
|
||||
PRInt64 nativeRet;
|
||||
nsAutoString b0;
|
||||
|
||||
*rval = JSVAL_NULL;
|
||||
|
@ -1765,11 +1764,10 @@ InstallFileOpFileGetDiskSpaceAvailable(JSContext *cx, JSObject *obj, uintN argc,
|
|||
{
|
||||
return JS_FALSE;
|
||||
}
|
||||
#if 0
|
||||
jsdouble d;
|
||||
LL_L2F(d, nativeRet);
|
||||
JS_NewDoubleValue( cx, d, rval );
|
||||
#endif
|
||||
|
||||
double d;
|
||||
LL_L2D(d, nativeRet);
|
||||
JS_NewDoubleValue( cx, d, rval );
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
Загрузка…
Ссылка в новой задаче