-
首页
-
C4D R23.110 C++ SDK
UrlInterface Class Reference
IO
#include <url.h>
详细描述
Interface class for Urls.
@MAXON_ANNOTATION{refclass=false}
公共成员函数
|
const
MAXON_METHOD
UrlScheme
&
|
GetScheme
() const
|
MAXON_METHOD
Result
< void >
|
SetScheme
(const
UrlScheme
&scheme)
|
MAXON_METHOD
Result
< void >
|
Append
(const
String
&name)
|
MAXON_METHOD
Result
< void >
|
Append
(const
Url
&relativeUrl)
|
MAXON_METHOD
Result
< void >
|
RemoveName
()
|
MAXON_METHOD
Url
|
GetEmbeddedUrl
() const
|
MAXON_METHOD
Result
< void >
|
SetEmbeddedUrl
(const
Url
&url)
|
MAXON_METHOD
String
|
GetName
() const
|
MAXON_METHOD
Result
< void >
|
SetName
(const
String
&name)
|
MAXON_METHOD
Url
|
GetDirectory
() const
|
MAXON_METHOD
Result
< void >
|
SetPath
(const
String
&path)
|
const
MAXON_METHOD
String
&
|
GetPath
() const
|
MAXON_METHOD
Result
< void >
|
SetSystemPath
(const
String
&path)
|
MAXON_METHOD
Result
<
String
>
|
GetSystemPath
() const
|
MAXON_METHOD
Result
< void >
|
SetUrl
(const
String
&urlString,
Bool
enableDefaultFallbackScheme)
|
MAXON_METHOD
String
|
GetUrl
() const
|
MAXON_METHOD
Result
< void >
|
SetAuthority
(const
String
&authority)
|
MAXON_METHOD
Result
< void >
|
SetAuthority
(const
Url
&authority)
|
const
MAXON_METHOD
Url
&
|
GetAuthority
() const
|
MAXON_METHOD
Result
< void >
|
GetComponents
(const
NonConstArray
<
String
> &parts) const
|
MAXON_METHOD
Result
<
Url
>
|
GetRelativeUrl
(const
Url
&basePath) const
|
MAXON_METHOD
String
|
GetSuffix
() const
|
MAXON_METHOD
Bool
|
CheckSuffix
(const
String
&suffix) const
|
MAXON_METHOD
Result
< void >
|
SetSuffix
(const
String
&suffix)
|
MAXON_METHOD
void
|
ClearSuffix
()
|
MAXON_METHOD
Bool
|
IsEmpty
() const
|
MAXON_FUNCTION
Bool
|
IsPopulated
() const
|
MAXON_METHOD
COMPARERESULT
|
比较
(const
UrlInterface
*name,
URLCOMPARE
mode=
URLCOMPARE::DEFAULT
) const
|
MAXON_METHOD
Result
<
数据
>
|
GetData
(const
ConstDataPtr
&key) const
|
MAXON_METHOD
Result
< void >
|
SetData
(
ForwardingDataPtr
&&key, const
数据
&data,
Bool
persistent=true)
|
MAXON_METHOD
Result
< void >
|
SetData
(
ForwardingDataPtr
&&key,
数据
&&data,
Bool
persistent=true)
|
MAXON_FUNCTION
IODETECT
|
IoDetect
() const
|
MAXON_FUNCTION
Result
< IoConnectionRef >
|
OpenConnection
() const
|
MAXON_FUNCTION
Result
< InputStreamRef >
|
OpenInputStream
(
OPENSTREAMFLAGS
flags=
OPENSTREAMFLAGS::NONE
) const
|
MAXON_FUNCTION
Result
< OutputStreamRef >
|
OpenOutputStream
(
OPENSTREAMFLAGS
flags=
OPENSTREAMFLAGS::NONE
) const
|
MAXON_FUNCTION
Result
< InOutputStreamRef >
|
OpenInOutputStream
(
OPENSTREAMFLAGS
flags=
OPENSTREAMFLAGS::NONE
) const
|
MAXON_FUNCTION
Result
< IoBrowseRef >
|
GetBrowseIterator
(
GETBROWSEITERATORFLAGS
flags) const
|
MAXON_FUNCTION
Result
<
IOATTRIBUTES
>
|
IoGetAttributes
() const
|
MAXON_FUNCTION
Result
< void >
|
IoSetAttributes
(
IOATTRIBUTES
flags,
IOATTRIBUTES
mask) const
|
MAXON_FUNCTION
Result
<
UniversalDateTime
>
|
IoGetTime
(
IOTIMEMODE
mode) const
|
MAXON_FUNCTION
Result
< void >
|
IoSetTime
(
IOTIMEMODE
mode, const
UniversalDateTime
&dateTime) const
|
MAXON_FUNCTION
Result
< void >
|
IoDelete
(
Bool
force,
Bool
recursive=false) const
|
MAXON_FUNCTION
Result
< void >
|
IoCreateDirectory
(
Bool
createParents,
BaseArray
<
Url
> *createdDirs=nullptr) const
|
MAXON_FUNCTION
Result
< void >
|
IoCopyFile
(const
Url
&destName,
Bool
overwrite,
Bool
removeReadOnly) const
|
MAXON_FUNCTION
Result
< void >
|
IoMove
(const
Url
&destName) const
|
MAXON_FUNCTION
Result
< void >
|
IoRename
(const
Url
&newName) const
|
MAXON_FUNCTION
Result
< void >
|
IoGetFreeVolumeSpace
(
Int64
&availableBytes,
Int64
&totalBytes) const
|
MAXON_FUNCTION
Result
< void >
|
IoShowInOS
(
IOSHOWINOSFLAGS
flags) const
|
MAXON_FUNCTION
Result
<
Url
>
|
Normalize
(
NORMALIZEFLAGS
flags=
NORMALIZEFLAGS::SCHEME_BASED
) const
|
MAXON_FUNCTION
Result
<
Url
>
|
IoNormalize
(
NORMALIZEFLAGS
flags=
NORMALIZEFLAGS::SCHEME_BASED
) const
|
MAXON_FUNCTION
Result
<
Url
>
|
operator+
(const
String
&s) const
|
MAXON_FUNCTION
Result
<
Url
>
|
operator+
(const
Url
&s) const
|
MAXON_METHOD
String
|
ToString
(const
FormatStatement
*formatStatement=nullptr) const
|
MAXON_FUNCTION
HashInt
|
GetHashCode
() const
|
Member Typedef Documentation
◆
RESTRICT_DICTIONARY_PROPS
成员函数文档编制
◆
MAXON_INTERFACE_NONVIRTUAL()
◆
GetScheme()
Gets the UrlScheme of the
Url
. Is guarantueed to be lowercase (canonical form for urls) if scheme was automatically determined through SetUrl, otherwise as set.
Urls consist of three parts: a
scheme
, an
authority
和
path
. The readable text-representation is "scheme://authority/path".
The
scheme
defines which handler is used, e.g. "http" for web-based connections or "file" for the regular file system.
The
authority
defines the machine, which can be empty for "localhost", a network drive or a webserver. It can also refer to an embedded file, e.g. a ZIP. To distinguish that case the readable text representation contains brackets: "scheme://[authority]/path". Nesting is possible repeatedly.
Finally the
path
component defines the unique location of a file or directory on the target machine. In most schemes paths are a combination of the directory path and file path, but the path could also be a network query or database entry. Path components are always separated by a forward slash and the forward slash is a reserved character that cannot be used for names.
-
返回
-
Returns the UrlScheme for the
Url
(e.g. "file", "http"). If no scheme is set the returned value is
UrlScheme()
.
◆
SetScheme()
Sets the scheme of the
Url
. Path and authority will stay unchanged.
Urls consist of three parts: a
scheme
, an
authority
和
path
. The readable text-representation is "scheme://authority/path".
The
scheme
defines which handler is used, e.g. "http" for web-based connections or "file" for the regular file system.
The
authority
defines the machine, which can be empty for "localhost", a network drive or a webserver. It can also refer to an embedded file, e.g. a ZIP. To distinguish that case the readable text representation contains brackets: "scheme://[authority]/path". Nesting is possible repeatedly.
Finally the
path
component defines the unique location of a file or directory on the target machine. In most schemes paths are a combination of the directory path and file path, but the path could also be a network query or database entry. Path components are always separated by a forward slash and the forward slash is a reserved character that cannot be used for names.
-
参数
-
[in]
|
scheme
|
The new scheme UrlScheme
Id
e.g. URLSCHEME_FILESYSTEM, URLSCHEME_ZIPFILE or URLSCHEME_MEMORY. Should always be lowercase because no normalization is applied here.
|
-
返回
-
OK on success.
◆
Append()
[1/2]
Appends a new component to the
Url
. E.g. if the
Url
is "file:///c:/directory" a call of Append("file.txt"_s) will result in "file:///c:/directory/file.txt".
-
参数
-
[in]
|
name
|
A component that will be added to the end of the
Url
. A separator (forward slash) will be placed between the end of the current
Url
and the new part. The value must not contain any forward slashes (under Windows additionally no backslashes), otherwise nothing will be done.
|
-
返回
-
*this.
@MAXON_ANNOTATION{returnsThis,noResult}
◆
Append()
[2/2]
Appends a relative
Url
to the current one. E.g. if the
Url
is "file:///c:/directory" a call of Append(
Url
("test/file.txt"_s)) will result in "file:///c:/directory/test/file.txt".
-
参数
-
[in]
|
relativeUrl
|
The relative
Url
that will be added. A separator (forward slash) will be placed between the end of the current
Url
and the new part. relativeUrl must be a
Url
with URLSCHEME_RELATIVE, otherwise nothing will be done.
|
-
返回
-
*this.
@MAXON_ANNOTATION{returnsThis,noResult}
◆
RemoveName()
Removes the last part of a
Url
. E.g. if the
Url
is "file:///c:/directory/file.txt" a call of
RemoveName()
will result in "file:///c:/directory".
-
返回
-
OK on success. Returns an error if there is nothing to remove.
◆
GetEmbeddedUrl()
Returns an embedded
Url
. E.g. if the
Url
is "zip://[file:///c:/images.zip]/image01.jpg" a call to
GetEmbeddedUrl()
will return "file:///c:/images.zip".
-
返回
-
The embedded
Url
or if there was none Url().
◆
SetEmbeddedUrl()
Replaces and sets an embedded
Url
. E.g. if the
Url
is "zip://[file:///c:/images.zip]/image01.jpg" a call to SetEmbeddedUrl("file:///c:/otherimages.zip"_s) will result in "zip://[file:///c:/otherimages.zip]/image01.jpg".
-
参数
-
[in]
|
url
|
The new embedded
Url
.
|
-
返回
-
OK on success.
◆
GetName()
Returns the name of the last component. E.g. if the
Url
is "file:///c:/directory/file.txt" a call to
GetName()
will return "file.txt".
-
返回
-
The name of the last path component.
◆
SetName()
Replaces the last component of a
Url
. The name must not contain a forward slashes and under Windows additionally no backslashes. E.g. if the
Url
is "file:///c:/directory/file.txt" a call of SetName("change.tif"_s) will result in "file:///c:/directory/change.tif".
-
参数
-
-
返回
-
OK on success.
◆
GetDirectory()
Returns the
Url
of the directory. If the
Url
is empty the directory is empty as well. E.g. if the
Url
was "file:///c:/directory/file.txt" a call of
GetDirectory()
will return "file:///c:/directory".
-
返回
-
The directory
Url
.
◆
SetPath()
Replaces the path component of the
Url
. The path is stored unchanged with the exception that under Windows all backslashes will be changed into forward slashes.
-
参数
-
-
返回
-
OK on success.
◆
GetPath()
Returns the path component of the
Url
. Note that this doesn't contain scheme and authority. E.g. if the
Url
is "file:///c:/directory/file.txt" a call will return "c:/directory/file.txt".
-
返回
-
The path component of the
Url
(with no authority and scheme).
◆
SetSystemPath()
Stores a system path in a
Url
. This call needs to be done after the appropriate scheme has been set. If no scheme is set URLSCHEME_FILESYSTEM will be automatically set. The system path may be converted to a different internal representation, e.g. split into authority and path components. Under Windows all backslashes will be changed into forward slashes.
-
参数
-
[in]
|
path
|
The system path.
|
-
返回
-
OK on success.
◆
GetSystemPath()
Returns a path from the
Url
that the current operating system (or scheme handler) can understand. If the
Url
contains no valid scheme an error will be returned. An error will also be returned if the
Url
contains illegal characters for the scheme, e.g. backslashes on Windows in a file scheme.
-
返回
-
The system path.
◆
SetUrl()
设置
Url
. The scheme is detected automatically and converted to the canonical lowercase version (as described in rfc3986#3.1). If a scheme isn't found and enableDefaultFallbackScheme is false the function returns an IllegalArgumentError, otherwise URLSCHEME_FILESYSTEM will be assumed (or URLSCHEME_RELATIVE if 'urlString' starts with no drive letter). Please note that Urls only use forward slashes as delimiter, backslashes are considered to be a part of names and not a delimiter. '?' will be considered as the start of URLFLAGS::QUERY parameters. Everything behin the '?' will be placed in that property. Use url.Get(URLFLAGS::QUERY) to get the query parameters.
-
参数
-
[in]
|
urlString
|
新的
Url
to be set.
|
[in]
|
enableDefaultFallbackScheme
|
If false and no scheme is set an error will be returned.
|
-
返回
-
OK on success.
◆
GetUrl()
Returns the
Url
as a string. A
Url
has the format scheme://authority/path.
-
返回
-
The
Url
as a string.
◆
SetAuthority()
[1/2]
Sets the authority of a
Url
. This can be a machine or server.
-
参数
-
[in]
|
authority
|
The new authority.
String()
can be passed for no authority / localhost. The authority scheme will be URLSCHEME_AUTHORITY.
|
-
返回
-
OK on success.
◆
SetAuthority()
[2/2]
Sets the authority of a
Url
. This can be a machine, server or embedded file. Url() can be passed for no authority.
-
参数
-
[in]
|
authority
|
The new authority. Can be a machine, server or embedded file.
|
-
返回
-
OK on success.
◆
GetAuthority()
Returns the authority of a
Url
. The authority can be a machine, server or embedded file.
-
返回
-
The authority of the
Url
. If the machine is localhost the returned
Url
is empty. If it is a machine or server the scheme will be URLSCHEME_AUTHORITY. Otherwise it defines an embedded file.
◆
GetComponents()
Returns all parts of the
Url
system path as separated strings. E.g. if the
Url
was "file:///c:/directory/file.txt" a call of GetComponents will return: { "C:", "directory", "file.txt" }.
-
参数
-
[out]
|
parts
|
Array
with the parts of the system path. A possible authority will be returned as the first part of the array.
|
-
返回
-
OK on success.
◆
GetRelativeUrl()
Returns a relative url based on the given basePath. The basePath needs to have the same scheme, authority. basepath needs to be part of the path of this url.
-
参数
-
[in]
|
basePath
|
The base of the relative url.
|
-
返回
-
Returns the relative url on success.
◆
GetSuffix()
Returns the suffix of the
Url
. E.g. if the
Url
was "file:///c:/directory/file.txt" a call of
GetSuffix()
will return "txt".
-
返回
-
The suffix without dot.
◆
CheckSuffix()
Checks whether the
Url
has the a given suffix E.g. if the
Url
is "file:///c:/directory/file.txt" a call of CheckSuffix("txt"_s) will return true.
-
参数
-
[in]
|
suffix
|
The suffix without dot to check against.
|
-
返回
-
True if the suffix matches.
◆
SetSuffix()
Replaces the suffix of the
Url
. If the
Url
had no suffix before a dot will be added together with the suffix string. E.g. if the
Url
is "file:///c:/directory/file.txt" a call of SetSuffix("jpg"_s) will result in "file:///c:/directory/file.jpg".
-
参数
-
[in]
|
suffix
|
The new suffix of the
Url
without dot.
|
-
返回
-
OK on success.
◆
ClearSuffix()
Deletes the suffix of the
Url
. E.g. if the
Url
was "file:///c:/directory/file.txt" a call will result in "file:///c:/directory/file".
◆
IsEmpty()
Returns if the
Url
has no content. A
Url
is considered empty if it has no path component and no authority (even if a scheme is set).
-
返回
-
True if the
Url
is empty.
@MAXON_ANNOTATION{default=true}
◆
IsPopulated()
Returns if the
Url
has any content. A
Url
is considered populated if it has a path component or authority set.
-
返回
-
True if the
Url
has content.
◆
Compare()
Compares the object against 'name'. Note that by default the comparison is case-sensitive, so './Test.tif' and './test.tif' are not the same. To check if Urls point to the identical item use Url::IoNormalizeAndResolve instead.
-
参数
-
[in]
|
name
|
Comparison object.
|
[in]
|
mode
|
Comparision mode.
|
-
返回
-
The comparison result.
◆
GetData()
返回
Url
attributes. See
maxon::URLFLAGS
了解细节。
-
参数
-
[in]
|
key
|
The id of the property to get. The possible values for id depend on the scheme.
|
-
返回
-
The attribute value or an error if there was none.
◆
SetData()
[1/2]
Modifies or sets a
Url
attribute. See
maxon::URLFLAGS
了解细节。
-
参数
-
[in]
|
key
|
The id of the property to set. The possible values for id depend on the scheme.
|
[in]
|
data
|
数据
to be set.
|
[in]
|
persistent
|
With the default value of true the attribute value is serialized. Use false for a transient attribute (one which shall not be serialized).
|
-
返回
-
OK on success.
◆
SetData()
[2/2]
Modifies or sets a
Url
attribute. See
maxon::URLFLAGS
了解细节。
-
参数
-
[in]
|
key
|
The id of the property to set. The possible values for id depend on the scheme.
|
[in]
|
data
|
数据
to be set.
|
[in]
|
persistent
|
With the default value of true the attribute value is serialized. Use false for a transient attribute (one which shall not be serialized).
|
-
返回
-
OK on success.
◆
IoDetect()
Detects the type of the object behind
Url
. This allows to check if a file or directory exists.
-
返回
-
IODETECT of the given
Url
.
◆
OpenConnection()
Returns a pointer to a
IoConnectionInterface
class of this
Url
.
-
返回
-
The pointer to the
IoConnectionInterface
. The return value needs to be checked against nullptr. @MAXON_ANNOTATION{incompleteReturnType=true}
◆
OpenInputStream()
Returns a pointer to a
InputStreamInterface
class of this
Url
.
-
参数
-
[in]
|
flags
|
See OPENSTREAMFLAGS for details.
|
-
返回
-
The pointer to the
InputStreamInterface
. The return value needs to be checked against nullptr. @MAXON_ANNOTATION{incompleteReturnType=true}
◆
OpenOutputStream()
Returns a pointer to a
OutputStreamInterface
class of this
Url
.
-
参数
-
[in]
|
flags
|
See OPENSTREAMFLAGS for details.
|
-
返回
-
The pointer to the
OutputStreamInterface
. The return value needs to be checked against nullptr. @MAXON_ANNOTATION{incompleteReturnType=true}
◆
OpenInOutputStream()
Returns a pointer to a
InOutputStreamInterface
class of this
Url
.
-
参数
-
[in]
|
flags
|
See OPENSTREAMFLAGS for details.
|
-
返回
-
The pointer to the
InOutputStreamInterface
. The return value needs to be checked against nullptr. @MAXON_ANNOTATION{incompleteReturnType=true}
◆
GetBrowseIterator()
Returns a IoBrowseIterator to browse through all children of an
Url
.
Example 1: If you want to catch all errors like opening the directory and error when going next file.
Url path(
URLSCHEME_FILESYSTEM
);
path.SetPath(
"h:/testdir"
_s);
for
(
const
auto
& it : path.GetBrowseIterator(
GETBROWSEITERATORFLAGS::NONE
))
{
// it's essential that error checking happens here at this point.
// this error can be opening the directory as well as browsing to the next file.
const
IoBrowseRef& browseRef = (it)
iferr_return
;
// do anything like browseRef.GetCurrentPath();
}
-
参数
-
[in]
|
flags
|
See GETBROWSEITERATORFLAGS.
|
-
返回
-
IoBrowseIterator object. @MAXON_ANNOTATION{incompleteReturnType=true}
◆
IoGetAttributes()
Returns the file attributes of the object behind
Url
.
-
返回
-
IOATTRIBUTES of the file.
◆
IoSetAttributes()
Modify the file attributes of the object behind
Url
.
-
参数
-
[in]
|
flags
|
Flags to set/clear.
|
[in]
|
mask
|
Mask with all flags to be changed.
|
-
返回
-
OK on success.
◆
IoGetTime()
Returns the
DateTime
of the current file. The time is in local time.
-
参数
-
[in]
|
mode
|
IOTIMEMODE of the requested time.
|
-
返回
-
Returns the
DateTime
or an error. @MAXON_ANNOTATION{incompleteReturnType=true}
◆
IoSetTime()
Modifies the
DateTime
of the current file. The time is in local time.
-
参数
-
[in]
|
mode
|
IOTIMEMODE of the requested time.
|
[in]
|
dateTime
|
The new datetime for the file.
|
-
返回
-
OK on success.
◆
IoDelete()
Deletes a file or directory physically on the medium.
-
参数
-
[in]
|
force
|
Set to true tries to deletes the file/directory even if the file/directory has read only flags set.
|
[in]
|
recursive
|
Recursively deletes a directory and its content. If a file is specified this value is ignored.
|
-
返回
-
Set to true if the file/directory could be removed successfully.
◆
IoCreateDirectory()
Creates a new directory. The function will return false if the directory already exists.
-
参数
-
[in]
|
createParents
|
Check if parent directory exists and if not create them recursively.
|
[out]
|
createdDirs
|
An array that will contain all newly created subdirectories in the order in which they were created. If this parameter is nullptr it will be ignored.
|
-
返回
-
Set to true if the directory could be created successfully.
◆
IoCopyFile()
Copies a file to a different location, the path must exist otherwise the function returns an error.
-
参数
-
[in]
|
destName
|
Destination name for the copy operation.
|
[in]
|
overwrite
|
Set to true to allow overwriting destName file if it was already there.
|
[in]
|
removeReadOnly
|
Set to true to remove the read only flag on the newly created copy.
|
-
返回
-
OK on success.
◆
IoMove()
Moves a file or directory (including hierarchy) to a different location, the path must exist otherwise the function returns an error. If the destName file or directory does already exist the function returns with an error. Moving a file or directory on the same partition will perform without a temporary copy.
-
参数
-
[in]
|
destName
|
Destination name for the move operation.
|
-
返回
-
OK on success.
◆
IoRename()
Renames a file or directory. The newName must not be the name of an existing file or directory.
-
参数
-
[in]
|
newName
|
Destination name for the move operation.
|
-
返回
-
OK on success.
◆
IoGetFreeVolumeSpace()
Calculates the free space on a volume. The
Url
must point to a volume, e.g. by browsing SCHEME_VOLUME.
-
参数
-
[out]
|
availableBytes
|
The number of available bytes on the volume.
|
[out]
|
totalBytes
|
The total size of the volume in bytes.
|
-
返回
-
OK on success.
◆
IoShowInOS()
Opens or shows the file in the systems explorer (desktop/finder). Under windows that would be on the desktop/explorer. Under OSX this would be the Finder. Depending on the url scheme this could also open another browser.
-
参数
-
[in]
|
flags
|
Flags to define how to open that file.
|
-
返回
-
OK on success.
◆
Normalize()
Return a normalized a url. Does not involve any Io operation and is just syntax based. If nothing needs to be normalized the same path is returned.
-
参数
-
[in]
|
flags
|
Flags to define type of normalization.
|
-
返回
-
The normalized url. In case of a normalization error *this is returned.
◆
IoNormalize()
Return a normalized a url. If the normalized url is a link, the IoHandler can resolve it (if supported). E.g. the
file:///
handler resolves symbolic links, where the
http://
handler does not resolve llinks.
-
参数
-
[in]
|
flags
|
Flags to define type of normalization.
|
-
返回
-
The normalized and resolved url. In case of a normalization error *this is returned.
◆
ToString()
Returns a readable string of the content.
-
参数
-
[in]
|
formatStatement
|
Nullptr or additional formatting instruction. Currently no additional formatting instructions are supported.
|
-
返回
-
The converted result.
◆
DescribeIO()
Describe all elements of this class for I/O operations.
-
参数
-
[in]
|
stream
|
The stream that is used to register the class members.
|
-
返回
-
OK on success.
◆
GetHashCode()
Returns the hash code of the
Url
(used for hash maps and comparisons).
-
返回
-
The
Url
's hash code.
#define iferr_return
定义:
resultbase.h:1434
static const Id URLSCHEME_FILESYSTEM
定义:
url.h:587
@ NONE
No flags specified.