Next: , Previous: GnomeVFSFileInfo, Up: Top


6 Basic File Operations

Essential VFS operations. This includes creating, moving and deleting files, opening and closing file handles.

6.1 Overview

GnomeVFS file operations are, for the most part, patterned after their POSIX equivalents, with the systematic difference that they accept URIs rather than paths on the local filesystem. This makes them easy to learn as if you are already familiar with basic commands such as open, seek, write, etc you will feel right at home with GnomeVFS after learning a little about URIs.

6.2 Usage

— Function: gnome-vfs-create (text_uri mchars) (open_mode <gnome-vfs-open-mode>) (exclusive bool) (perm unsigned-int) ⇒  (ret scm)

Create text-uri according to mode open-mode. On return, handle will then contain a pointer to a handle for the open file.

handle
pointer to a pointer to a <gnome-vfs-handle> object.
text-uri
string representing the uri to create.
open-mode
mode to leave the file opened in after creation (or ‘GNOME_VFS_OPEN_MODE_NONE’ to leave the file closed after creation).
exclusive
whether the file should be created in "exclusive" mode. i.e. if this flag is nonzero, operation will fail if a file with the same name already exists.
perm
bitmap representing the permissions for the newly created file (Unix style).
ret
an integer representing the result of the operation.
— Function: gnome-vfs-create-uri (uri <gnome-vfsuri>) (open_mode <gnome-vfs-open-mode>) (exclusive bool) (perm unsigned-int) ⇒  (ret scm)

Create uri according to mode open-mode. On return, handle will then contain a pointer to a handle for the open file.

handle
pointer to a pointer to a <gnome-vfs-handle> object.
uri
uri for the file to create.
open-mode
open mode.
exclusive
whether the file should be created in "exclusive" mode. i.e. if this flag is nonzero, operation will fail if a file with the same name already exists.
perm
bitmap representing the permissions for the newly created file (Unix style).
ret
an integer representing the result of the operation.
— Function: gnome-vfs-open (text_uri mchars) (open_mode <gnome-vfs-open-mode>) ⇒  (ret scm)

Open text-uri according to mode open-mode. On return, handle will then contain a pointer to a handle for the open file.

handle
pointer to a pointer to a <gnome-vfs-handle> object.
text-uri
string representing the uri to open.
open-mode
open mode.
ret
an integer representing the result of the operation.
— Function: gnome-vfs-open-uri (uri <gnome-vfsuri>) (open_mode <gnome-vfs-open-mode>) ⇒  (ret scm)

Open uri according to mode open-mode. On return, handle will then contain a pointer to a handle for the open file.

handle
pointer to a pointer to a <gnome-vfs-handle> object.
uri
uri to open.
open-mode
open mode.
ret
an integer representing the result of the operation.
— Function: gnome-vfs-unlink (text_uri mchars) ⇒  (ret <gnome-vfs-result>)

Unlink text-uri (i.e. delete the file).

text-uri
uri of the file to be unlinked.
ret
an integer representing the result of the operation.
— Function: gnome-vfs-unlink-from-uri (uri <gnome-vfsuri>) ⇒  (ret <gnome-vfs-result>)

Unlink uri (i.e. delete the file).

uri
uri of the file to be unlinked.
ret
an integer representing the result of the operation.
— Function: gnome-vfs-move-uri (old_uri <gnome-vfsuri>) (new_uri <gnome-vfsuri>) (force_replace bool) ⇒  (ret <gnome-vfs-result>)

Move a file from uri old-uri to new-uri. This will only work if old-uri and new-uri are on the same file system. Otherwise, it is necessary to use the more general gnome-vfs-xfer-uri function.

old-uri
source uri.
new-uri
destination uri.
force-replace
if ‘#t’, move old-uri to new-uri even if there is already a file at new-uri. If there is a file, it will be discarded.
ret
an integer representing the result of the operation.
— Function: gnome-vfs-move (old_text_uri mchars) (new_text_uri mchars) (force_replace bool) ⇒  (ret <gnome-vfs-result>)

Move a file from old-text-uri to new-text-uri. This will only work if old-text-uri and new-text-uri are on the same file system. Otherwise, it is necessary to use the more general gnome-vfs-xfer-uri function.

old-text-uri
string representing the source file location.
new-text-uri
string representing the destination file location.
force-replace
if ‘#t’, perform the operation even if it unlinks an existing file at new-text-uri.
ret
an integer representing the result of the operation.
— Function: gnome-vfs-check-same-fs-uris (source_uri <gnome-vfsuri>) (target_uri <gnome-vfsuri>) ⇒  (ret <gnome-vfs-result>) (same_fs_return bool)

Check if source-uri and target-uri are on the same file system.

source-uri
a uri.
target-uri
another uri.
same-fs-return
pointer to a boolean variable which will be set to ‘#t’ on return if source-uri and target-uri are on the same file system.
ret
an integer representing the result of the operation.
— Function: gnome-vfs-check-same-fs (source mchars) (target mchars) ⇒  (ret <gnome-vfs-result>) (same_fs_return bool)

Check if source and target are on the same file system.

source
path to a file.
target
path to another file.
same-fs-return
pointer to a boolean variable which will be set to ‘#t’ on return if source and target are on the same file system.
ret
an integer representing the result of the operation.
— Function: gnome-vfs-uri-exists (self <gnome-vfsuri>) ⇒  (ret bool)

Check if the uri points to an existing entity.

uri
a uri.
ret
#t’ if uri exists.
— Function: gnome-vfs-create-symbolic-link (uri <gnome-vfsuri>) (target_reference mchars) ⇒  (ret <gnome-vfs-result>)

Creates a symbolic link, or eventually, a uri link (as necessary) at uri pointing to target-reference.

uri
uri to create a link at.
target-reference
uri "reference" to point the link to (uri or relative path).
ret
an integer representing the result of the operation.