Fuego.Io : File

The File component is used to manage files in the server hosting the Oracle BPM Process Execution Engine. The File component can list, rename, move, copy, delete, check the existence of, and get properties of files.

Example 1

The following example uses the File component to perform various file management tasks:

testfile as Fuego.Io.File = Fuego.Io.File("/tmp/testfile.txt")

// The following code checks for testfile.txt. If it exists, it is deleted:
delete testfile
    using sourcePath = "/tmp/testfile.txt",
        silent = true

// The following code creates file:
fileok = createNewFile(testfile, silent : false)


//The following code displays "true" if the the file is a directory:
display ("Is this file a Directory: " + testfile.directory)


// The following code displays if the file exists:
display ("File exists: " + exists(testfile))


// The following code retrieves the "file's full name.
display ("File's fullname: " + testfile.fullName)


// The following code displays "true" if the file is hidden:
display ("File is hidden?: " + testfile.hidden)

// The following code retrieves the date/time when the file was most recently modified:
display ("Last file modification: " +
        Time.valueOf(lastModified(testfile)* 1000))

// The following code retrieves the length of the file:
display ("File's length: " + length(testfile))

// The following code retrieves the file's name.
display ("File's name: " + testfile.name)

// The following code retrieves the path to the file.
display ("File's path: " + testfile.path)

// The following code displays true if the file is read only:
display ("File is readonly?: " + testfile.readOnly)

// The following code displays the character that represents
// the directory separator. In Windows the character is \; in
// Unix the character is /).

display ("Directory separator: " + testfile.separator())

// The following code displays all of the files that are in
// tmp that begin with "test":
result2 = testfile.listFiles(sourcePathFile : "/tmp", silent : true)
for each f1 in result2
do
    if substring(f1.name, first:0, last:4) = "test" then
        display f1.name
    end
end

// The following code copies "testfile" to "copytestfile":
copy testfile
    using sourcePath = "/tmp/testfile.txt",
        destinationPath = "/tmp/copytestfile.txt",
        silent = false

// The following code deletes "copytestfile":
delete testfile
    using sourcePath = "/tmp/copytestfile.txt",
        silent = false

// The following code renames "testfile" to "testfileRen.txt":
rename testfile
    using sourcePath = "/tmp/testfile.txt",
        destinationName = "/tmp/testfileRen.txt",
        silent = true

// The following code moves "/tmp/testfileRen.txt" to "/Temp/testfileRen.txt":
move testfile
    using sourcePath = "/tmp/testfileRen.txt",
        destinationPath = "/Temp/testfileRen.txt",
        silent = false

delete testfile
    using sourcePath = "/Temp/testfileRen.txt",
    silent = false