summaryrefslogtreecommitdiff
path: root/src/lib/eina/eina_vpath.h
blob: 40adffeca18057387174a75a03e6f38fba507f0f (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
#ifndef EINA_VPATH_H
#define EINA_VPATH_H

#include "eina_prefix.h"

/*
 * Eina_vpath
 * eina vpath is a path that can be prefixed with a virtual path.
 *
 * A virutla path can either start with (:XXXXXXXX:) that indicates a virtual path, OR normal with / or ./ or ../ or ~
 * The char sequence in between (: and :) are used as key to lookup the real value.
 * The key has to be set by a interface before, otherwise you will get a error.
 *
 * The symbol ~ is interpretated as the home directory of the running user, and will be replaced.
 * Additional infos: https://phab.enlightenment.org/w/eina_vpath/
 */

/**
 * This datatype is a vpath, this means you can use the syntax described above.
 */
typedef const char* Eina_Vpath;


typedef struct
{
  const char *desktop;
  const char *documents;
  const char *downloads;
  const char *music;
  const char *pictures;
  const char *pub;
  const char *templates;
  const char *videos;
  const char *data;
  const char *config;
  const char *cache;
  const char *run;
} Eina_Vpath_Interface_User;

/**
 * Make the app specific paths accessable as virtual path
 *
 * This will create :
 *   - app.dir
 *   - app.bin
 *   - app.lib
 *   - app.data
 *   - app.locale
 *   - app.config
 *   - app.cache
 *   - app.local
 *
 * If you do NOT call this api the virtual paths for app.* will be unset
 */
EAPI void eina_vpath_interface_app_set(const char *app_name, Eina_Prefix *p);

/**
 * Create the desktop specific vpaths
 *
 * The virtual paths will be named usr.<field-name-of-struct>
 *
 * If you do NOT call this api the virtual paths for usr.* will be unset.
 */
EAPI void eina_vpath_interface_user_set(Eina_Vpath_Interface_User *user);

/*
 * Translate a virtual path into a normal path.
 *
 * @return a string that is not virtual anymore
 *
 */
EAPI char* eina_vpath_resolve(Eina_Vpath path);

#endif