Main Page | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Class Members | File Members | Related Pages

FilePath Class Reference

Inheritance diagram for FilePath:

IWritable MutableFilePath List of all members.

Public Member Functions

 this (FilePath other)
 this (Uri uri)
 this (char[] filepath)
void reset ()
bool isAbsolute ()
char[] getRoot ()
char[] getPath ()
char[] getName ()
char[] getExtension ()
char[] getSuffix ()
char[] toString ()
void write (IWriter write)
IBuffer write (IBuffer buf)
MutableUri toUri ()
char[] toUtf8 ()
wchar[] toUtf16 ()
char[] splice (FilePath base)
IBuffer splice (FilePath base, IBuffer buf)
FilePath toParent ()
bool isChild ()
FilePath toSibling (char[] name)
FilePath toSibling (char[] name, char[] ext)
FilePath toSibling (char[] name, char[] ext, char[] suffix)

Static Public Member Functions

static char[] normalize (inout char[] path)

Protected Member Functions

 this ()

Private Member Functions

int locateParent ()

Private Attributes

char[] fp
char[] ext
char[] name
char[] path
char[] root
char[] suffix
wchar[] fpWide

Static Private Attributes

static const int MaxFilePathSize = 1024

Detailed Description

Models a file name. These are expected to be used as the constructor argument to File implementations. The intention is that they easily convert to other representations such as absolute, canonical, or Url. Note that this class is immutable. Use MutableFilePath if you wish to alter specific attributes.

File paths containing non-ansi characters should be UTF-8 encoded. Supporting Unicode in this manner was deemed to be more suitable than providing a wchar version of FilePath, and is both consistent & compatible with the approach taken with the Uri class.

Definition at line 64 of file FilePath.d.


Member Function Documentation

this  )  [inline, protected]
 

Create an empty FilePath. This is strictly for subclass use.

Reimplemented in MutableFilePath.

Definition at line 87 of file FilePath.d.

this FilePath  other  )  [inline]
 

Create a FilePath through reference to another.

Reimplemented in MutableFilePath.

Definition at line 97 of file FilePath.d.

References assert().

this Uri  uri  )  [inline]
 

Definition at line 117 of file FilePath.d.

References path.

this char[]  filepath  )  [inline]
 

Create a FilePath from the given string. Note the path is not duplicated here, so you are expected to provide an immutable copy for the lifetime of this object.

If you're not certain, duplicate the path first.

Reimplemented in MutableFilePath.

Definition at line 137 of file FilePath.d.

References assert().

static char [] normalize inout char[]  path  )  [inline, static]
 

Convert path separators to the correct format. This mutates the provided 'path' content, so .dup it as necessary.

Definition at line 222 of file FilePath.d.

References version.

void reset  )  [inline]
 

Definition at line 243 of file FilePath.d.

Referenced by toParent(), toSibling(), and toUtf8().

bool isAbsolute  )  [inline]
 

Returns true if this FilePath is *not* relative to the current working directory.

Definition at line 256 of file FilePath.d.

References path, and root.

Referenced by toUri().

char [] getRoot  )  [inline]
 

Return the root of this path. Roots are constructs such as "c:".

Definition at line 270 of file FilePath.d.

References root.

char [] getPath  )  [inline]
 

Return the file path. Paths start with a '/' but do not end with one. The root path is empty. Directory paths are split such that the directory name is placed into the 'name' member.

Definition at line 284 of file FilePath.d.

References path.

char [] getName  )  [inline]
 

Return the name of this file, or directory.

Definition at line 295 of file FilePath.d.

Referenced by FileScan::simpleFilter().

char [] getExtension  )  [inline]
 

Return the file-extension, sans seperator

Definition at line 306 of file FilePath.d.

Referenced by ServletResponse::copyFile(), and FileScan::simpleFilter().

char [] getSuffix  )  [inline]
 

Suffix is like extension, except it can include multiple '.' sequences. For example, "wumpus1.foo.bar" has suffix "foo.bar" and extension "bar".

Definition at line 319 of file FilePath.d.

References suffix.

char [] toString  )  [inline]
 

Convert this FilePath to a char[]. This is expected to execute optimally in most cases.

Definition at line 331 of file FilePath.d.

References Buffer, fp, MaxFilePathSize, and write().

Referenced by FileBucket::Record::eof(), FileConduit::getName(), FileProxy::toString(), and toUtf16().

void write IWriter  write  )  [inline]
 

Write this FilePath to the given IWriter. This makes the FilePath compatible with all Writers. Note that we could leverage the write(IBuffer) method here, but that would bypass any special character converters attached to the IWriter.

Reimplemented from IWritable.

Definition at line 359 of file FilePath.d.

References name, path, and root.

