1998-12-08 02:15:50 +00:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
|
|
|
*
|
|
|
|
* 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.
|
|
|
|
*/
|
|
|
|
|
1998-12-08 22:45:42 +00:00
|
|
|
// This file is included by nsFileSpec.cp, and includes the Windows-specific
|
1998-12-08 02:15:50 +00:00
|
|
|
// implementations.
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------------------------
|
1998-12-08 22:45:42 +00:00
|
|
|
nsNativeFileSpec::nsNativeFileSpec(const nsFilePath& inPath)
|
1998-12-08 02:15:50 +00:00
|
|
|
//----------------------------------------------------------------------------------------
|
1998-12-09 08:47:30 +00:00
|
|
|
: mPath(NULL)
|
1998-12-08 02:15:50 +00:00
|
|
|
{
|
|
|
|
*this = inPath;
|
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------------------------
|
1998-12-08 22:45:42 +00:00
|
|
|
void nsNativeFileSpec::operator = (const nsFilePath& inPath)
|
1998-12-08 02:15:50 +00:00
|
|
|
//----------------------------------------------------------------------------------------
|
|
|
|
{
|
|
|
|
// Convert '/' to '\'
|
1998-12-11 01:42:04 +00:00
|
|
|
nsFileSpecHelpers::StringAssign(mPath, inSpec.mPath);
|
|
|
|
for (const char* cp = mPath; *cp; cp++)
|
1998-12-08 02:15:50 +00:00
|
|
|
{
|
1998-12-11 01:42:04 +00:00
|
|
|
if (*cp == '/')
|
|
|
|
*cp = '\\';
|
1998-12-08 02:15:50 +00:00
|
|
|
}
|
|
|
|
} // nsNativeFileSpec::operator =
|
|
|
|
|
1998-12-09 01:04:53 +00:00
|
|
|
//----------------------------------------------------------------------------------------
|
|
|
|
nsFilePath::nsFilePath(const nsNativeFileSpec& inSpec)
|
|
|
|
//----------------------------------------------------------------------------------------
|
1998-12-09 08:47:30 +00:00
|
|
|
: mPath(NULL)
|
1998-12-09 01:04:53 +00:00
|
|
|
{
|
1998-12-09 08:47:30 +00:00
|
|
|
*this = inSpec;
|
|
|
|
} // nsFilePath::nsFilePath
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------------------------
|
1998-12-11 01:42:04 +00:00
|
|
|
void nsFilePath::operator = (const nsNativeFileSpec& inSpec)
|
1998-12-09 08:47:30 +00:00
|
|
|
//----------------------------------------------------------------------------------------
|
|
|
|
{
|
1998-12-09 01:04:53 +00:00
|
|
|
// Convert '\' to '/'
|
1998-12-11 01:42:04 +00:00
|
|
|
nsFileSpecHelpers::StringAssign(mPath, inSpec.mPath);
|
|
|
|
for (const char* cp = mPath; *cp; cp++)
|
1998-12-09 01:04:53 +00:00
|
|
|
{
|
1998-12-11 01:42:04 +00:00
|
|
|
if (*cp == '\\')
|
|
|
|
*cp = '/';
|
1998-12-09 01:04:53 +00:00
|
|
|
}
|
1998-12-09 08:47:30 +00:00
|
|
|
} // nsFilePath::operator =
|
1998-12-09 01:04:53 +00:00
|
|
|
|
1998-12-08 02:15:50 +00:00
|
|
|
//----------------------------------------------------------------------------------------
|
1998-12-09 08:47:30 +00:00
|
|
|
void nsNativeFileSpec::SetLeafName(const char* inLeafName)
|
1998-12-08 02:15:50 +00:00
|
|
|
//----------------------------------------------------------------------------------------
|
|
|
|
{
|
1998-12-09 01:04:53 +00:00
|
|
|
nsFileSpecHelpers::LeafReplace(mPath, '\\', inLeafName);
|
1998-12-08 02:15:50 +00:00
|
|
|
} // nsNativeFileSpec::SetLeafName
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------------------------
|
1998-12-09 08:47:30 +00:00
|
|
|
const char* nsNativeFileSpec::GetLeafName() const
|
1998-12-08 02:15:50 +00:00
|
|
|
//----------------------------------------------------------------------------------------
|
|
|
|
{
|
1998-12-09 01:04:53 +00:00
|
|
|
return nsFileSpecHelpers::GetLeaf(mPath, '\\');
|
1998-12-08 02:15:50 +00:00
|
|
|
} // nsNativeFileSpec::GetLeafName
|
|
|
|
|
1998-12-09 01:04:53 +00:00
|
|
|
//----------------------------------------------------------------------------------------
|
|
|
|
bool nsNativeFileSpec::Exists() const
|
|
|
|
//----------------------------------------------------------------------------------------
|
|
|
|
{
|
|
|
|
return false; // fixme
|
|
|
|
} // nsNativeFileSpec::Exists
|
|
|
|
|