зеркало из https://github.com/mozilla/pjs.git
Fixes for bugs #3779,#2784. Member initialization of nsFileURL for windows compiler, escaping of url when made from path or spec, add file:// on macintosh when making a url from a spec. [bugs introduced when, for dp, I changed nsFilePath not to escape]. a=chofmann.
This commit is contained in:
Родитель
d7b5d09fd7
Коммит
296a662cd4
|
@ -255,7 +255,7 @@ class NS_BASE nsFileSpec
|
||||||
long parID,
|
long parID,
|
||||||
ConstStr255Param name);
|
ConstStr255Param name);
|
||||||
nsFileSpec(const FSSpec& inSpec)
|
nsFileSpec(const FSSpec& inSpec)
|
||||||
: mSpec(inSpec), mError(NS_OK) {}
|
: mSpec(inSpec), mError(NS_OK), mPath(nsnull) {}
|
||||||
void operator = (const FSSpec& inSpec)
|
void operator = (const FSSpec& inSpec)
|
||||||
{ mSpec = inSpec; mError = NS_OK; }
|
{ mSpec = inSpec; mError = NS_OK; }
|
||||||
|
|
||||||
|
|
|
@ -22,7 +22,6 @@
|
||||||
#include "FullPath.h"
|
#include "FullPath.h"
|
||||||
#include "FileCopy.h"
|
#include "FileCopy.h"
|
||||||
#include "MoreFilesExtras.h"
|
#include "MoreFilesExtras.h"
|
||||||
#include "nsEscape.h"
|
|
||||||
|
|
||||||
#include <Aliases.h>
|
#include <Aliases.h>
|
||||||
#include <Folders.h>
|
#include <Folders.h>
|
||||||
|
@ -917,7 +916,7 @@ nsFilePath::nsFilePath(const char* inString, PRBool inCreateDirs)
|
||||||
, mFileSpec(inString, inCreateDirs)
|
, mFileSpec(inString, inCreateDirs)
|
||||||
{
|
{
|
||||||
// Make canonical and absolute.
|
// Make canonical and absolute.
|
||||||
char * path = MacFileHelpers::PathNameFromFSSpec( mFileSpec, TRUE );
|
char * path = MacFileHelpers::PathNameFromFSSpec( mFileSpec, true );
|
||||||
mPath = MacFileHelpers::EncodeMacPath(path, true, false);
|
mPath = MacFileHelpers::EncodeMacPath(path, true, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -928,7 +927,7 @@ nsFilePath::nsFilePath(const nsString& inString, PRBool inCreateDirs)
|
||||||
, mFileSpec(nsAutoCString(inString), inCreateDirs)
|
, mFileSpec(nsAutoCString(inString), inCreateDirs)
|
||||||
{
|
{
|
||||||
// Make canonical and absolute.
|
// Make canonical and absolute.
|
||||||
char * path = MacFileHelpers::PathNameFromFSSpec( mFileSpec, TRUE );
|
char * path = MacFileHelpers::PathNameFromFSSpec( mFileSpec, true );
|
||||||
mPath = MacFileHelpers::EncodeMacPath(path, true, false);
|
mPath = MacFileHelpers::EncodeMacPath(path, true, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -952,7 +951,7 @@ nsFilePath::nsFilePath(const nsFileURL& inOther)
|
||||||
void nsFilePath::operator = (const nsFileSpec& inSpec)
|
void nsFilePath::operator = (const nsFileSpec& inSpec)
|
||||||
//----------------------------------------------------------------------------------------
|
//----------------------------------------------------------------------------------------
|
||||||
{
|
{
|
||||||
char * path = MacFileHelpers::PathNameFromFSSpec( inSpec.mSpec, TRUE );
|
char * path = MacFileHelpers::PathNameFromFSSpec( inSpec.mSpec, true );
|
||||||
delete [] mPath;
|
delete [] mPath;
|
||||||
mPath = MacFileHelpers::EncodeMacPath(path, true, false);
|
mPath = MacFileHelpers::EncodeMacPath(path, true, false);
|
||||||
mFileSpec = inSpec;
|
mFileSpec = inSpec;
|
||||||
|
@ -1032,8 +1031,17 @@ void nsFileURL::operator = (const nsFileSpec& inOther)
|
||||||
{
|
{
|
||||||
mFileSpec = inOther;
|
mFileSpec = inOther;
|
||||||
delete [] mURL;
|
delete [] mURL;
|
||||||
char* path = MacFileHelpers::PathNameFromFSSpec( mFileSpec, TRUE );
|
char* path = MacFileHelpers::PathNameFromFSSpec( mFileSpec, true );
|
||||||
mURL = MacFileHelpers::EncodeMacPath(path, true, true);
|
char* encodedPath = MacFileHelpers::EncodeMacPath(path, true, true);
|
||||||
|
char* encodedURL = nsFileSpecHelpers::AllocCat(kFileURLPrefix, encodedPath);
|
||||||
|
delete [] encodedPath;
|
||||||
|
if (encodedURL[strlen(encodedURL) - 1] != '/' && inOther.IsDirectory())
|
||||||
|
{
|
||||||
|
mURL = nsFileSpecHelpers::AllocCat(encodedURL, "/");
|
||||||
|
delete [] encodedURL;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
mURL = encodedURL;
|
||||||
} // nsFileURL::operator =
|
} // nsFileURL::operator =
|
||||||
|
|
||||||
//----------------------------------------------------------------------------------------
|
//----------------------------------------------------------------------------------------
|
||||||
|
|
|
@ -62,38 +62,41 @@ NS_BASE char* nsEscape(const char * str, nsEscapeMask mask)
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------------------------
|
//----------------------------------------------------------------------------------------
|
||||||
NS_BASE char* nsEscapeCount(const char * str, PRInt32 len, nsEscapeMask mask, PRInt32 * out_len)
|
NS_BASE char* nsEscapeCount(
|
||||||
|
const char * str,
|
||||||
|
PRInt32 len,
|
||||||
|
nsEscapeMask mask,
|
||||||
|
PRInt32* out_len)
|
||||||
//----------------------------------------------------------------------------------------
|
//----------------------------------------------------------------------------------------
|
||||||
{
|
{
|
||||||
int32 i, extra = 0;
|
if (!str)
|
||||||
char *hexChars = "0123456789ABCDEF";
|
return 0;
|
||||||
|
|
||||||
if(!str)
|
int i, extra = 0;
|
||||||
return(0);
|
char* hexChars = "0123456789ABCDEF";
|
||||||
|
|
||||||
register const unsigned char* src = (unsigned char *) str;
|
register const unsigned char* src = (const unsigned char *) str;
|
||||||
for (i = 0; i < len; i++)
|
for (i = 0; i < len; i++)
|
||||||
{
|
{
|
||||||
if (!IS_OK(src[i]))
|
if (!IS_OK(*src++))
|
||||||
extra+=2; /* the escape, plus an extra byte for each nibble */
|
extra += 2; /* the escape, plus an extra byte for each nibble */
|
||||||
}
|
}
|
||||||
|
|
||||||
char* result = new char[len + extra + 1];
|
char* result = new char[len + extra + 1];
|
||||||
if (!result)
|
if (!result)
|
||||||
return(0);
|
return 0;
|
||||||
|
|
||||||
register unsigned char* dst = (unsigned char *) result;
|
register unsigned char* dst = (unsigned char *) result;
|
||||||
|
src = (const unsigned char *) str;
|
||||||
|
if (mask == url_XPAlphas)
|
||||||
|
{
|
||||||
for (i = 0; i < len; i++)
|
for (i = 0; i < len; i++)
|
||||||
{
|
{
|
||||||
unsigned char c = src[i];
|
unsigned char c = *src++;
|
||||||
if (IS_OK(c))
|
if (IS_OK(c))
|
||||||
{
|
|
||||||
*dst++ = c;
|
*dst++ = c;
|
||||||
}
|
else if (c == ' ')
|
||||||
else if (mask == url_XPAlphas && c == ' ')
|
|
||||||
{
|
|
||||||
*dst++ = '+'; /* convert spaces to pluses */
|
*dst++ = '+'; /* convert spaces to pluses */
|
||||||
}
|
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
*dst++ = HEX_ESCAPE;
|
*dst++ = HEX_ESCAPE;
|
||||||
|
@ -101,6 +104,22 @@ NS_BASE char* nsEscapeCount(const char * str, PRInt32 len, nsEscapeMask mask, PR
|
||||||
*dst++ = hexChars[c & 0x0f]; /* low nibble */
|
*dst++ = hexChars[c & 0x0f]; /* low nibble */
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
for (i = 0; i < len; i++)
|
||||||
|
{
|
||||||
|
unsigned char c = *src++;
|
||||||
|
if (IS_OK(c))
|
||||||
|
*dst++ = c;
|
||||||
|
else
|
||||||
|
{
|
||||||
|
*dst++ = HEX_ESCAPE;
|
||||||
|
*dst++ = hexChars[c >> 4]; /* high nibble */
|
||||||
|
*dst++ = hexChars[c & 0x0f]; /* low nibble */
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
*dst = '\0'; /* tack on eos */
|
*dst = '\0'; /* tack on eos */
|
||||||
if(out_len)
|
if(out_len)
|
||||||
|
@ -125,9 +144,7 @@ NS_BASE PRInt32 nsUnescapeCount(char * str)
|
||||||
|
|
||||||
while (*src)
|
while (*src)
|
||||||
if (*src != HEX_ESCAPE)
|
if (*src != HEX_ESCAPE)
|
||||||
{
|
|
||||||
*dst++ = *src++;
|
*dst++ = *src++;
|
||||||
}
|
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
src++; /* walk over escape */
|
src++; /* walk over escape */
|
||||||
|
@ -145,7 +162,6 @@ NS_BASE PRInt32 nsUnescapeCount(char * str)
|
||||||
}
|
}
|
||||||
|
|
||||||
*dst = 0;
|
*dst = 0;
|
||||||
|
|
||||||
return (int)(dst - str);
|
return (int)(dst - str);
|
||||||
|
|
||||||
} /* NET_UnEscapeCnt */
|
} /* NET_UnEscapeCnt */
|
||||||
|
|
|
@ -20,6 +20,7 @@
|
||||||
|
|
||||||
#include "nsFileStream.h"
|
#include "nsFileStream.h"
|
||||||
#include "nsDebug.h"
|
#include "nsDebug.h"
|
||||||
|
#include "nsEscape.h"
|
||||||
|
|
||||||
#include "prtypes.h"
|
#include "prtypes.h"
|
||||||
#include "plstr.h"
|
#include "plstr.h"
|
||||||
|
@ -345,17 +346,19 @@ nsFileURL::nsFileURL(const nsFileURL& inOther)
|
||||||
//----------------------------------------------------------------------------------------
|
//----------------------------------------------------------------------------------------
|
||||||
nsFileURL::nsFileURL(const nsFilePath& inOther)
|
nsFileURL::nsFileURL(const nsFilePath& inOther)
|
||||||
//----------------------------------------------------------------------------------------
|
//----------------------------------------------------------------------------------------
|
||||||
: mURL(nsFileSpecHelpers::AllocCat(kFileURLPrefix, (const char*)inOther))
|
: mURL(nsnull)
|
||||||
{
|
{
|
||||||
|
*this = inOther;
|
||||||
} // nsFileURL::nsFileURL
|
} // nsFileURL::nsFileURL
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef XP_MAC
|
#ifndef XP_MAC
|
||||||
//----------------------------------------------------------------------------------------
|
//----------------------------------------------------------------------------------------
|
||||||
nsFileURL::nsFileURL(const nsFileSpec& inOther)
|
nsFileURL::nsFileURL(const nsFileSpec& inOther)
|
||||||
: mURL(nsFileSpecHelpers::AllocCat(kFileURLPrefix, (const char*)nsFilePath(inOther)))
|
: mURL(nsnull)
|
||||||
//----------------------------------------------------------------------------------------
|
//----------------------------------------------------------------------------------------
|
||||||
{
|
{
|
||||||
|
*this = inOther;
|
||||||
} // nsFileURL::nsFileURL
|
} // nsFileURL::nsFileURL
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -392,7 +395,20 @@ void nsFileURL::operator = (const nsFilePath& inOther)
|
||||||
//----------------------------------------------------------------------------------------
|
//----------------------------------------------------------------------------------------
|
||||||
{
|
{
|
||||||
delete [] mURL;
|
delete [] mURL;
|
||||||
mURL = nsFileSpecHelpers::AllocCat(kFileURLPrefix, (const char*)inOther);
|
char* original = (char*)(const char*)inOther; // we shall modify, but restore.
|
||||||
|
#ifdef XP_PC
|
||||||
|
// because we don't want to escape the '|' character, change it to a letter.
|
||||||
|
NS_ASSERTION(original[2] == '|', "No drive letter part!");
|
||||||
|
original[2] = 'x';
|
||||||
|
char* escapedPath = nsEscape(original, url_Path);
|
||||||
|
original[2] = '|'; // restore it
|
||||||
|
escapedPath[2] = '|';
|
||||||
|
#else
|
||||||
|
char* escapedPath = nsEscape(original, url_Path);
|
||||||
|
#endif
|
||||||
|
if (escapedPath)
|
||||||
|
mURL = nsFileSpecHelpers::AllocCat(kFileURLPrefix, escapedPath);
|
||||||
|
delete [] escapedPath;
|
||||||
} // nsFileURL::operator =
|
} // nsFileURL::operator =
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -401,8 +417,7 @@ void nsFileURL::operator = (const nsFilePath& inOther)
|
||||||
void nsFileURL::operator = (const nsFileSpec& inOther)
|
void nsFileURL::operator = (const nsFileSpec& inOther)
|
||||||
//----------------------------------------------------------------------------------------
|
//----------------------------------------------------------------------------------------
|
||||||
{
|
{
|
||||||
delete [] mURL;
|
*this = nsFilePath(inOther);
|
||||||
mURL = nsFileSpecHelpers::AllocCat(kFileURLPrefix, (const char*)nsFilePath(inOther));
|
|
||||||
} // nsFileURL::operator =
|
} // nsFileURL::operator =
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
@ -62,38 +62,41 @@ NS_BASE char* nsEscape(const char * str, nsEscapeMask mask)
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------------------------
|
//----------------------------------------------------------------------------------------
|
||||||
NS_BASE char* nsEscapeCount(const char * str, PRInt32 len, nsEscapeMask mask, PRInt32 * out_len)
|
NS_BASE char* nsEscapeCount(
|
||||||
|
const char * str,
|
||||||
|
PRInt32 len,
|
||||||
|
nsEscapeMask mask,
|
||||||
|
PRInt32* out_len)
|
||||||
//----------------------------------------------------------------------------------------
|
//----------------------------------------------------------------------------------------
|
||||||
{
|
{
|
||||||
int32 i, extra = 0;
|
if (!str)
|
||||||
char *hexChars = "0123456789ABCDEF";
|
return 0;
|
||||||
|
|
||||||
if(!str)
|
int i, extra = 0;
|
||||||
return(0);
|
char* hexChars = "0123456789ABCDEF";
|
||||||
|
|
||||||
register const unsigned char* src = (unsigned char *) str;
|
register const unsigned char* src = (const unsigned char *) str;
|
||||||
for (i = 0; i < len; i++)
|
for (i = 0; i < len; i++)
|
||||||
{
|
{
|
||||||
if (!IS_OK(src[i]))
|
if (!IS_OK(*src++))
|
||||||
extra+=2; /* the escape, plus an extra byte for each nibble */
|
extra += 2; /* the escape, plus an extra byte for each nibble */
|
||||||
}
|
}
|
||||||
|
|
||||||
char* result = new char[len + extra + 1];
|
char* result = new char[len + extra + 1];
|
||||||
if (!result)
|
if (!result)
|
||||||
return(0);
|
return 0;
|
||||||
|
|
||||||
register unsigned char* dst = (unsigned char *) result;
|
register unsigned char* dst = (unsigned char *) result;
|
||||||
|
src = (const unsigned char *) str;
|
||||||
|
if (mask == url_XPAlphas)
|
||||||
|
{
|
||||||
for (i = 0; i < len; i++)
|
for (i = 0; i < len; i++)
|
||||||
{
|
{
|
||||||
unsigned char c = src[i];
|
unsigned char c = *src++;
|
||||||
if (IS_OK(c))
|
if (IS_OK(c))
|
||||||
{
|
|
||||||
*dst++ = c;
|
*dst++ = c;
|
||||||
}
|
else if (c == ' ')
|
||||||
else if (mask == url_XPAlphas && c == ' ')
|
|
||||||
{
|
|
||||||
*dst++ = '+'; /* convert spaces to pluses */
|
*dst++ = '+'; /* convert spaces to pluses */
|
||||||
}
|
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
*dst++ = HEX_ESCAPE;
|
*dst++ = HEX_ESCAPE;
|
||||||
|
@ -101,6 +104,22 @@ NS_BASE char* nsEscapeCount(const char * str, PRInt32 len, nsEscapeMask mask, PR
|
||||||
*dst++ = hexChars[c & 0x0f]; /* low nibble */
|
*dst++ = hexChars[c & 0x0f]; /* low nibble */
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
for (i = 0; i < len; i++)
|
||||||
|
{
|
||||||
|
unsigned char c = *src++;
|
||||||
|
if (IS_OK(c))
|
||||||
|
*dst++ = c;
|
||||||
|
else
|
||||||
|
{
|
||||||
|
*dst++ = HEX_ESCAPE;
|
||||||
|
*dst++ = hexChars[c >> 4]; /* high nibble */
|
||||||
|
*dst++ = hexChars[c & 0x0f]; /* low nibble */
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
*dst = '\0'; /* tack on eos */
|
*dst = '\0'; /* tack on eos */
|
||||||
if(out_len)
|
if(out_len)
|
||||||
|
@ -125,9 +144,7 @@ NS_BASE PRInt32 nsUnescapeCount(char * str)
|
||||||
|
|
||||||
while (*src)
|
while (*src)
|
||||||
if (*src != HEX_ESCAPE)
|
if (*src != HEX_ESCAPE)
|
||||||
{
|
|
||||||
*dst++ = *src++;
|
*dst++ = *src++;
|
||||||
}
|
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
src++; /* walk over escape */
|
src++; /* walk over escape */
|
||||||
|
@ -145,7 +162,6 @@ NS_BASE PRInt32 nsUnescapeCount(char * str)
|
||||||
}
|
}
|
||||||
|
|
||||||
*dst = 0;
|
*dst = 0;
|
||||||
|
|
||||||
return (int)(dst - str);
|
return (int)(dst - str);
|
||||||
|
|
||||||
} /* NET_UnEscapeCnt */
|
} /* NET_UnEscapeCnt */
|
||||||
|
|
|
@ -20,6 +20,7 @@
|
||||||
|
|
||||||
#include "nsFileStream.h"
|
#include "nsFileStream.h"
|
||||||
#include "nsDebug.h"
|
#include "nsDebug.h"
|
||||||
|
#include "nsEscape.h"
|
||||||
|
|
||||||
#include "prtypes.h"
|
#include "prtypes.h"
|
||||||
#include "plstr.h"
|
#include "plstr.h"
|
||||||
|
@ -345,17 +346,19 @@ nsFileURL::nsFileURL(const nsFileURL& inOther)
|
||||||
//----------------------------------------------------------------------------------------
|
//----------------------------------------------------------------------------------------
|
||||||
nsFileURL::nsFileURL(const nsFilePath& inOther)
|
nsFileURL::nsFileURL(const nsFilePath& inOther)
|
||||||
//----------------------------------------------------------------------------------------
|
//----------------------------------------------------------------------------------------
|
||||||
: mURL(nsFileSpecHelpers::AllocCat(kFileURLPrefix, (const char*)inOther))
|
: mURL(nsnull)
|
||||||
{
|
{
|
||||||
|
*this = inOther;
|
||||||
} // nsFileURL::nsFileURL
|
} // nsFileURL::nsFileURL
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef XP_MAC
|
#ifndef XP_MAC
|
||||||
//----------------------------------------------------------------------------------------
|
//----------------------------------------------------------------------------------------
|
||||||
nsFileURL::nsFileURL(const nsFileSpec& inOther)
|
nsFileURL::nsFileURL(const nsFileSpec& inOther)
|
||||||
: mURL(nsFileSpecHelpers::AllocCat(kFileURLPrefix, (const char*)nsFilePath(inOther)))
|
: mURL(nsnull)
|
||||||
//----------------------------------------------------------------------------------------
|
//----------------------------------------------------------------------------------------
|
||||||
{
|
{
|
||||||
|
*this = inOther;
|
||||||
} // nsFileURL::nsFileURL
|
} // nsFileURL::nsFileURL
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -392,7 +395,20 @@ void nsFileURL::operator = (const nsFilePath& inOther)
|
||||||
//----------------------------------------------------------------------------------------
|
//----------------------------------------------------------------------------------------
|
||||||
{
|
{
|
||||||
delete [] mURL;
|
delete [] mURL;
|
||||||
mURL = nsFileSpecHelpers::AllocCat(kFileURLPrefix, (const char*)inOther);
|
char* original = (char*)(const char*)inOther; // we shall modify, but restore.
|
||||||
|
#ifdef XP_PC
|
||||||
|
// because we don't want to escape the '|' character, change it to a letter.
|
||||||
|
NS_ASSERTION(original[2] == '|', "No drive letter part!");
|
||||||
|
original[2] = 'x';
|
||||||
|
char* escapedPath = nsEscape(original, url_Path);
|
||||||
|
original[2] = '|'; // restore it
|
||||||
|
escapedPath[2] = '|';
|
||||||
|
#else
|
||||||
|
char* escapedPath = nsEscape(original, url_Path);
|
||||||
|
#endif
|
||||||
|
if (escapedPath)
|
||||||
|
mURL = nsFileSpecHelpers::AllocCat(kFileURLPrefix, escapedPath);
|
||||||
|
delete [] escapedPath;
|
||||||
} // nsFileURL::operator =
|
} // nsFileURL::operator =
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -401,8 +417,7 @@ void nsFileURL::operator = (const nsFilePath& inOther)
|
||||||
void nsFileURL::operator = (const nsFileSpec& inOther)
|
void nsFileURL::operator = (const nsFileSpec& inOther)
|
||||||
//----------------------------------------------------------------------------------------
|
//----------------------------------------------------------------------------------------
|
||||||
{
|
{
|
||||||
delete [] mURL;
|
*this = nsFilePath(inOther);
|
||||||
mURL = nsFileSpecHelpers::AllocCat(kFileURLPrefix, (const char*)nsFilePath(inOther));
|
|
||||||
} // nsFileURL::operator =
|
} // nsFileURL::operator =
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
@ -255,7 +255,7 @@ class NS_BASE nsFileSpec
|
||||||
long parID,
|
long parID,
|
||||||
ConstStr255Param name);
|
ConstStr255Param name);
|
||||||
nsFileSpec(const FSSpec& inSpec)
|
nsFileSpec(const FSSpec& inSpec)
|
||||||
: mSpec(inSpec), mError(NS_OK) {}
|
: mSpec(inSpec), mError(NS_OK), mPath(nsnull) {}
|
||||||
void operator = (const FSSpec& inSpec)
|
void operator = (const FSSpec& inSpec)
|
||||||
{ mSpec = inSpec; mError = NS_OK; }
|
{ mSpec = inSpec; mError = NS_OK; }
|
||||||
|
|
||||||
|
|
|
@ -22,7 +22,6 @@
|
||||||
#include "FullPath.h"
|
#include "FullPath.h"
|
||||||
#include "FileCopy.h"
|
#include "FileCopy.h"
|
||||||
#include "MoreFilesExtras.h"
|
#include "MoreFilesExtras.h"
|
||||||
#include "nsEscape.h"
|
|
||||||
|
|
||||||
#include <Aliases.h>
|
#include <Aliases.h>
|
||||||
#include <Folders.h>
|
#include <Folders.h>
|
||||||
|
@ -917,7 +916,7 @@ nsFilePath::nsFilePath(const char* inString, PRBool inCreateDirs)
|
||||||
, mFileSpec(inString, inCreateDirs)
|
, mFileSpec(inString, inCreateDirs)
|
||||||
{
|
{
|
||||||
// Make canonical and absolute.
|
// Make canonical and absolute.
|
||||||
char * path = MacFileHelpers::PathNameFromFSSpec( mFileSpec, TRUE );
|
char * path = MacFileHelpers::PathNameFromFSSpec( mFileSpec, true );
|
||||||
mPath = MacFileHelpers::EncodeMacPath(path, true, false);
|
mPath = MacFileHelpers::EncodeMacPath(path, true, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -928,7 +927,7 @@ nsFilePath::nsFilePath(const nsString& inString, PRBool inCreateDirs)
|
||||||
, mFileSpec(nsAutoCString(inString), inCreateDirs)
|
, mFileSpec(nsAutoCString(inString), inCreateDirs)
|
||||||
{
|
{
|
||||||
// Make canonical and absolute.
|
// Make canonical and absolute.
|
||||||
char * path = MacFileHelpers::PathNameFromFSSpec( mFileSpec, TRUE );
|
char * path = MacFileHelpers::PathNameFromFSSpec( mFileSpec, true );
|
||||||
mPath = MacFileHelpers::EncodeMacPath(path, true, false);
|
mPath = MacFileHelpers::EncodeMacPath(path, true, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -952,7 +951,7 @@ nsFilePath::nsFilePath(const nsFileURL& inOther)
|
||||||
void nsFilePath::operator = (const nsFileSpec& inSpec)
|
void nsFilePath::operator = (const nsFileSpec& inSpec)
|
||||||
//----------------------------------------------------------------------------------------
|
//----------------------------------------------------------------------------------------
|
||||||
{
|
{
|
||||||
char * path = MacFileHelpers::PathNameFromFSSpec( inSpec.mSpec, TRUE );
|
char * path = MacFileHelpers::PathNameFromFSSpec( inSpec.mSpec, true );
|
||||||
delete [] mPath;
|
delete [] mPath;
|
||||||
mPath = MacFileHelpers::EncodeMacPath(path, true, false);
|
mPath = MacFileHelpers::EncodeMacPath(path, true, false);
|
||||||
mFileSpec = inSpec;
|
mFileSpec = inSpec;
|
||||||
|
@ -1032,8 +1031,17 @@ void nsFileURL::operator = (const nsFileSpec& inOther)
|
||||||
{
|
{
|
||||||
mFileSpec = inOther;
|
mFileSpec = inOther;
|
||||||
delete [] mURL;
|
delete [] mURL;
|
||||||
char* path = MacFileHelpers::PathNameFromFSSpec( mFileSpec, TRUE );
|
char* path = MacFileHelpers::PathNameFromFSSpec( mFileSpec, true );
|
||||||
mURL = MacFileHelpers::EncodeMacPath(path, true, true);
|
char* encodedPath = MacFileHelpers::EncodeMacPath(path, true, true);
|
||||||
|
char* encodedURL = nsFileSpecHelpers::AllocCat(kFileURLPrefix, encodedPath);
|
||||||
|
delete [] encodedPath;
|
||||||
|
if (encodedURL[strlen(encodedURL) - 1] != '/' && inOther.IsDirectory())
|
||||||
|
{
|
||||||
|
mURL = nsFileSpecHelpers::AllocCat(encodedURL, "/");
|
||||||
|
delete [] encodedURL;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
mURL = encodedURL;
|
||||||
} // nsFileURL::operator =
|
} // nsFileURL::operator =
|
||||||
|
|
||||||
//----------------------------------------------------------------------------------------
|
//----------------------------------------------------------------------------------------
|
||||||
|
|
Загрузка…
Ссылка в новой задаче