Top | ![]() |
![]() |
![]() |
![]() |
PhodavVirtualDir * | phodav_virtual_dir_new_root () |
void | phodav_virtual_dir_root_set_real () |
GFile * | phodav_virtual_dir_root_get_real () |
PhodavVirtualDir * | phodav_virtual_dir_new_dir () |
gboolean | phodav_virtual_dir_attach_real_child () |
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.
PhodavVirtualDir *
phodav_virtual_dir_new_root (void
);
Creates a new root virtual directory that acts as the ancestor of all further virtual directories.
Since: 2.5
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()
).
root |
PhodavVirtualDir obtained from |
|
real_root_path |
path to a real directory. |
[nullable] |
Since: 2.5
GFile *
phodav_virtual_dir_root_get_real (PhodavVirtualDir *root
);
the GFile previously set by phodav_virtual_dir_root_set_real()
,
otherwise NULL.
[transfer full]
Since: 2.5
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.
root |
PhodavVirtualDir returned by |
|
path |
path of the PhodavVirtualDir that should be created |
|
error |
GError to set on error, or |
[nullable] |
Since: 2.5
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.
parent |
a PhodavVirtualDir that should simulate the direct ancestor of |
|
child |
a real file that should be linked to |
Since: 2.5