About
A maxon::Url defines the location of a file or a similar resource. The class allows to construct a file path and to handle files. maxon::Url is based on maxon::UrlInterface.
- Note
- To convert a maxon::Url to a Filename use MaxonConvert().
Construction
A maxon::Url can be constructed with:
#define DiagnosticOutput(formatString,...)
Definition: debugdiagnostics.h:176
#define iferr_return
Definition: resultbase.h:1465
Various default folders can be obtained from the maxon::Application class:
See also Application Manual.
Scheme
An URL can reference files on the file system, web addresses, files within ZIP files, etc. The scheme defines what kind of object a given maxon::Url is referencing:
The supported maxon::UrlScheme types are:
const maxon::Url url {
"file:///c:/folder/file.txt"_s };
static const Id URLSCHEME_FILESYSTEM
Scheme identifier for generic file system access.
Definition: url.h:681
Parts
An maxon::Url is composed of several parts. These parts can be accessed individually:
const maxon::String authority = url.GetAuthority().ToString(
nullptr);
const maxon::String directory = url.GetDirectory().ToString(
nullptr);
const char const char * name
Definition: abstract.h:195
Definition: string.h:1235
File Functions
The maxon::Url class contains several functions to analyse and handle files:
{
}
@ SHOW_IN_EXPLORER
Show the url in the windows explorer or osx finder.
@ NONEXISTENT
Url doesn't exist.
{
const maxon::IoBrowseRef& browseDirectory = (it)
iferr_return;
const maxon::Url url = browseDirectory.GetCurrentPath();
continue;
if (url.CheckSuffix("exr"_s))
{
}
}
return OK
Definition: apibase.h:2667
@ NONE
No flags specified.
@ DIRECTORY
Url is a directory, you can use GetBrowseIterator to iterate through the children.
Streams
Data streams are used to write into and read from a resource defined with a maxon::Url:
See also maxon::IoFileOutputHelper and maxon::IoFileInputHelper.
For details on input/output streams see InputStream Manual and OutputStream Manual.
{
}
PyCompilerFlags * flags
Definition: ast.h:14
Definition: basearray.h:412
static MAXON_METHOD Result< void > ReadFileToMemory(UrlOrInputStream &&name, WritableArrayInterface< Char > &arr)
PyObject * stream
Definition: codecs.h:186
@ SEEK_TO_END
Sets the file handle to the end of file after opening. To append to the end of a file use WRITE_DONT_...
@ WRITE_DONT_TRUNCATE
Allows to write to existing files without truncation, so the existing file is kept as is.
if (isHTTP || isHTTPS)
{
const maxon::InputStreamRef inputStream = webFile.OpenInputStream()
iferr_return;
const maxon::OutputStreamRef outputStream = localFile.OpenOutputStream()
iferr_return;
}
ResultMem Resize(Int newCnt, COLLECTION_RESIZE_FLAGS resizeFlags=COLLECTION_RESIZE_FLAGS::DEFAULT)
Definition: basearray.h:1369
Definition: apibaseid.h:253
bool Bool
boolean type, possible values are only false/true, 8 bit
Definition: apibase.h:181
int64_t Int64
64 bit signed integer datatype.
Definition: apibase.h:178
static const Id URLSCHEME_HTTPS
Scheme identifier for Hypertext Transfer Protocol Secure (HTTPS) connections.
Definition: url.h:775
static const Id URLSCHEME_HTTP
Scheme identifier for Hypertext Transfer Protocol (HTTP) connections.
Definition: url.h:769
PyWideStringList Py_ssize_t length
Definition: initconfig.h:448
const maxon::InputStreamRef inputStream = webFile.OpenInputStream()
iferr_return;
if (streamSize < predictedSize)
{
}
Int64 Int
signed 32/64 bit int, size depends on the platform
Definition: apibase.h:188
Url Flags
maxon::URLFLAGS can be used to define maxon::Url attributes.
maxon::Url theServer {
"http://localhost:8080"_s };
Definition: string.h:1490
PyObject PyObject * result
Definition: abstract.h:43
#define ApplicationOutput(formatString,...)
Definition: debugdiagnostics.h:210
#define iferr(...)
Definition: errorbase.h:388
Miscellaneous
Miscellaneous functions are:
Further Reading