Referenced by splice(), and toString().

IBuffer write IBuffer  buf  )  [inline]
 

Convert this FilePath to a char[] in the provided buffer

Definition at line 380 of file FilePath.d.

MutableUri toUri  )  [inline]
 

Definition at line 405 of file FilePath.d.

References isAbsolute(), name, path, root, MutableUri::setHost(), MutableUri::setPath(), MutableUri::setScheme(), Text, and version.

char [] toUtf8  )  [inline]
 

Return a zero terminated version of this file path. Note that the compiler places a zero at the end of each static string, as does the allocator for char[] requests.

In typical usage, this will not need to duplicate the path

Definition at line 436 of file FilePath.d.

References fp, and reset().

Referenced by FileProxy::VersionPosix::createDirectory(), FileProxy::VersionWin32::createDirectory(), FileProxy::VersionPosix::createFile(), FileProxy::VersionWin32::createFile(), FileProxy::VersionPosix::getInfo(), FileProxy::VersionWin32::getInfo(), FileConduit::VersionPosix::open(), FileConduit::VersionWin32::open(), FileProxy::VersionPosix::remove(), FileProxy::VersionWin32::remove(), FileSystem::VersionPosix::setDirectory(), FileSystem::VersionWin32::setDirectory(), FileProxy::VersionPosix::toList(), and FileProxy::VersionWin32::toList().

wchar [] toUtf16  )  [inline]
 

Definition at line 451 of file FilePath.d.

References toString().

Referenced by FileProxy::VersionWin32::createDirectory(), FileProxy::VersionWin32::createFile(), FileProxy::VersionWin32::getInfo(), FileConduit::VersionWin32::open(), FileProxy::VersionWin32::remove(), FileSystem::VersionWin32::setDirectory(), and FileProxy::VersionWin32::toList().

char [] splice FilePath  base  )  [inline]
 

Splice this FilePath onto the end of the provided base path. Output is return as a char[].

Definition at line 468 of file FilePath.d.

References Buffer, and MaxFilePathSize.

IBuffer splice FilePath  base,
IBuffer  buf
[inline]
 

Splice this FilePath onto the end of the provided base path. Output is placed into the provided IBuffer.

Definition at line 480 of file FilePath.d.

References IBuffer::append(), IBuffer::getLimit(), name, path, and write().

int locateParent  )  [inline, private]
 

Find the next parent of the FilePath. Returns a valid index to the seperator when present, -1 otherwise.

Definition at line 506 of file FilePath.d.

References path.

Referenced by toParent().

FilePath toParent  )  [inline]
 

Returns a FilePath representing the parent of this one. An exception is thrown if there is not parent (at the root).

Definition at line 525 of file FilePath.d.

References FilePath, locateParent(), path, and reset().

bool isChild  )  [inline]
 

Returns true if this FilePath has a parent.

Definition at line 550 of file FilePath.d.

FilePath toSibling char[]  name  )  [inline]
 

Return a cloned FilePath with a different name.

Definition at line 561 of file FilePath.d.

Referenced by toSibling().

FilePath toSibling char[]  name,
char[]  ext
[inline]
 

Return a cloned FilePath with a different name and extension. Note that the suffix is destroyed.

Definition at line 573 of file FilePath.d.

References suffix, and toSibling().

FilePath toSibling char[]  name,
char[]  ext,
char[]  suffix
[inline]
 

Return a cloned FilePath with a different name, extension, and suffix.

Definition at line 585 of file FilePath.d.

References ext, FilePath, name, reset(), and suffix.


Member Data Documentation

char [] fp [private]
 

Definition at line 66 of file FilePath.d.

Referenced by toString(), and toUtf8().

char [] ext [private]
 

Definition at line 66 of file FilePath.d.

Referenced by toSibling().

char [] name [private]
 

Definition at line 66 of file FilePath.d.

Referenced by splice(), toSibling(), toUri(), and write().

char [] path [private]
 

Definition at line 66 of file FilePath.d.

Referenced by getPath(), isAbsolute(), locateParent(), splice(), this(), toParent(), toUri(), and write().

char [] root [private]
 

Definition at line 66 of file FilePath.d.

Referenced by getRoot(), isAbsolute(), toUri(), and write().

char [] suffix [private]
 

Definition at line 66 of file FilePath.d.

Referenced by getSuffix(), and toSibling().

wchar [] fpWide [private]
 

Definition at line 73 of file FilePath.d.

const int MaxFilePathSize = 1024 [static, private]
 

Definition at line 78 of file FilePath.d.

Referenced by splice(), and toString().


The documentation for this class was generated from the following file:
Generated on Sat Dec 24 17:28:38 2005 for Mango by  doxygen 1.4.0