Documentation‎ > ‎Commands‎ > ‎


Implement virtual file system commands.


gnocl::file [subcommand] [-option value...]


The file command implements Gnome virtual file system commands.


gnocl::file create [file-name] [-option value...]
Create a new file. This command returns the name of a newly created command, which can be used to invoke various operations on the new file. See file open.
-random boolean (default: 0)
Whether random access can be used.
-permission integer(default: 0755)
Permission of the file
-force  boolean (default: o)
Whether an existing file with the same name is overwritten.
gnocl::file exists [file-name]
Returns a boolean whether file file-name exist.
gnocl::file info [file-name] [-option]
gnocl::file info [file-name] [-option value...]
In its first form, an information about a file is returned. The option specifies, which information to return.
In its second form the values of each option must be the name of a global variable in which the corresponding information is stored. In this case the empty string is returned.
puts [gnocl::file info "file:///tmp/qqq.tcl" -mimeType]

gnocl::file info "file:///tmp/qqq.tcl" \
    -isSymlink isSymlink \
    -size fileSize \
    -fileType type

Example 1: <description needed >
-fileType string
-isLocal string
-isSymlink string
-mimeType string
-name string
-size string
-symlinkName string
gnocl::file listDir [dir-name]
Returns a list of files in a directory.
proc printFileInfo { name size } {
puts "$name: $size"

gnocl::file listDir "~" \
    -matchName {^[q-t].*}
    -onMatch "printFileInfo %n %s"]
Example 2: Lists all files starting with q, r, s or t in the home directory of the current user.
-matchName string
List only those files matching the given regular expression
-onMatch string
Do not return a list of files, but execute the given Tcl command for each file. Before evaluation the following percent strings are substituted:
%n    name
%t    type
%l    boolean whether file is local
%k    boolean whether file is symlink
%K    symlink name
%m    MIME type
%s    file size
gnocl::file open [file-name] [-option value...]
This command opens a file and returns the name of a newly created command, which can be used to invoke various operations listed below on the file.
-random boolean (dfault: 0)
Whether random access can be used.
-mode one of read, r, write, w, readWrite, rw (default: read)
Open mode.
File operations
read num-bytes var
Read num-bytes bytes in the variable var. Returns the number of bytes read or -1 if EOF is encountered.
write string
Write string.
seek position [-origin org ]
Set the file position indicator to position position. org must be one of start, current or end.
Return current position of the file position indicator
Close the file. The command associated with this file becomes invalid.
gnocl::file makeDir [dir-name]
Make a directory.
-permission integer (default: 0755)
gnocl::file remove [file-name]
Remove a file.
gnocl::file removeDir [dir-name]
Remove a directory.


An example how to directly read in zip archives.

set txtFp [gnocl::file create /tmp/VFS_test.txt -force 1]

$txtFp write "Gnocl with Gnome VFS"

$txtFp close

exec zip -j /tmp/ /tmp/VFS_test.txt

set zipFp [gnocl::file open /tmp/]

$zipFp read 1024 ll

$zipFp close

puts $ll ;# will print "Gnocl with Gnome VFS"