зеркало из https://github.com/mozilla/gecko-dev.git
Checking for file and directory names that may be too long for a given platform. Fixes bug 10147. r=deveditz, sr=mscott
This commit is contained in:
Родитель
f774901d29
Коммит
317db38ec6
|
@ -61,6 +61,15 @@
|
|||
|
||||
#define XPINSTALL_BUNDLE_URL "chrome://communicator/locale/xpinstall/xpinstall.properties"
|
||||
|
||||
//file and directory name length maximums
|
||||
#ifdef XP_MAC
|
||||
#define MAX_FILENAME 31
|
||||
#elif defined (XP_PC)
|
||||
#define MAX_FILENAME 128
|
||||
#elif defined (XP_UNIX)
|
||||
#define MAX_FILENAME 1024
|
||||
#endif
|
||||
|
||||
class nsInstallInfo
|
||||
{
|
||||
public:
|
||||
|
|
|
@ -109,46 +109,44 @@ nsInstallFile::nsInstallFile(nsInstall* inInstall,
|
|||
//Need to parse the inPartialPath to remove any separators
|
||||
PRBool finished = PR_FALSE;
|
||||
PRUint32 offset = 0;
|
||||
PRInt32 location = 0, pass = 0;
|
||||
PRInt32 location = 0, nodeLength = 0;
|
||||
nsString subString;
|
||||
|
||||
//nsString tempPartialPath(inPartialPath);
|
||||
location = inPartialPath.FindChar('/',PR_FALSE, offset);
|
||||
if (location == ((PRInt32)inPartialPath.mLength - 1)) //trailing slash
|
||||
{
|
||||
*error = nsInstall::INVALID_ARGUMENTS;
|
||||
return;
|
||||
}
|
||||
|
||||
while (!finished)
|
||||
{
|
||||
location = inPartialPath.FindChar('/',PR_FALSE, offset);
|
||||
if ((location < 0) && (pass == 0)) //no separators were found
|
||||
if (location == kNotFound) //no separators were found
|
||||
{
|
||||
nsAutoCString tempPartialPath(inPartialPath);
|
||||
mFinalFile->Append(tempPartialPath);
|
||||
finished = PR_TRUE;
|
||||
}
|
||||
else if ((location < 0) && (pass > 0) && (offset < inPartialPath.mLength)) //last occurance
|
||||
{
|
||||
nsresult rv = inPartialPath.Mid(subString, offset, inPartialPath.mLength-offset);
|
||||
nsAutoCString tempSubString(subString);
|
||||
mFinalFile->Append(tempSubString);
|
||||
nodeLength = inPartialPath.mLength - offset;
|
||||
finished = PR_TRUE;
|
||||
}
|
||||
else
|
||||
{
|
||||
nsresult rv = inPartialPath.Mid(subString, offset, location-offset);
|
||||
nodeLength = location - offset;
|
||||
}
|
||||
|
||||
if (nodeLength > MAX_FILENAME)
|
||||
{
|
||||
*error = nsInstall::FILENAME_TOO_LONG;
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
nsresult rv = inPartialPath.Mid(subString, offset, nodeLength);
|
||||
nsAutoCString tempSubString(subString);
|
||||
mFinalFile->Append(tempSubString);
|
||||
offset = location + 1;
|
||||
pass++;
|
||||
offset += nodeLength + 1;
|
||||
if (!finished)
|
||||
location = inPartialPath.FindChar('/',PR_FALSE, offset);
|
||||
}
|
||||
}
|
||||
|
||||
//{
|
||||
// nsresult rv = mFinalFile->Append(inPartialPath.ToNewCString());
|
||||
// if (rv != NS_OK)
|
||||
// {
|
||||
// *error = nsInstall::ILLEGAL_RELATIVE_PATH;
|
||||
// return;
|
||||
// }
|
||||
//}
|
||||
|
||||
mFinalFile->Exists(&mReplaceFile);
|
||||
mVersionRegistryName = new nsString(inComponentName);
|
||||
mJarLocation = new nsString(inJarLocation);
|
||||
|
|
Загрузка…
Ссылка в новой задаче