File system and URLs

Files on disk, in a network or from other sources are addressed using the CCL::Url class with interface CCL::IUrl (see also CCL::UrlRef). An URL consists of a protocol, hostname, path and optional parameters.

On Windows, a file system location like C:\Users\Me\Documents is represented as file:///C:/Users/Me/Documents. You can access the file system singleton via

CCL::System::GetFileSystem (see CCL::INativeFileSystem).

The file data can be read/written with the CCL::IStream interface. The file is closed when the stream object is released.

See also Virtual File System for details about the supported protocols for files from other sources.

Example:

Url pathToFile ("file:///C:/Users/Me/Documents/data.bin");
AutoPtr<IStream> stream = System::GetFileSystem ().openStream (pathToFile, IStream::kOpenMode);

String representations of an URL

CCL::IUrl has methods for creating different string representation of an URL. Some helper classes simplifiy their use. For displaying an URL to the user, CCL::UrlFullString should be used.

Class

Shortcut for method

Description

CCL::UrlFullString

IUrl::getUrl

Full url with protocol and optionally parameters

CCL::UrlDisplayString

IUrl::toDisplayString

Beautified string for display respecting the platform conventions

CCL::NativePath

IUrl::fromNativePath

Native path string in UTF-16 enconding

CCL::POSIXPath

IUrl::toPOSIXPath

POSIX-style path (‘/’ as separator) in UTF-8 encoding

Example (Windows):

CCL::UrlFullString

file:///C:/Users/CCL/Documents/Notes.txt

CCL::UrlDisplayString

C:\Users\CCL\Documents\Notes.txt

CCL::NativePath

C:\Users\CCL\Documents\Notes.txt

CCL::POSIXPath

/C:/Users/CCL/Documents/Notes.txt