2000-06-07 09:07:10 +00:00
|
|
|
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
1999-11-07 21:55:12 +00:00
|
|
|
*
|
|
|
|
* The contents of this file are subject to the Netscape Public License
|
|
|
|
* Version 1.0 (the "NPL"); you may not use this file except in
|
|
|
|
* compliance with the NPL. You may obtain a copy of the NPL at
|
|
|
|
* http://www.mozilla.org/NPL/
|
|
|
|
*
|
|
|
|
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
|
|
|
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
|
|
|
* for the specific language governing rights and limitations under the
|
|
|
|
* NPL.
|
|
|
|
*
|
|
|
|
* The Initial Developer of this code under the NPL is Netscape
|
|
|
|
* Communications Corporation. Portions created by Netscape are
|
|
|
|
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
|
|
|
* Reserved.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "nsJARURI.h"
|
1999-11-30 04:50:42 +00:00
|
|
|
#include "nsNetUtil.h"
|
1999-11-07 21:55:12 +00:00
|
|
|
#include "nsIIOService.h"
|
|
|
|
#include "nsCRT.h"
|
|
|
|
#include "nsIComponentManager.h"
|
|
|
|
#include "nsIServiceManager.h"
|
1999-11-12 06:13:13 +00:00
|
|
|
#include "nsIZipReader.h"
|
2001-09-29 08:28:41 +00:00
|
|
|
#include "nsReadableUtils.h"
|
2002-08-15 18:38:46 +00:00
|
|
|
#include "nsURLHelper.h"
|
2000-01-27 08:57:14 +00:00
|
|
|
|
1999-11-07 21:55:12 +00:00
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
nsJARURI::nsJARURI()
|
2001-03-13 02:01:07 +00:00
|
|
|
: mJAREntry(nsnull)
|
1999-11-07 21:55:12 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
nsJARURI::~nsJARURI()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2001-07-31 19:05:34 +00:00
|
|
|
NS_IMPL_THREADSAFE_ISUPPORTS3(nsJARURI, nsIJARURI, nsIURI, nsISerializable)
|
1999-11-07 21:55:12 +00:00
|
|
|
|
|
|
|
nsresult
|
2002-03-06 07:48:55 +00:00
|
|
|
nsJARURI::Init(const char *charsetHint)
|
1999-11-07 21:55:12 +00:00
|
|
|
{
|
2002-03-06 07:48:55 +00:00
|
|
|
mCharsetHint = charsetHint;
|
1999-11-07 21:55:12 +00:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2002-03-06 07:48:55 +00:00
|
|
|
#define NS_JAR_SCHEME NS_LITERAL_CSTRING("jar:")
|
|
|
|
#define NS_JAR_DELIMITER NS_LITERAL_CSTRING("!/")
|
1999-11-07 21:55:12 +00:00
|
|
|
|
2000-01-27 08:57:14 +00:00
|
|
|
nsresult
|
2002-03-06 07:48:55 +00:00
|
|
|
nsJARURI::FormatSpec(const nsACString &entryPath, nsACString &result)
|
1999-11-07 21:55:12 +00:00
|
|
|
{
|
2002-03-06 07:48:55 +00:00
|
|
|
nsCAutoString fileSpec;
|
|
|
|
nsresult rv = mJARFile->GetSpec(fileSpec);
|
1999-11-07 21:55:12 +00:00
|
|
|
if (NS_FAILED(rv)) return rv;
|
|
|
|
|
2002-03-06 07:48:55 +00:00
|
|
|
result = NS_JAR_SCHEME + fileSpec + NS_JAR_DELIMITER + entryPath;
|
2001-12-15 20:34:07 +00:00
|
|
|
return NS_OK;
|
2000-01-27 08:57:14 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
2001-07-31 19:05:34 +00:00
|
|
|
// nsISerializable methods:
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsJARURI::Read(nsIObjectInputStream* aStream)
|
|
|
|
{
|
|
|
|
NS_NOTREACHED("nsJARURI::Read");
|
|
|
|
return NS_ERROR_NOT_IMPLEMENTED;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsJARURI::Write(nsIObjectOutputStream* aStream)
|
|
|
|
{
|
|
|
|
NS_NOTREACHED("nsJARURI::Write");
|
|
|
|
return NS_ERROR_NOT_IMPLEMENTED;
|
|
|
|
}
|
|
|
|
|
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
|
|
// nsIURI methods:
|
2000-01-27 08:57:14 +00:00
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2002-03-06 07:48:55 +00:00
|
|
|
nsJARURI::GetSpec(nsACString &aSpec)
|
2000-01-27 08:57:14 +00:00
|
|
|
{
|
|
|
|
return FormatSpec(mJAREntry, aSpec);
|
1999-11-07 21:55:12 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2002-03-06 07:48:55 +00:00
|
|
|
nsJARURI::SetSpec(const nsACString &aSpec)
|
1999-11-07 21:55:12 +00:00
|
|
|
{
|
|
|
|
nsresult rv;
|
2002-08-15 18:38:46 +00:00
|
|
|
nsCOMPtr<nsIIOService> ioServ(do_GetIOService(&rv));
|
1999-11-07 21:55:12 +00:00
|
|
|
if (NS_FAILED(rv)) return rv;
|
|
|
|
|
2002-03-06 07:48:55 +00:00
|
|
|
nsCAutoString scheme;
|
2002-09-13 19:32:45 +00:00
|
|
|
rv = net_ExtractURLScheme(aSpec, nsnull, nsnull, &scheme);
|
1999-11-07 21:55:12 +00:00
|
|
|
if (NS_FAILED(rv)) return rv;
|
|
|
|
|
2002-03-06 07:48:55 +00:00
|
|
|
if (strcmp("jar", scheme.get()) != 0)
|
2000-01-27 08:57:14 +00:00
|
|
|
return NS_ERROR_MALFORMED_URI;
|
1999-11-07 21:55:12 +00:00
|
|
|
|
|
|
|
// Search backward from the end for the "!/" delimiter. Remember, jar URLs
|
|
|
|
// can nest, e.g.:
|
|
|
|
// jar:jar:http://www.foo.com/bar.jar!/a.jar!/b.html
|
|
|
|
// This gets the b.html document from out of the a.jar file, that's
|
|
|
|
// contained within the bar.jar file.
|
|
|
|
|
2002-03-06 07:48:55 +00:00
|
|
|
nsACString::const_iterator begin, end, delim_begin, delim_end;
|
|
|
|
aSpec.BeginReading(begin);
|
|
|
|
aSpec.EndReading(end);
|
|
|
|
|
|
|
|
delim_begin = begin;
|
|
|
|
delim_end = end;
|
|
|
|
|
|
|
|
if (!RFindInReadable(NS_JAR_DELIMITER, delim_begin, delim_end))
|
1999-11-07 21:55:12 +00:00
|
|
|
return NS_ERROR_MALFORMED_URI;
|
|
|
|
|
2002-03-06 07:48:55 +00:00
|
|
|
begin.advance(4);
|
1999-11-07 21:55:12 +00:00
|
|
|
|
2002-08-15 18:38:46 +00:00
|
|
|
rv = ioServ->NewURI(Substring(begin, delim_begin), mCharsetHint.get(), nsnull, getter_AddRefs(mJARFile));
|
1999-11-07 21:55:12 +00:00
|
|
|
if (NS_FAILED(rv)) return rv;
|
|
|
|
|
2002-03-06 07:48:55 +00:00
|
|
|
// skip over any extra '/' chars
|
|
|
|
while (*delim_end == '/')
|
|
|
|
++delim_end;
|
1999-11-07 21:55:12 +00:00
|
|
|
|
2002-09-13 19:32:45 +00:00
|
|
|
rv = net_ResolveRelativePath(Substring(delim_end, end),
|
|
|
|
NS_LITERAL_CSTRING(""),
|
|
|
|
mJAREntry);
|
2000-01-27 08:57:14 +00:00
|
|
|
return rv;
|
1999-11-07 21:55:12 +00:00
|
|
|
}
|
|
|
|
|
2000-05-17 07:12:40 +00:00
|
|
|
NS_IMETHODIMP
|
2002-03-06 07:48:55 +00:00
|
|
|
nsJARURI::GetPrePath(nsACString &prePath)
|
|
|
|
{
|
|
|
|
prePath = "jar:";
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsJARURI::GetScheme(nsACString &aScheme)
|
2000-05-17 07:12:40 +00:00
|
|
|
{
|
2002-03-06 07:48:55 +00:00
|
|
|
aScheme = "jar";
|
|
|
|
return NS_OK;
|
2000-05-17 07:12:40 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2002-03-06 07:48:55 +00:00
|
|
|
nsJARURI::SetScheme(const nsACString &aScheme)
|
2000-05-17 07:12:40 +00:00
|
|
|
{
|
2002-03-06 07:48:55 +00:00
|
|
|
// doesn't make sense to set the scheme of a jar: URL
|
|
|
|
return NS_ERROR_FAILURE;
|
2000-05-17 07:12:40 +00:00
|
|
|
}
|
|
|
|
|
1999-11-07 21:55:12 +00:00
|
|
|
NS_IMETHODIMP
|
2002-03-06 07:48:55 +00:00
|
|
|
nsJARURI::GetUserPass(nsACString &aUserPass)
|
1999-11-07 21:55:12 +00:00
|
|
|
{
|
2002-03-06 07:48:55 +00:00
|
|
|
return NS_ERROR_FAILURE;
|
1999-11-07 21:55:12 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2002-03-06 07:48:55 +00:00
|
|
|
nsJARURI::SetUserPass(const nsACString &aUserPass)
|
1999-11-07 21:55:12 +00:00
|
|
|
{
|
2000-01-27 08:57:14 +00:00
|
|
|
return NS_ERROR_FAILURE;
|
1999-11-07 21:55:12 +00:00
|
|
|
}
|
|
|
|
|
2000-02-03 03:44:22 +00:00
|
|
|
NS_IMETHODIMP
|
2002-03-06 07:48:55 +00:00
|
|
|
nsJARURI::GetUsername(nsACString &aUsername)
|
2000-02-03 03:44:22 +00:00
|
|
|
{
|
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2002-03-06 07:48:55 +00:00
|
|
|
nsJARURI::SetUsername(const nsACString &aUsername)
|
2000-02-03 03:44:22 +00:00
|
|
|
{
|
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2002-03-06 07:48:55 +00:00
|
|
|
nsJARURI::GetPassword(nsACString &aPassword)
|
2000-02-03 03:44:22 +00:00
|
|
|
{
|
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2002-03-06 07:48:55 +00:00
|
|
|
nsJARURI::SetPassword(const nsACString &aPassword)
|
2000-02-03 03:44:22 +00:00
|
|
|
{
|
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
}
|
|
|
|
|
1999-11-07 21:55:12 +00:00
|
|
|
NS_IMETHODIMP
|
2002-03-06 07:48:55 +00:00
|
|
|
nsJARURI::GetHostPort(nsACString &aHostPort)
|
1999-11-07 21:55:12 +00:00
|
|
|
{
|
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2002-03-06 07:48:55 +00:00
|
|
|
nsJARURI::SetHostPort(const nsACString &aHostPort)
|
1999-11-07 21:55:12 +00:00
|
|
|
{
|
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2002-03-06 07:48:55 +00:00
|
|
|
nsJARURI::GetHost(nsACString &aHost)
|
1999-11-07 21:55:12 +00:00
|
|
|
{
|
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2002-03-06 07:48:55 +00:00
|
|
|
nsJARURI::SetHost(const nsACString &aHost)
|
1999-11-07 21:55:12 +00:00
|
|
|
{
|
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsJARURI::GetPort(PRInt32 *aPort)
|
|
|
|
{
|
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsJARURI::SetPort(PRInt32 aPort)
|
|
|
|
{
|
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2002-03-06 07:48:55 +00:00
|
|
|
nsJARURI::GetPath(nsACString &aPath)
|
1999-11-07 21:55:12 +00:00
|
|
|
{
|
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2002-03-06 07:48:55 +00:00
|
|
|
nsJARURI::SetPath(const nsACString &aPath)
|
1999-11-07 21:55:12 +00:00
|
|
|
{
|
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
}
|
|
|
|
|
2002-03-06 07:48:55 +00:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsJARURI::GetAsciiSpec(nsACString &aSpec)
|
|
|
|
{
|
|
|
|
return GetSpec(aSpec);
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsJARURI::GetAsciiHost(nsACString &aHost)
|
|
|
|
{
|
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsJARURI::GetOriginCharset(nsACString &aOriginCharset)
|
|
|
|
{
|
|
|
|
aOriginCharset.Truncate();
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
1999-11-07 21:55:12 +00:00
|
|
|
NS_IMETHODIMP
|
2000-01-27 08:57:14 +00:00
|
|
|
nsJARURI::Equals(nsIURI *other, PRBool *result)
|
1999-11-07 21:55:12 +00:00
|
|
|
{
|
2000-01-27 08:57:14 +00:00
|
|
|
nsresult rv;
|
|
|
|
*result = PR_FALSE;
|
|
|
|
|
2000-06-16 07:47:46 +00:00
|
|
|
if (other == nsnull)
|
|
|
|
return NS_OK; // not equal
|
|
|
|
|
2001-12-06 01:20:33 +00:00
|
|
|
nsCOMPtr<nsIJARURI> otherJAR(do_QueryInterface(other, &rv));
|
2000-01-27 08:57:14 +00:00
|
|
|
if (NS_FAILED(rv))
|
|
|
|
return NS_OK; // not equal
|
|
|
|
|
|
|
|
nsCOMPtr<nsIURI> otherJARFile;
|
|
|
|
rv = otherJAR->GetJARFile(getter_AddRefs(otherJARFile));
|
|
|
|
if (NS_FAILED(rv)) return rv;
|
|
|
|
|
|
|
|
PRBool equal;
|
|
|
|
rv = mJARFile->Equals(otherJARFile, &equal);
|
|
|
|
if (NS_FAILED(rv)) return rv;
|
|
|
|
if (!equal)
|
|
|
|
return NS_OK; // not equal
|
|
|
|
|
2002-03-06 07:48:55 +00:00
|
|
|
nsCAutoString otherJAREntry;
|
|
|
|
rv = otherJAR->GetJAREntry(otherJAREntry);
|
2000-01-27 08:57:14 +00:00
|
|
|
if (NS_FAILED(rv)) return rv;
|
|
|
|
|
2002-03-06 07:48:55 +00:00
|
|
|
*result = (strcmp(mJAREntry.get(), otherJAREntry.get()) == 0);
|
2000-01-27 08:57:14 +00:00
|
|
|
return NS_OK;
|
1999-11-07 21:55:12 +00:00
|
|
|
}
|
|
|
|
|
2001-01-31 01:33:03 +00:00
|
|
|
NS_IMETHODIMP
|
2001-03-13 02:01:07 +00:00
|
|
|
nsJARURI::SchemeIs(const char *i_Scheme, PRBool *o_Equals)
|
2001-01-31 01:33:03 +00:00
|
|
|
{
|
|
|
|
NS_ENSURE_ARG_POINTER(o_Equals);
|
2001-03-13 02:01:07 +00:00
|
|
|
if (!i_Scheme) return NS_ERROR_INVALID_ARG;
|
|
|
|
|
|
|
|
if (*i_Scheme == 'j' || *i_Scheme == 'J') {
|
|
|
|
*o_Equals = PL_strcasecmp("jar", i_Scheme) ? PR_FALSE : PR_TRUE;
|
|
|
|
} else {
|
|
|
|
*o_Equals = PR_FALSE;
|
|
|
|
}
|
2001-01-31 01:33:03 +00:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
1999-11-07 21:55:12 +00:00
|
|
|
NS_IMETHODIMP
|
2000-01-27 08:57:14 +00:00
|
|
|
nsJARURI::Clone(nsIURI **result)
|
1999-11-07 21:55:12 +00:00
|
|
|
{
|
2000-01-27 08:57:14 +00:00
|
|
|
nsresult rv;
|
|
|
|
|
|
|
|
nsCOMPtr<nsIURI> newJARFile;
|
|
|
|
rv = mJARFile->Clone(getter_AddRefs(newJARFile));
|
|
|
|
if (NS_FAILED(rv)) return rv;
|
|
|
|
|
|
|
|
nsJARURI* uri = new nsJARURI();
|
|
|
|
if (uri == nsnull)
|
|
|
|
return NS_ERROR_OUT_OF_MEMORY;
|
|
|
|
|
|
|
|
NS_ADDREF(uri);
|
|
|
|
uri->mJARFile = newJARFile;
|
2002-03-06 07:48:55 +00:00
|
|
|
uri->mJAREntry = mJAREntry;
|
2000-01-27 08:57:14 +00:00
|
|
|
*result = uri;
|
|
|
|
|
|
|
|
return NS_OK;
|
1999-11-07 21:55:12 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2002-03-06 07:48:55 +00:00
|
|
|
nsJARURI::Resolve(const nsACString &relativePath, nsACString &result)
|
1999-11-07 21:55:12 +00:00
|
|
|
{
|
2000-01-27 08:57:14 +00:00
|
|
|
nsresult rv;
|
2000-06-07 09:07:10 +00:00
|
|
|
|
2003-07-09 01:35:35 +00:00
|
|
|
rv = net_ExtractURLScheme(relativePath, nsnull, nsnull, nsnull);
|
2000-06-07 09:07:10 +00:00
|
|
|
if (NS_SUCCEEDED(rv)) {
|
|
|
|
// then aSpec is absolute
|
2002-03-06 07:48:55 +00:00
|
|
|
result = relativePath;
|
2000-06-07 09:07:10 +00:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2000-01-27 08:57:14 +00:00
|
|
|
nsCAutoString path(mJAREntry);
|
2003-03-15 20:00:20 +00:00
|
|
|
PRInt32 pos = 0;
|
|
|
|
|
|
|
|
char first = relativePath.Length() > 0 ? relativePath.First() : '#';
|
2000-01-27 08:57:14 +00:00
|
|
|
|
2003-03-15 20:00:20 +00:00
|
|
|
switch (first) {
|
|
|
|
case '/':
|
|
|
|
path = "";
|
|
|
|
break;
|
|
|
|
case '?':
|
|
|
|
case '#':
|
|
|
|
pos = path.RFindChar(first);
|
|
|
|
if (pos >= 0)
|
|
|
|
path.Truncate(pos);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
pos = path.RFindChar('/');
|
|
|
|
if (pos >= 0)
|
|
|
|
path.Truncate(pos + 1);
|
|
|
|
else
|
|
|
|
path = "";
|
|
|
|
}
|
2002-03-06 07:48:55 +00:00
|
|
|
nsCAutoString resolvedEntry;
|
2002-09-13 19:32:45 +00:00
|
|
|
rv = net_ResolveRelativePath(relativePath, path,
|
|
|
|
resolvedEntry);
|
2000-01-27 08:57:14 +00:00
|
|
|
if (NS_FAILED(rv)) return rv;
|
|
|
|
|
2002-03-06 07:48:55 +00:00
|
|
|
return FormatSpec(resolvedEntry, result);
|
1999-11-07 21:55:12 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
Bit checkin for bug 68045, r/sr=waterson&shaver, second attempt. It all works
for me on optimized and debug gcc2.96, rh7.1.
- Better failure codes from nsXULPrototypeScript::Deserialize.
- Call nsXULDocument::AbortFastLoads after nsXULPrototypeScript::Serialize
failure, instead of just nulling the FastLoad service's output stream.
- Expose nsXULDocument::AbortFastLoads via nsIXULPrototypeCache, for use from
nsChromeProtocolHandler.cpp. AbortFastLoads flushes the XUL cache now, for
good measure.
- The needless "Current" adjective in nsIFastLoadService attribute and method
names is no more.
- Add a do_GetFastLoadService() helper, to use CID instead of contractid, and
to let the compiler consolidate the static inline CID.
- Add "nglayout.debug.checksum_xul_fastload_file" pref so people can do without
the checksum verification step when reading a FastLoad file.
- Verify the FastLoad file checksum, by default. Also, cache it in the FastLoad
service so we don't recompute it when re-opening the FastLoad file as mailnews
and other top-levels start up. Fill the checksum cache in EndFastLoad, when
the last pseudo-concurrent top-level finishes loading.
My hope to compute the checksum while writing the FastLoad file ran afoul of
misordered writes. The old code to checksum the in-memory nsFastLoadHeader
also was broken on little endian platforms. Now all checksumming is done via
a separate read pass over the complete file, save for the header's checksum
field, which is summed as if it contained zero.
- Track and check FastLoad file dependencies. This required groveling with a
bunch of Necko interfaces in nsChromeProtocolHandler::NewChannel -- read it
and weep. Dependency checking, as well as checksum access and computation,
use better-factored nsIFastLoad{File,Read,Write}Control interfaces.
- nsBufferedStream::Seek wasn't flushing the buffer when seeking backward
within the buffer, but it must, because mCursor bounds the amount to write
if the buffer contains the end of file.
- Add an unbufferedStream readonly attribute to nsIStreamBufferAccess, so we
don't have to screw around with the bufferying layer when checksumming. Also
implement nsIStreamBufferAccess in nsBufferedOutputStream.
- nsISeekableOutputStream was bogus, based on a bad state I had put the
nsBufferedOutputStream code in on its way from being completely broken when
you seek backwards outside of the buffer. Removing this interface required
using nsIFastLoadFileIO in nsFastLoadFileWriter, and it also required careful
ordering of Close calls (the Reader must close after the Writer or Updater,
so that the Reader's underlying, unbuffered input stream can be read by
nsFastLoadFileWriter::Close to compute the checksum.
- Miscellaneous tab/indentation, comment typo, bracing, if( => if ( style,
nsnull vs. 0, useless variable elimination, tortured control flow,
AutoString instead of String, and gratuitous ; after nsISupportsUtils.h
macro call cleanups.
2001-08-21 20:51:34 +00:00
|
|
|
// nsIJARURI methods:
|
1999-11-07 21:55:12 +00:00
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2000-01-27 08:57:14 +00:00
|
|
|
nsJARURI::GetJARFile(nsIURI* *jarFile)
|
1999-11-07 21:55:12 +00:00
|
|
|
{
|
2000-01-27 08:57:14 +00:00
|
|
|
*jarFile = mJARFile;
|
|
|
|
NS_ADDREF(*jarFile);
|
1999-11-07 21:55:12 +00:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2000-01-27 08:57:14 +00:00
|
|
|
nsJARURI::SetJARFile(nsIURI* jarFile)
|
1999-11-07 21:55:12 +00:00
|
|
|
{
|
2000-01-27 08:57:14 +00:00
|
|
|
mJARFile = jarFile;
|
1999-11-07 21:55:12 +00:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2002-03-06 07:48:55 +00:00
|
|
|
nsJARURI::GetJAREntry(nsACString &entryPath)
|
1999-11-07 21:55:12 +00:00
|
|
|
{
|
2002-03-06 07:48:55 +00:00
|
|
|
// trim off any trailing ref, query, or param
|
|
|
|
PRInt32 pos = mJAREntry.RFindCharInSet("#?;");
|
|
|
|
if (pos < 0)
|
|
|
|
pos = mJAREntry.Length();
|
|
|
|
entryPath = Substring(mJAREntry, 0, pos);
|
|
|
|
return NS_OK;
|
1999-11-07 21:55:12 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2002-03-06 07:48:55 +00:00
|
|
|
nsJARURI::SetJAREntry(const nsACString &entryPath)
|
1999-11-07 21:55:12 +00:00
|
|
|
{
|
2002-03-06 07:48:55 +00:00
|
|
|
mJAREntry.Truncate();
|
2000-01-27 08:57:14 +00:00
|
|
|
|
2002-09-13 19:32:45 +00:00
|
|
|
return net_ResolveRelativePath(entryPath,
|
|
|
|
NS_LITERAL_CSTRING(""),
|
|
|
|
mJAREntry);
|
1999-11-07 21:55:12 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
////////////////////////////////////////////////////////////////////////////////
|