The FSUtil object provides several utility methods for dealing with the file system. It is obtained using the DOpus.FSUtil method.
Method Name |
Arguments |
Return Type |
Description |
---|---|---|---|
ComparePath |
<string:path1> |
bool |
Compares the two provided path strings for equality - returns
True if the two paths are equal, or
False if otherwise. |
DisplayName |
<string:path> |
string |
Retrieves the display name of a path. This is the form of a path that
is intended to be displayed to the user, rather than used internally by
Opus. For example, for a library path it will strip off the internal
?xxxxxxx notation that Opus uses to identify library member
folders. |
Exists |
<string:path> |
bool |
Returns True if the specified file, folder or device exists, or False otherwise. |
GetItem |
<string:path> |
object:Item |
Creates an Item object for the specified file path. |
GetMetadata |
<string:path> |
object:Metadata |
Returns a Metadata object representing the metadata for the specified file. |
GetType |
<string:path> |
string |
Returns a string indicating the type of the specified file path. The string will be either file, dir or invalid if the path doesn't exist. The optional flags argument is used to control the behavior with archives - normally an archive will be reported as dir, but if you specify "a" for the flags parameter it will be reported as file. |
Hash |
<string:path> |
string or object:Vector |
Calculates a checksum for the specified file. By default the MD5 checksum is calculated. You can specify "sha" for the optional type parameter to calculate the SHA checksum. If you specify "md5,sha" as the type then both checksums will be calculated at the same time, and the result will be returned as a Vector of strings (the MD5 checksum will always be the first element). |
NewFileSize |
<string:"s"> |
object:FileSize |
Creates a new FileSize object, which makes
it easier to handle 64 bit file sizes. You can initialize this with a
number of data types (int, string, currency, or
another FileSize
object). |
NewPath |
<string:path> |
object:Path |
Creates a new Path object initialised to the provided path string. |
NewWild |
<string:pattern> |
object:Wild |
Creates a new Wild object. If a pattern
and flags are provided the pattern will be parsed automatically, otherwise
you must call the Parse method to parse a pattern before
using the object. |
OpenFile |
<string:path> or <object:Blob> |
object:File |
Opens or creates a file and returns a File object
that lets you access its contents as binary data. You can pass a string or
Path object
representing a file to open, and you can also pass an existing Blob object to
create a File object
that gives you read/write stream access to a chunk of memory.
When opening in write mode, you can also specify optional flags that
control how the file is opened: |
ReadDir |
<string:path> |
object:FolderEnum |
Returns a FolderEnum object that lets you enumerate the contents of the specified folder. Pass True for the optional recurse flag to recursively enumerate the folder (i.e. to enumerate the contents of all its sub-folders, and their sub-folders, and so on). |
Resolve |
<string:path> |
object:Path |
Resolves the specified library or file collection path to its
underlying file system path. This method can also be used to resolve a folder alias, as well as
application paths in the form
{apppath|appname}. |
SameDrive |
<string:path> |
bool |
Returns True if this path refers to the same
drive or partition as the supplied path. The optional flags
are: |