Home · Overviews · Reference · Classes codeless banner

File Javascript Class Reference

Helper class for dealing with filenames.

Methods

File(name): File

Returns a new file instance for the specified file name.

extension(): string

Returns the file extension.

    var file = File("/home/qbuild/hello.txt");
    // file.extension() == "txt"

name(): string

Returns the file name.

    var file = File("/home/qbuild/hello.txt");
    // file.name() == "hello"

path: null

Returns the file path.

    var file = File("/home/qbuild/hello.txt");
    // file.path() == "/home/qbuild"

stripextension: null

Returns the file without extension.

    var file = File("/home/qbuild/hello.txt");
    // file.stripextension() == "/home/qbuild/hello"

escapedname: null

Returns the file name with spaces escaped.

    var file = File("/home/qbuild/hello world.txt");
    // file.stripextension() == "/home/qbuild/hello\ world.txt"

simplename: null

Returns the file with non-alphanumeric characters replaced with simple escaped versions. The resultant name will consist only of the characters, "a-zA-Z0-9_".

    var file = File("myfilename*x.txt");
    // file.simplename() == "myfilename_42x_46.txt"

canonicalName(): string

Returns the canonical name of the file.

    var file = File("foo/../bar");
    // file.canonicalName() == "bar"

isRelative(): boolean

Returns true if this is a relative path (does not start with '/') otherwise false.

See also Javascript Binding.


Copyright © 2009 Trolltech
Qt Extended - QBuild Maintainer Guide