home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Chip 1997 October
/
Chip_1997-10_cd.bin
/
tema
/
sybase
/
powerj
/
hpp.z
/
WFILPATH.HPP
< prev
next >
Wrap
C/C++ Source or Header
|
1997-01-22
|
8KB
|
215 lines
/* %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Copyright (C) 1995, by WATCOM International Inc. All rights %
% reserved. No part of this software may be reproduced or %
% used in any form or by any means - graphic, electronic or %
% mechanical, including photocopying, recording, taping or %
% information storage and retrieval systems - except with the %
% written permission of WATCOM International Inc. %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
*/
/*************************************************************************
*
* WFilePath
*
*************************************************************************/
#ifndef _WFILPATH_HPP_INCLUDED
#define _WFILPATH_HPP_INCLUDED
#ifndef _WNO_PRAGMA_PUSH
#pragma pack(push,8);
#pragma enum int;
#endif
#ifndef _WDEF_HPP_INCLUDED
# include "wdef.hpp"
#endif
#ifndef _WOBJECT_HPP_INCLUDED
# include "wobject.hpp"
#endif
#ifndef _WSTRING_HPP_INCLUDED
# include "wstring.hpp"
#endif
#include <stdlib.h>
#define _WFILEPATH_NONE ( 0x0 )
#define _WFILEPATH_DRIVE ( 0x1 )
#define _WFILEPATH_DIR ( 0x2 )
#define _WFILEPATH_FNAME ( 0x4 )
#define _WFILEPATH_EXT ( 0x8 )
#define _WFILEPATH_ALL ( 0xF )
class WCMCLASS WFilePath : public WString {
WDeclareSubclass( WFilePath, WString )
public:
/**********************************************************
* Constructors and Destructors
*********************************************************/
WFilePath();
WFilePath( const WChar *string, WULong numChars=USE_STR_LEN );
WFilePath( const WResourceID & id, WModuleHandle module=_ApplicationModule );
WFilePath( const WString & s, WBool makeCopy=FALSE );
WFilePath( const WFilePath & filePath );
~WFilePath();
/**********************************************************
* Properties
*********************************************************/
// AbsolutePath
//
// Convert a relative path to an absolute path. Must pass
// in a WFilePath used to determine which drive the absolute
// path refers to.
WFilePath GetAbsolutePath( const WFilePath & dir ) const;
// Directory
//
// The path (if any), always ending with a "\"
// (i.e. "\inst\" in "c:\inst\test.exe")
WBool SetDirectory( const WString & directory );
WString GetDirectory() const;
// Drive
//
// The drive (if any), including the colon
// (i.e. "c:" in "c:\inst\test.exe")
WBool SetDrive( const WString & drive );
WString GetDrive() const;
// Extension
//
// The extension (if any) including a leading period
// (i.e. ".exe" in "c:\inst\test.exe")
WBool SetExtension( const WString & extension );
WString GetExtension() const;
// FileName
//
// The name part of the file (i.e. "test" in "c:\inst\test.exe")
WBool SetFileName( const WString & fileName );
WString GetFileName() const;
// FileParts
//
// Returns a WString with the given set of file parts.
WString GetFileParts( WUInt flags=_WFILEPATH_ALL ) const;
/**********************************************************
* Methods
*********************************************************/
// Absolute
//
// Convert a relative path to an absolute path. Must pass
// in a WFilePath used to determine which drive the absolute
// path refers to. If it creates a path which cannot be
// properly cleaned, it will return an empty string.
WFilePath Absolute( const WFilePath & dir ) const;
// CleanDirectory()
//
// Removes extraneous directory separators such as
// .\, foo\..\, etc.
WBool CleanDirectory();
// Exists
//
// Checks to see if a file or directory exists. Can
// optionally return the attributes of the file.
WBool Exists( WDWord *attributes=NULL ) const;
// MakePath
//
// Rebuild the filepath out of the given parts. If NULL
// is passed, can optionally use the current part.
WBool MakePath( const WChar * drive, const WChar * path,
const WChar * name, const WChar * ext,
WUInt useCurrentIfNull=_WFILEPATH_NONE );
// Search
//
// Search for the file using the same rules used to
// load DLLs. Returns a null path if not found.
WFilePath Search() const;
/**********************************************************
* Overrides
*********************************************************/
virtual WBool SetDirty( WBool dirty=TRUE );
//
// == operator
//
friend int WEXPORT operator==( const WFilePath & a, const WFilePath & b );
friend int WEXPORT operator==( const WFilePath & a, const WString & b );
friend int WEXPORT operator==( const WFilePath & a, const WAnsiChar *b );
friend int WEXPORT operator==( const WFilePath & a, const WUnicodeChar *b );
friend int WEXPORT operator==( const WAnsiChar *a, const WFilePath & b );
friend int WEXPORT operator==( const WUnicodeChar *a, const WFilePath & b );
friend int WEXPORT operator==( const WFilePath & a, WAnsiChar *b );
friend int WEXPORT operator==( const WFilePath & a, WUnicodeChar *b );
friend int WEXPORT operator==( WAnsiChar *a, const WFilePath & b );
friend int WEXPORT operator==( WUnicodeChar *a, const WFilePath & b );
//
// != operator
//
friend int WEXPORT operator!=( const WFilePath & a, const WFilePath & b );
friend int WEXPORT operator!=( const WFilePath & a, const WString & b );
friend int WEXPORT operator!=( const WFilePath & a, const WAnsiChar *b );
friend int WEXPORT operator!=( const WFilePath & a, const WUnicodeChar *b );
friend int WEXPORT operator!=( const WAnsiChar *a, const WFilePath & b );
friend int WEXPORT operator!=( const WUnicodeChar *a, const WFilePath & b );
friend int WEXPORT operator!=( const WFilePath & a, WAnsiChar *b );
friend int WEXPORT operator!=( const WFilePath & a, WUnicodeChar *b );
friend int WEXPORT operator!=( WAnsiChar *a, const WFilePath & b );
friend int WEXPORT operator!=( WUnicodeChar *a, const WFilePath & b );
/**********************************************************
* Other
*********************************************************/
private:
WBool SplitPath();
void UpdatePath();
private:
WInt _driveEnd;
WInt _pathEnd;
WInt _nameEnd;
WInt _extEnd;
WBool _rebuilding;
};
#ifndef _WNO_PRAGMA_PUSH
#pragma enum pop;
#pragma pack(pop);
#endif
#endif // _WFILPATH_HPP_INCLUDED