PhodavVirtualDir

PhodavVirtualDir — in-memory directory

Functions

Object Hierarchy

    GObject
    ├── GFileEnumerator
       ╰── PhodavVirtualDirEnumerator
    ╰── PhodavVirtualDir

Includes

#include <libphodav/phodav.h>

Description

PhodavVirtualDir implements GFileIface and can be used with all GFile functions.

PhodavVirtualDir, as the name suggests, does not represent any real file. Instead, it is a virtual element that can be used to build a directory tree structure in the memory. However, a PhodavVirtualDir can have a real file as its child.

The first building block of such tree must be phodav_virtual_dir_new_root(). Further directories can be added using phodav_virtual_dir_new_dir(). To link a real file as a child of a PhodavVirtualDir, use phodav_virtual_dir_attach_real_child().

PhodavVirtualDir allows you to easily share two resources when they have no common ancestor (like "C:\fileA" and "D:\fileB") or when sharing their common ancestor would be impractical (sharing the whole "/" when the files are "/d1/d2/fileA" and "/d3/d4/fileB").

PhodavVirtualDir was designed primarily for the purposes of the SPICE project and hence the functionality is very narrow. If other projects find it handy as well, it could be extended quite easily.

Supported methods:

  • GET

  • PROPFIND

  • LOCK

  • UNLOCK

This concerns only the virtual directories. If you have a real GFile linked to a virtual directory, all the other methods are supported on such file.

You currently cannot delete a PhodavVirtualDir. Once the last reference to the root is dropped, the whole structure is destroyed. Children that have other references (non-internal) become dummies, otherwise they're freed.

PhodavVirtualDir is available since phodav 2.5.

Functions

phodav_virtual_dir_new_root ()

PhodavVirtualDir *
phodav_virtual_dir_new_root (void);

Creates a new root virtual directory that acts as the ancestor of all further virtual directories.

Returns

a new PhodavVirtualDir with the path /.

[transfer full]

Since: 2.5


phodav_virtual_dir_root_set_real ()

void
phodav_virtual_dir_root_set_real (PhodavVirtualDir *root,
                                  const gchar *real_root_path);

If real_root_path is not NULL, root lists all files added with phodav_virtual_dir_new_dir() and phodav_virtual_dir_attach_real_child() as well as all files under real_root_path as its children.

This enables you to keep the server path to files in real_root_path unchanged while also using the virtual folders. (real_root_path /fileA is still accessible as "/fileA", if you used phodav_virtual_dir_attach_real_child(), the path would change to "/real_root-basename/fileA")

This does not check for any conflicts between the virtual directories and the real files - virtual directories take precedence (e.g. in g_file_get_child()).

Parameters

root

PhodavVirtualDir obtained from phodav_virtual_dir_new_root()

 

real_root_path

path to a real directory.

[nullable]

Since: 2.5


phodav_virtual_dir_root_get_real ()

GFile *
phodav_virtual_dir_root_get_real (PhodavVirtualDir *root);

Parameters

Returns

the GFile previously set by phodav_virtual_dir_root_set_real(), otherwise NULL.

[transfer full]

Since: 2.5


phodav_virtual_dir_new_dir ()

PhodavVirtualDir *
phodav_virtual_dir_new_dir (PhodavVirtualDir *root,
                            const gchar *path,
                            GError **error);

Tries to create a new virtual directory with the specified path . If it fails, error is set accordingly.

A real GFile child cannot act as parent to PhodavVirtualDir.

Note that this does not create parent directories. You have to call this repeatedly yourself if the parent(s) don't exist yet.

Parameters

root

PhodavVirtualDir returned by phodav_virtual_dir_new_root()

 

path

path of the PhodavVirtualDir that should be created

 

error

GError to set on error, or NULL to ignore.

[nullable]

Returns

a new PhodavVirtualDir that corresponds to the path .

[transfer full]

Since: 2.5


phodav_virtual_dir_attach_real_child ()

gboolean
phodav_virtual_dir_attach_real_child (PhodavVirtualDir *parent,
                                      GFile *child);

If successful, child becomes a descendant of parent .

Keep in mind that the link is only unidirectional - child does not know about its parent . That means that functions such as g_file_enumerate_children(), g_file_resolve_relative_path() (used with parent ) work as expected, but g_file_get_parent() (used with child ) does not.

If you want to add a PhodavVirtualDir to parent , use phodav_virtual_dir_new_dir() instead.

Parameters

parent

a PhodavVirtualDir that should simulate the direct ancestor of child

 

child

a real file that should be linked to parent

 

Returns

TRUE on success, otherwise FALSE

Since: 2.5

See Also

GFileIface