FileOps

Static Functions

Function
FileOps.$changeworkingdir()
FileOps.$converthfspathtoposixpath()
FileOps.$convertposixpathtohfspath()
FileOps.$copyfile()
FileOps.$createdir()
FileOps.$deletefile()
FileOps.$doesfileexist()
FileOps.$filelist()
FileOps.$getfileinfo()
FileOps.$getfilename()
FileOps.$getlasterror()
FileOps.$getunixpermissions()
FileOps.$getworkingdir()
FileOps.$isdirectory()
FileOps.$isfile()
FileOps.$movefile()
FileOps.$parentdir()
FileOps.$putfilename()
FileOps.$readfile()
FileOps.$rename()
FileOps.$selectdirectory()
FileOps.$selectfilesinsystemviewer()
FileOps.$setfileinfo()
FileOps.$setunixpermissions()
FileOps.$spaceinfo()
FileOps.$splitpathname()
FileOps.$writefile()

Note: FileOps.$writeentirefile() and FileOps.$readentirefile() are obsolete and have been removed from the Catalog; use their equivalent functions FileOps.$writefile() and FileOps.$readfile() as above, or the dynamic functions below.

FileOps Worker Objects

The FileOps Worker Objects, FileOpsCopyWorker, FileOpsMoveWorker, and FileOpsDeleteWorker allow you to copy, move or delete files asynchronously, which may be useful when operating on a large number of files. They are equivalent to the static methods of the FileOps object to copyfile, movefile and deletefile.

To use the FileOps workers, you need to create an Object variable and set its subtype to one of the FileOps worker objects via the Select Object dialog. Alternatively, you can create an Object class and set its superclass to one of the FileOps worker objects, then create an Object variable or Object reference variable and set its subtype to the object class name. Having created the variable you can call its methods using OBJECTVAR.$methodname.

The FileOps workers work exactly like the other workers, including the ability to run the $init, $start or $run methods. They have the property $progressinterval which sets an interval in seconds, at which progress notifications are sent to the $progress method. $progressinterval defaults to the minimum value of 1 second.

For the $init method, the parameters are the same as used in the static methods to copyfile, movefile or deletefile.

The FileOps workers have an optional last parameter vTag for their $init methods. If supplied, the vTag parameter is some data that is passed to $completed in the column __tag of the row parameter. This can be used for example to identify the caller when the worker object is shared by several instances.

When $completed is called, a row is returned with the errorCode and errorText of the action; errorCode will be 0 if there is no error, otherwise a FileOps Worker error is returned, plus the error description in the errorText column.

When the $progress method is called (only if $callprogress is true), a row is returned with a column name 'progress' containing an estimated number between 0 and 100 indicating the percentage progress of the file operation. Note: the Delete worker never calls $progress, therefore progress notifications are not sent from the delete worker.

Note that if you try to cancel a FileOps worker while it is running, the main thread will be blocked until the worker finishes its job.

The main thread is not locked when a FileOps worker is getting cancelled, that is, either directly through a call to $cancel, or through the FileOps worker variable going out of scope. You should note that the FileOps worker will still execute in the background even when cancelled.

FileOps External Object

Dynamic Functions (Methods)

The FileOps dynamic functions allow you to manipulate files. To use these methods, you must declare an object variable, and set its subtype to the FileOps external object. You then call the method using the syntax object.$methodname(). You can use the Interface Manager to view the methods of the object.

The FileOps external object has the following methods.

Function
$closefile()
$createfile()
$createtmpfile()
$getfileinfo()
$getfilesize()
$getlasterror()
$getposition()
$isopen()
$openfile()
$openresources()
$readcharacter()
$readfile()
$setfileinfo()
$setfilesize()
$setposition()
$writecharacter()
$writefile()