Data directories: Difference between revisions

From Arx Libertatis Wiki
Jump to navigation Jump to search
Line 22: Line 22:
2. If a <b><code>--no-data-dir</code> command-line option</b> is given, don't use a separate data directory.
2. If a <b><code>--no-data-dir</code> command-line option</b> is given, don't use a separate data directory.


3. (windows-only) If the <b><code>HKEY_CURRENT_USER\Software\ArxLibertatis\DataDir</code> registry keys</b> exists, use it's value.
3. (windows-only) If the <b><code>HKEY_CURRENT_USER\Software\ArxLibertatis\DataDir</code> registry key</b> exists, use it's value.


4. (windows-only) If the <b><code>HKEY_LOCAL_MACHINE\Software\ArxLibertatis\DataDir</code> registry keys</b> exists, use it's value.
4. (windows-only) If the <b><code>HKEY_LOCAL_MACHINE\Software\ArxLibertatis\DataDir</code> registry key</b> exists, use it's value.


5. If a <b>cmake <code>-DDATA_DIR</code> and <code>-DDATA_DIR_PREFIXES</code> options</b> are given and <code>DATA_DIR</code> is a relative path after expanding <b>environment variables</b>, interpret <code>DATA_DIR_PREFIXES</code> as a colon-separated list (after expanding <b>environment variables</b>) and search for <code>DATA_DIR</code> in each entry. Use the first match found.
5. If a <b>cmake <code>-DDATA_DIR</code> and <code>-DDATA_DIR_PREFIXES</code> options</b> are given and <code>DATA_DIR</code> is a relative path after expanding <b>environment variables</b>, interpret <code>DATA_DIR_PREFIXES</code> as a colon-separated list (after expanding <b>environment variables</b>) and search for <code>DATA_DIR</code> in each entry. Use the first match found.
Line 39: Line 39:
1. If a <b><code>--user-dir=...</code> command-line option</b> is given, always use that user directory.
1. If a <b><code>--user-dir=...</code> command-line option</b> is given, always use that user directory.


3. (windows-only) If the <b><code>HKEY_CURRENT_USER\Software\ArxLibertatis\UserDir</code> registry keys</b> exists, use it's value.
3. (windows-only) If the <b><code>HKEY_CURRENT_USER\Software\ArxLibertatis\UserDir</code> registry key</b> exists, use it's value.


4. (windows-only) If the <b><code>HKEY_LOCAL_MACHINE\Software\ArxLibertatis\UserDir</code> registry keys</b> exists, use it's value.
4. (windows-only) If the <b><code>HKEY_LOCAL_MACHINE\Software\ArxLibertatis\UserDir</code> registry key</b> exists, use it's value.


5. If a <b>cmake <code>-DUSER_DIR</code> and <code>-DUSER_DIR_PREFIXES</code> options</b> are given and <code>USER_DIR</code> is a relative path after expanding <b>environment variables</b>, interpret <code>USER_DIR_PREFIXES</code> as a colon-separated list (after expanding <b>environment variables</b>) and search for <code>USER_DIR</code> in each entry. Use the first match found.
5. If a <b>cmake <code>-DUSER_DIR</code> and <code>-DUSER_DIR_PREFIXES</code> options</b> are given and <code>USER_DIR</code> is a relative path after expanding <b>environment variables</b>, interpret <code>USER_DIR_PREFIXES</code> as a colon-separated list (after expanding <b>environment variables</b>) and search for <code>USER_DIR</code> in each entry. Use the first match found.

Revision as of 09:47, 8 December 2011

This page describes the current proposal for how data / config / save files should be located (see also https://github.com/arx/ArxLibertatis/issues/88):

The game will recognize two different directories, a data directory and a user directory.

  • The data directory holds read-only asset data and possibly a cfg_default.ini. The data directory can be empty to only load data from the user directory.
  • The user directory holds save games, cfg.ini, screenshots, but can also hold asset data that takes priority over that from the data directory (like user-installed mods).

This should allow the game run either from all files in the current directory or from a system-wide installation with per-user config and save files.

Goals

  • Starting from a local directory should be as simple as possibly and store saves/settings in that directory. This is for compatibility with the current way arx-libertatis is run and to allow easier testing.
  • Windows installers should be able to specify the directories in the registry.
  • By default, linux installations should look in the directories specified by the XDG Base Directory Specification

Directory detection procedure

Data directory

1. If a --data-dir=... command-line option is given, always use that data directory.

2. If a --no-data-dir command-line option is given, don't use a separate data directory.

3. (windows-only) If the HKEY_CURRENT_USER\Software\ArxLibertatis\DataDir registry key exists, use it's value.

4. (windows-only) If the HKEY_LOCAL_MACHINE\Software\ArxLibertatis\DataDir registry key exists, use it's value.

5. If a cmake -DDATA_DIR and -DDATA_DIR_PREFIXES options are given and DATA_DIR is a relative path after expanding environment variables, interpret DATA_DIR_PREFIXES as a colon-separated list (after expanding environment variables) and search for DATA_DIR in each entry. Use the first match found.

  • default value is 'arx'
  • (linux-only) default value for DATA_DIR_PREFIXES is '${CMAKE_INSTALL_PREFIX}/share:$XDG_DATA_DIRS'

6. If a cmake -DDATA_DIR option was given, use it after expanding environment variables.

If a data directory was found but does not exist, clear it. If no data directory was found, that's ok - the user directory can contain all required files.

User directory

1. If a --user-dir=... command-line option is given, always use that user directory.

3. (windows-only) If the HKEY_CURRENT_USER\Software\ArxLibertatis\UserDir registry key exists, use it's value.

4. (windows-only) If the HKEY_LOCAL_MACHINE\Software\ArxLibertatis\UserDir registry key exists, use it's value.

5. If a cmake -DUSER_DIR and -DUSER_DIR_PREFIXES options are given and USER_DIR is a relative path after expanding environment variables, interpret USER_DIR_PREFIXES as a colon-separated list (after expanding environment variables) and search for USER_DIR in each entry. Use the first match found.

  • default value is 'arx'
  • (linux-only) default value for USER_DIR_PREFIXES is '$XDG_DATA_HOME'
  • (windows-only) default value for USER_DIR_PREFIXES is '%USERPROFILE%/My Documents/Games'

6. If a cmake -DUSER_DIR option was given, use it after expanding environment variables.

7. If a data directory has been found but not user directory and the preconditions for step 5 hold, create USER_DIR in the first directory of USER_DIR_PREFIXES that already exists. If none of the directories in USER_DIR_PREFIXES exist, create the first entry.

8. If a data directory has been found but not user directory and the preconditions for step 6 hold, create USER_DIR.

9. Otherwise, use the current working directory as the user directory.

If no user directory was found or could be created, quit.