зеркало из https://github.com/mozilla/pjs.git
Bug 673586 - Implement lastModifiedDate property for the File interface. r=mounir
This commit is contained in:
Родитель
5d8893cfce
Коммит
948960ec9f
|
@ -183,6 +183,7 @@ public:
|
||||||
// Overrides
|
// Overrides
|
||||||
NS_IMETHOD GetSize(PRUint64* aSize);
|
NS_IMETHOD GetSize(PRUint64* aSize);
|
||||||
NS_IMETHOD GetType(nsAString& aType);
|
NS_IMETHOD GetType(nsAString& aType);
|
||||||
|
NS_IMETHOD GetLastModifiedDate(JSContext* cx, JS::Value *aLastModifiedDate);
|
||||||
NS_IMETHOD GetMozFullPathInternal(nsAString& aFullPath);
|
NS_IMETHOD GetMozFullPathInternal(nsAString& aFullPath);
|
||||||
NS_IMETHOD GetInternalStream(nsIInputStream**);
|
NS_IMETHOD GetInternalStream(nsIInputStream**);
|
||||||
|
|
||||||
|
|
|
@ -56,10 +56,14 @@ interface nsIDOMBlob : nsISupports
|
||||||
[notxpcom] FileInfo getFileInfo(in FileManager aFileManager);
|
[notxpcom] FileInfo getFileInfo(in FileManager aFileManager);
|
||||||
};
|
};
|
||||||
|
|
||||||
[scriptable, builtinclass, uuid(b096ef67-7b77-47f8-8e70-5d8ee36416bf)]
|
[scriptable, builtinclass, uuid(eee028d1-8ce9-4c6c-b9ce-d89b656e1e17)]
|
||||||
interface nsIDOMFile : nsIDOMBlob
|
interface nsIDOMFile : nsIDOMBlob
|
||||||
{
|
{
|
||||||
readonly attribute DOMString name;
|
readonly attribute DOMString name;
|
||||||
|
|
||||||
|
[implicit_jscontext]
|
||||||
|
readonly attribute jsval lastModifiedDate;
|
||||||
|
|
||||||
readonly attribute DOMString mozFullPath;
|
readonly attribute DOMString mozFullPath;
|
||||||
|
|
||||||
// This performs no security checks!
|
// This performs no security checks!
|
||||||
|
|
|
@ -128,6 +128,13 @@ nsDOMFileBase::GetName(nsAString &aFileName)
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
NS_IMETHODIMP
|
||||||
|
nsDOMFileBase::GetLastModifiedDate(JSContext* cx, JS::Value *aLastModifiedDate)
|
||||||
|
{
|
||||||
|
aLastModifiedDate->setNull();
|
||||||
|
return NS_OK;
|
||||||
|
}
|
||||||
|
|
||||||
NS_IMETHODIMP
|
NS_IMETHODIMP
|
||||||
nsDOMFileBase::GetMozFullPath(nsAString &aFileName)
|
nsDOMFileBase::GetMozFullPath(nsAString &aFileName)
|
||||||
{
|
{
|
||||||
|
@ -417,6 +424,22 @@ nsDOMFileFile::GetMozFullPathInternal(nsAString &aFilename)
|
||||||
return mFile->GetPath(aFilename);
|
return mFile->GetPath(aFilename);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
NS_IMETHODIMP
|
||||||
|
nsDOMFileFile::GetLastModifiedDate(JSContext* cx, JS::Value *aLastModifiedDate)
|
||||||
|
{
|
||||||
|
PRTime msecs;
|
||||||
|
mFile->GetLastModifiedTime(&msecs);
|
||||||
|
JSObject* date = JS_NewDateObjectMsec(cx, msecs);
|
||||||
|
if (date) {
|
||||||
|
aLastModifiedDate->setObject(*date);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
aLastModifiedDate->setNull();
|
||||||
|
}
|
||||||
|
|
||||||
|
return NS_OK;
|
||||||
|
}
|
||||||
|
|
||||||
NS_IMETHODIMP
|
NS_IMETHODIMP
|
||||||
nsDOMFileFile::GetSize(PRUint64 *aFileSize)
|
nsDOMFileFile::GetSize(PRUint64 *aFileSize)
|
||||||
{
|
{
|
||||||
|
|
|
@ -34,6 +34,11 @@ var domFile = fileList.files[0];
|
||||||
|
|
||||||
is(domFile.name, "prefs.js", "fileName should be prefs.js");
|
is(domFile.name, "prefs.js", "fileName should be prefs.js");
|
||||||
|
|
||||||
|
ok("lastModifiedDate" in domFile, "lastModifiedDate must be present");
|
||||||
|
|
||||||
|
var d = new Date(testFile.lastModifiedTime);
|
||||||
|
ok(d.getTime() == domFile.lastModifiedDate.getTime(), "lastModifiedDate should be the same.");
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
</pre>
|
</pre>
|
||||||
</body> </html>
|
</body> </html>
|
||||||
|
|
Загрузка…
Ссылка в новой задаче