OWLNext 7.0
Borland's Object Windows Library for the modern age
|
The TFileName class constructs filenames. More...
#include <owl/filename.h>
Public Types | |
enum | TSpecialType { TempFile , TempDir , CurrentDir , BootDir , MachineDir , HomeDir , SharedDir , SysDir , ComputerName } |
Construct a filename representing a special file or directory. More... | |
enum | TPart { Server = 1 , Device = 2 , Path = 4 , File = 8 , Ext =16 } |
Obtain any combination of various filename parts. More... | |
enum | { ReplaceExisting =1 , CopyAllowed =2 , DelayUntilReboot =4 } |
Public Member Functions | |
TFileName () | |
Constructs an empty filename. | |
TFileName (LPCTSTR serverName, LPCTSTR shareOrDeviceName, LPCTSTR path, LPCTSTR file, LPCTSTR ext) | |
Constructs a filename from its parts. | |
TFileName (LPCTSTR freeform, bool pathOnly=false) | |
Construct a filename given the full path in any form. | |
TFileName (const tstring &freeform, bool pathOnly=false) | |
Construct a filename given the full path in any form. | |
TFileName (const TFileName &src) | |
Constructs a filename from another filename. | |
TFileName & | operator= (const TFileName &src) |
Assigns new filename or freeform to this name. | |
TFileName & | operator= (const tstring &src) |
Assigns new filename or freeform to this name. | |
TFileName & | operator= (LPCTSTR src) |
Assigns new filename or freeform to this name. | |
TFileName (TSpecialType type) | |
Construct a filename representing a special file or directory. | |
tchar * | GetNameNoExt () |
tchar * | GetNameAndExt () const |
tchar * | GetFullFileName () |
tchar * | GetFullFileNameNoExt () |
void | FormCanonicalName () |
const tstring & | Canonical (bool forceUNC=false) const |
Return normal fully qualified path string. | |
const tchar * | CanonicalStr (bool forceUNC=false) const |
const tchar * | ShortName (bool forceUNC=false) const |
Returns the short file path. | |
const tchar * | Title () const |
The Title member function uses system conventions to get a human-readable rendering of the filename appropriate for use in titles. | |
const tchar * | Squeezed (int maxLen, bool keepName=true) const |
Obtains a human-readable form of the filename. | |
const tchar * | GetParts (uint p) const |
Reassembles any logical subset of filename parts. | |
bool | HasParts (uint p) const |
Returns true if any of the parts specified by p are used. | |
TFileName & | SetPart (uint p, const tstring &partStr) |
Replaces the specified filename parts with parts extracted from partStr. | |
TFileName & | MergeParts (uint p, const TFileName &source) |
Replaces the specified parts in this with the parts from source. | |
TFileName & | StripParts (uint p) |
Removes the specified filename parts from this set of parts. | |
TFileName & | AddSubDir (const tstring &subdir) |
bool | IsValid () const |
Determines whether a filename is valid. | |
bool | IsUNC () const |
Determines whether the name is UNC format as opposed to a logical-drive based machine. | |
bool | Exists () const |
Determines whether the device, directory, or file exists. | |
bool | operator== (const TFileName &other) const |
Returns true if this filename is canonically equal to other. | |
bool | Remove () const |
Deletes this file associated with this name if possible; otherwise attempts to delete the directory associated with this name (which must be empty). | |
bool | Move (const TFileName &newName, uint32 how=CopyAllowed) |
Move (rename) the file associated with this filename, and change this name to the new name. | |
bool | Copy (const TFileName &newName, bool failIfExists) const |
Copy the file associated with this filename to a new file. | |
int | ChangeDir () const |
Changes the current directory to the directory associated with this filename. | |
int | CreateDir () const |
Creates the directory associated with this filename. | |
int | GetStatus (TFileStatus &status) const |
Get the file status struct for the item associated with this filename. | |
int | SetStatus (const TFileStatus &status) |
Fills the status structure for the file associated with this filename with information from status. | |
Static Public Member Functions | |
static LPCTSTR | WildName () |
General wildstring. | |
static LPCTSTR | WildPart (uint) |
Part specific? | |
Protected Member Functions | |
void | Parse (LPCTSTR freeform, bool pathOnly=false) |
Parses the freeform string into the filename parts. | |
Protected Attributes | |
tstring | ServerStr |
Holds the server filename part. | |
tstring | DeviceStr |
Holds the device filename part. | |
tstring | PathStr |
Holds the path filename part. | |
tstring | FileStr |
Holds the file filename part (no extension). | |
tstring | ExtStr |
Holds the extension filename part. | |
tstring | FullCanonicalName |
tchar | NameBuffer [_MAX_PATH] |
bool | Unc |
true if UNC naming convention in use; false otherwise. | |
The TFileName class constructs filenames.
Definition at line 37 of file filename.h.
Enumerator | |
---|---|
ReplaceExisting | |
CopyAllowed | |
DelayUntilReboot |
Definition at line 153 of file filename.h.
Obtain any combination of various filename parts.
Seperators inserted only as appropriate
Enumerator | |
---|---|
Server | Server name. |
Device | Logical device or sharename. |
Path | Directory path to the file. |
File | Filename part without the extension. |
Ext | Extension. |
Definition at line 125 of file filename.h.
Construct a filename representing a special file or directory.
Definition at line 91 of file filename.h.
owl::TFileName::TFileName | ( | ) |
Constructs an empty filename.
Definition at line 225 of file filename.cpp.
owl::TFileName::TFileName | ( | LPCTSTR | serverName, |
LPCTSTR | deviceName, | ||
LPCTSTR | path, | ||
LPCTSTR | file, | ||
LPCTSTR | ext ) |
Constructs a filename from its parts.
Use 0 to skip any of the parameters. The form is:
where:
Definition at line 264 of file filename.cpp.
References DeviceStr, ExtStr, FileStr, FormCanonicalName(), PathStr, ServerStr, and Unc.
Construct a filename given the full path in any form.
Definition at line 362 of file filename.cpp.
References Parse().
Construct a filename given the full path in any form.
Definition at line 371 of file filename.cpp.
References Parse().
owl::TFileName::TFileName | ( | const TFileName & | src | ) |
Constructs a filename from another filename.
Definition at line 232 of file filename.cpp.
References FormCanonicalName().
owl::TFileName::TFileName | ( | TFileName::TSpecialType | type | ) |
Construct a filename representing a special file or directory.
The parameter type can be specified from TSpecialType.
Definition at line 383 of file filename.cpp.
References _T, _tcscat, BootDir, ComputerName, CurrentDir, HomeDir, MachineDir, Parse(), SharedDir, SysDir, TempDir, TempFile, and WIN95_LONGFILENAME_MAX.
Definition at line 962 of file filename.cpp.
References _tcschr, FormCanonicalName(), and PathStr.
Return normal fully qualified path string.
Convert a possibly logical drive based name to a UNC name if indicated.
Definition at line 520 of file filename.cpp.
References FullCanonicalName.
Definition at line 252 of file filename.h.
References Canonical().
int owl::TFileName::ChangeDir | ( | ) | const |
Changes the current directory to the directory associated with this filename.
Returns a non-zero value on success. Call LastError for extended information.
Definition at line 956 of file filename.cpp.
References CanonicalStr().
Copy the file associated with this filename to a new file.
If failIfExists is true, the copy will not take place if a file newName already exists.
Definition at line 934 of file filename.cpp.
References CanonicalStr().
int owl::TFileName::CreateDir | ( | ) | const |
Creates the directory associated with this filename.
Returns a non-zero value on success. Call LastError for extended information.
Definition at line 945 of file filename.cpp.
References CanonicalStr().
bool owl::TFileName::Exists | ( | ) | const |
Determines whether the device, directory, or file exists.
Definition at line 735 of file filename.cpp.
References _USES_CONVERSION, _W2A, Canonical(), and CanonicalStr().
void owl::TFileName::FormCanonicalName | ( | ) |
Definition at line 493 of file filename.cpp.
References _T, _tcscmp, Device, Ext, File, FullCanonicalName, GetParts(), NameBuffer, Path, Server, and WIN95_LONGFILENAME_MAX.
tchar * owl::TFileName::GetFullFileName | ( | ) |
Definition at line 482 of file filename.cpp.
References CanonicalStr().
tchar * owl::TFileName::GetFullFileNameNoExt | ( | ) |
Definition at line 535 of file filename.cpp.
References Device, File, GetParts(), Path, and Server.
tchar * owl::TFileName::GetNameAndExt | ( | ) | const |
Definition at line 530 of file filename.cpp.
References Ext, File, and GetParts().
tchar * owl::TFileName::GetNameNoExt | ( | ) |
Definition at line 525 of file filename.cpp.
References File, and GetParts().
Reassembles any logical subset of filename parts.
More than one part can be checked for by bitwise oring in the parameter p. See TFileName::TPart.
Definition at line 759 of file filename.cpp.
References _tcscat, Device, DeviceStr, Ext, ExtStr, File, FileStr, NameBuffer, Path, PathStr, Server, ServerStr, and Unc.
int owl::TFileName::GetStatus | ( | TFileStatus & | status | ) | const |
Get the file status struct for the item associated with this filename.
Definition at line 1012 of file filename.cpp.
References _tcscpy, Canonical(), and owl::TFileStatus::fullName.
|
inline |
Determines whether the name is UNC format as opposed to a logical-drive based machine.
Definition at line 247 of file filename.h.
References Unc.
bool owl::TFileName::IsValid | ( | ) | const |
Determines whether a filename is valid.
Definition at line 723 of file filename.cpp.
References _USES_CONVERSION, _W2A, and CanonicalStr().
Replaces the specified parts in this with the parts from source.
More than one part can be merged by bitwise oring in the parameter p. See TFileName::TPart.
Definition at line 853 of file filename.cpp.
References Device, DeviceStr, Ext, ExtStr, File, FileStr, FormCanonicalName(), Path, PathStr, Server, and ServerStr.
bool owl::TFileName::Move | ( | const TFileName & | newName, |
uint32 | how = CopyAllowed ) |
Move (rename) the file associated with this filename, and change this name to the new name.
Under WinNT how is used to specifie how the file is to be copied:
Definition at line 917 of file filename.cpp.
References CanonicalStr().
Assigns new filename or freeform to this name.
Definition at line 451 of file filename.cpp.
References DeviceStr, ExtStr, FileStr, FormCanonicalName(), PathStr, ServerStr, and Unc.
Assigns new filename or freeform to this name.
Definition at line 226 of file filename.h.
References Parse().
Assigns new filename or freeform to this name.
Definition at line 233 of file filename.h.
References Parse().
Returns true if this filename is canonically equal to other.
Definition at line 240 of file filename.h.
References _tcsicmp, and CanonicalStr().
Parses the freeform string into the filename parts.
Definition at line 283 of file filename.cpp.
References _T, DeviceStr, ExtStr, FileStr, FormCanonicalName(), PathStr, owl::serverNamePrefixLen, ServerStr, and Unc.
bool owl::TFileName::Remove | ( | ) | const |
Deletes this file associated with this name if possible; otherwise attempts to delete the directory associated with this name (which must be empty).
Definition at line 899 of file filename.cpp.
References CanonicalStr().
Replaces the specified filename parts with parts extracted from partStr.
More than one part can be checked for by bitwise oring in the parameter p. See TFileName::TPart.
Definition at line 831 of file filename.cpp.
References Device, DeviceStr, Ext, ExtStr, File, FileStr, FormCanonicalName(), Path, PathStr, Server, and ServerStr.
int owl::TFileName::SetStatus | ( | const TFileStatus & | status | ) |
Fills the status structure for the file associated with this filename with information from status.
Definition at line 1034 of file filename.cpp.
References owl::__attr2Sys(), owl::TFileStatus::accessTime, owl::TFileStatus::attribute, Canonical(), owl::TFileStatus::createTime, File, owl::TFileStatus::modifyTime, owl::TFile::OpenExisting, owl::TFile::PermExclusive, owl::TFileStatus::size, TYPESAFE_DOWNCAST, WARN, and owl::TFile::WriteOnly.
Returns the short file path.
Convert a possibly logical drive based name to a UNC name if indicated.
Definition at line 547 of file filename.cpp.
References _tcscpy, CanonicalStr(), NameBuffer, and WIN95_LONGFILENAME_MAX.
Obtains a human-readable form of the filename.
The name length is at most maxLen characters.
Definition at line 682 of file filename.cpp.
References _MAX_PATH, _T, _tcscpy, CHECK, Device, GetParts(), NameBuffer, PathStr, Server, and Title().
Removes the specified filename parts from this set of parts.
More than one part can be checked for by bitwise oring in the parameter p. See TFileName::TPart.
Definition at line 877 of file filename.cpp.
References _T, Device, DeviceStr, Ext, ExtStr, File, FileStr, FormCanonicalName(), Path, PathStr, Server, and ServerStr.
const tchar * owl::TFileName::Title | ( | ) | const |
The Title member function uses system conventions to get a human-readable rendering of the filename appropriate for use in titles.
Definition at line 563 of file filename.cpp.
References _T, _tcscpy, Canonical(), COUNTOF, NameBuffer, and WIN95_LONGFILENAME_MAX.
|
protected |
Holds the device filename part.
Definition at line 45 of file filename.h.
|
protected |
Holds the extension filename part.
Definition at line 54 of file filename.h.
|
protected |
Holds the file filename part (no extension).
Definition at line 51 of file filename.h.
|
protected |
Definition at line 56 of file filename.h.
Definition at line 57 of file filename.h.
|
mutableprotected |
Holds the path filename part.
Definition at line 48 of file filename.h.
|
protected |
Holds the server filename part.
Definition at line 42 of file filename.h.
|
protected |
true if UNC naming convention in use; false otherwise.
Definition at line 60 of file filename.h.