зеркало из https://github.com/mozilla/gecko-dev.git
Fix for bug 10435. Everything except CopyFrom() and MoveFrom()
This commit is contained in:
Родитель
689f6d1cbf
Коммит
9d805dcf7b
|
@ -23,11 +23,6 @@ interface nsISimpleEnumerator;
|
|||
[scriptable, uuid(73025830-0ce2-11d3-9331-00104ba0fd40)]
|
||||
interface nsIFileChannel : nsIChannel
|
||||
{
|
||||
/**
|
||||
* Returns the creation date of the URL.
|
||||
*/
|
||||
readonly attribute PRTime CreationDate;
|
||||
|
||||
/**
|
||||
* Returns the last modification date of the URL.
|
||||
*/
|
||||
|
@ -108,9 +103,9 @@ interface nsIFileChannel : nsIChannel
|
|||
nsIFileChannel ResolveLink();
|
||||
|
||||
/**
|
||||
* Returns a unique file name for the directory of the current URL.
|
||||
* Returns a new unique unique file channel for the directory of the current URL.
|
||||
*/
|
||||
string MakeUniqueFileName(in string baseName);
|
||||
nsIFileChannel MakeUnique(in string baseName);
|
||||
|
||||
/**
|
||||
* Executes a program specified by the file channel.
|
||||
|
|
|
@ -29,6 +29,7 @@
|
|||
#include "nsIBufferOutputStream.h"
|
||||
#include "nsAutoLock.h"
|
||||
#include "netCore.h"
|
||||
#include "nsFileStream.h"
|
||||
#include "nsIFileStream.h"
|
||||
#include "nsISimpleEnumerator.h"
|
||||
#include "nsIURL.h"
|
||||
|
@ -755,13 +756,6 @@ nsFileChannel::OnEmpty(nsIBuffer* buffer)
|
|||
// From nsIFileChannel
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsFileChannel::GetCreationDate(PRTime *aCreationDate)
|
||||
{
|
||||
// XXX no GetCreationDate in nsFileSpec yet
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsFileChannel::GetModDate(PRTime *aModDate)
|
||||
{
|
||||
|
@ -781,27 +775,9 @@ nsFileChannel::GetFileSize(PRUint32 *aFileSize)
|
|||
NS_IMETHODIMP
|
||||
nsFileChannel::GetParent(nsIFileChannel * *aParent)
|
||||
{
|
||||
nsresult rv;
|
||||
|
||||
nsFileSpec parentSpec;
|
||||
mSpec.GetParent(parentSpec);
|
||||
nsFileURL parentURL(parentSpec);
|
||||
const char* urlStr = parentURL.GetURLString();
|
||||
|
||||
NS_WITH_SERVICE(nsIIOService, serv, kIOServiceCID, &rv);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
nsIChannel* channel;
|
||||
rv = serv->NewChannel("load", // XXX what should this be?
|
||||
urlStr, nsnull,
|
||||
mGetter, &channel);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
// this cast is safe because nsFileURL::GetURLString aways
|
||||
// returns file: strings, and consequently we'll make nsIFileChannel
|
||||
// objects from them:
|
||||
*aParent = NS_STATIC_CAST(nsIFileChannel*, channel);
|
||||
|
||||
return NS_OK;
|
||||
return CreateFileChannelFromFileSpec(parentSpec, aParent);
|
||||
}
|
||||
|
||||
class nsDirEnumerator : public nsISimpleEnumerator
|
||||
|
@ -922,15 +898,22 @@ nsFileChannel::Exists(PRBool *result)
|
|||
NS_IMETHODIMP
|
||||
nsFileChannel::Create()
|
||||
{
|
||||
// XXX no Create in nsFileSpec -- creates non-existent file
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
nsFileSpec mySpec(mSpec, PR_TRUE); // relative path.
|
||||
{
|
||||
nsIOFileStream testStream(mySpec); // creates the file
|
||||
// Scope ends here, file gets closed
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsFileChannel::Delete()
|
||||
{
|
||||
// XXX no Delete in nsFileSpec -- deletes file or dir
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
mSpec.Delete(PR_TRUE); // RECURSIVE DELETE!
|
||||
if (mSpec.Exists())
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
|
@ -993,24 +976,38 @@ nsFileChannel::IsFile(PRBool *result)
|
|||
NS_IMETHODIMP
|
||||
nsFileChannel::IsLink(PRBool *_retval)
|
||||
{
|
||||
// XXX no IsLink in nsFileSpec (for alias/shortcut/symlink)
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
*_retval = mSpec.IsSymlink();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsFileChannel::ResolveLink(nsIFileChannel **_retval)
|
||||
{
|
||||
// XXX no ResolveLink in nsFileSpec yet -- returns what link points to
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
PRBool ignore;
|
||||
nsFileSpec tempSpec = mSpec;
|
||||
nsresult rv = tempSpec.ResolveSymlink(ignore);
|
||||
|
||||
if(NS_SUCCEEDED(rv))
|
||||
{
|
||||
return CreateFileChannelFromFileSpec(tempSpec, _retval);
|
||||
}
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsFileChannel::MakeUniqueFileName(const char* baseName, char **_retval)
|
||||
nsFileChannel::MakeUnique(const char* baseName, nsIFileChannel **_retval)
|
||||
{
|
||||
// XXX makeUnique needs to return the name or file spec to the newly create
|
||||
// file!
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
if (mSpec.IsDirectory())
|
||||
{
|
||||
nsFileSpec tempSpec = mSpec;
|
||||
tempSpec.MakeUnique(baseName);
|
||||
|
||||
return CreateFileChannelFromFileSpec(tempSpec, _retval);
|
||||
}
|
||||
return NS_ERROR_FAILURE; // XXX probably need NS_BASE_STREAM_NOT_DIRECTORY or something
|
||||
}
|
||||
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsFileChannel::Execute(const char *args)
|
||||
|
@ -1036,3 +1033,29 @@ nsFileChannel::Execute(const char *args)
|
|||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
nsresult
|
||||
nsFileChannel::CreateFileChannelFromFileSpec(nsFileSpec& spec, nsIFileChannel **result)
|
||||
{
|
||||
nsresult rv;
|
||||
|
||||
nsFileURL aURL(spec);
|
||||
const char* urlStr = aURL.GetURLString();
|
||||
|
||||
NS_WITH_SERVICE(nsIIOService, serv, kIOServiceCID, &rv);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
nsIChannel* channel;
|
||||
rv = serv->NewChannel("load", // XXX what should this be?
|
||||
urlStr,
|
||||
nsnull,
|
||||
mGetter,
|
||||
&channel);
|
||||
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
// this cast is safe because nsFileURL::GetURLString aways
|
||||
// returns file: strings, and consequently we'll make nsIFileChannel
|
||||
// objects from them:
|
||||
*result = NS_STATIC_CAST(nsIFileChannel*, channel);
|
||||
return NS_OK;
|
||||
}
|
|
@ -135,6 +135,8 @@ protected:
|
|||
PRUint32 mLoadAttributes;
|
||||
nsILoadGroup* mLoadGroup;
|
||||
|
||||
nsresult CreateFileChannelFromFileSpec(nsFileSpec& spec, nsIFileChannel** result);
|
||||
|
||||
#ifdef STREAM_CONVERTER_HACK
|
||||
nsCOMPtr<nsIStreamConverter2> mStreamConverter;
|
||||
nsXPIDLCString mStreamConverterOutType;
|
||||
|
|
Загрузка…
Ссылка в новой задаче