Changeset - r20928:e6a1e0b8d890
[Not reviewed]
master
0 6 0
rubidium - 11 years ago 2013-11-13 19:32:37
rubidium@openttd.org
(svn r25975) -Feature [FS#5385]: XDG base directory support
6 files changed with 122 insertions and 17 deletions:
0 comments (0 inline, 0 general)
config.lib
Show inline comments
 
@@ -63,24 +63,25 @@ set_default() {
 
	enable_osx_g5="0"
 
	enable_cocoa_quartz="1"
 
	enable_cocoa_quickdraw="1"
 
	with_osx_sysroot="1"
 
	with_application_bundle="1"
 
	with_menu_entry="1"
 
	with_allegro="1"
 
	with_sdl="1"
 
	with_cocoa="1"
 
	with_zlib="1"
 
	with_lzma="1"
 
	with_lzo2="1"
 
	with_xdg_basedir="1"
 
	with_png="1"
 
	enable_builtin_depend="1"
 
	with_makedepend="0"
 
	with_direct_music="1"
 
	with_sort="1"
 
	with_iconv="1"
 
	with_midi=""
 
	with_midi_arg=""
 
	with_libtimidity="1"
 
	with_freetype="1"
 
	with_fontconfig="1"
 
	with_icu="1"
 
@@ -136,24 +137,25 @@ set_default() {
 
		enable_universal
 
		enable_osx_g5
 
		enable_cocoa_quartz
 
		enable_cocoa_quickdraw
 
		with_osx_sysroot
 
		with_application_bundle
 
		with_allegro
 
		with_sdl
 
		with_cocoa
 
		with_zlib
 
		with_lzma
 
		with_lzo2
 
		with_xdg_basedir
 
		with_png
 
		enable_builtin_depend
 
		with_makedepend
 
		with_direct_music
 
		with_sort
 
		with_iconv
 
		with_midi
 
		with_midi_arg
 
		with_libtimidity
 
		with_freetype
 
		with_fontconfig
 
		with_icu
 
@@ -338,24 +340,31 @@ detect_params() {
 
			--with-lzma=*)                with_lzma="$optarg";;
 
			--with-liblzma)               with_lzma="2";;
 
			--without-liblzma)            with_lzma="0";;
 
			--with-liblzma=*)             with_lzma="$optarg";;
 

	
 
			--with-lzo2)                  with_lzo2="2";;
 
			--without-lzo2)               with_lzo2="0";;
 
			--with-lzo2=*)                with_lzo2="$optarg";;
 
			--with-liblzo2)               with_lzo2="2";;
 
			--without-liblzo2)            with_lzo2="0";;
 
			--with-liblzo2=*)             with_lzo2="$optarg";;
 

	
 
			--with-xdg-basedir)           with_xdg_basedir="2";;
 
			--without-xdg-basedir)        with_xdg_basedir="0";;
 
			--with-xdg-basedir=*)         with_xdg_basedir="$optarg";;
 
			--with-libxdg-basedir)        with_xdg_basedir="2";;
 
			--without-libxdg-basedir)     with_xdg_basedir="0";;
 
			--with-libxdg-basedir=*)      with_xdg_basedir="$optarg";;
 

	
 
			--with-png)                   with_png="2";;
 
			--without-png)                with_png="0";;
 
			--with-png=*)                 with_png="$optarg";;
 
			--with-libpng)                with_png="2";;
 
			--without-libpng)             with_png="0";;
 
			--with-libpng=*)              with_png="$optarg";;
 

	
 
			--with-libtimidity)           with_libtimidity="2";;
 
			--without-libtimidity)        with_libtimidity="0";;
 
			--with-libtimidity=*)         with_libtimidity="$optarg";;
 

	
 
			--with-freetype)              with_freetype="2";;
 
@@ -809,24 +818,25 @@ check_params() {
 
		log 1 "WARNING: liblzo2 was not detected or disabled"
 
		log 1 "WARNING: OpenTTD doesn't require liblzo2, but it does mean that"
 
		log 1 "WARNING: loading old savegames/scenarios will be disabled."
 
		if [ "$pre_detect_with_lzo2" = "0" ]; then
 
			log 1 "WARNING: We strongly suggest you to install liblzo2."
 
		else
 
			log 1 "configure: error: no liblzo2 detected"
 
			log 1 " If you want to compile without liblzo2 use --without-liblzo2 as parameter"
 
			exit
 
		fi
 
	fi
 

	
 
	detect_xdg_basedir
 
	detect_png
 
	detect_freetype
 
	detect_fontconfig
 
	detect_icu
 
	detect_pspconfig
 
	detect_libtimidity
 

	
 
	if [ "$with_direct_music" != "0" ]; then
 
		if [ "$os" != "MINGW" ] && [ "$os" != "CYGWIN" ]; then
 
			if [ "$with_direct_music" != "1" ]; then
 
				log 1 "configure: error: direct-music is only supported on Win32 targets"
 
				exit 1
 
@@ -1652,24 +1662,35 @@ make_cflags_and_ldflags() {
 
		fi
 
	fi
 

	
 
	if [ "$with_lzo2" != "0" ]; then
 
		if [ "$enable_static" != "0" ] && [ "$os" != "OSX" ]; then
 
			LIBS="$LIBS $lzo2"
 
		else
 
			LIBS="$LIBS -llzo2"
 
		fi
 
		CFLAGS="$CFLAGS -DWITH_LZO"
 
	fi
 

	
 
	if [ -n "$xdg_basedir_config" ]; then
 
		CFLAGS="$CFLAGS -DWITH_XDG_BASEDIR"
 
		CFLAGS="$CFLAGS `$xdg_basedir_config --cflags | tr '\n\r' '  '`"
 

	
 
		if [ "$enable_static" != "0" ]; then
 
			LIBS="$LIBS `$xdg_basedir_config --libs --static | tr '\n\r' '  '`"
 
		else
 
			LIBS="$LIBS `$xdg_basedir_config --libs | tr '\n\r' '  '`"
 
		fi
 
	fi
 

	
 
	# 64bit machines need -D_SQ64
 
	if [ "$cpu_type" = "64" ] && [ "$enable_universal" = "0" ]; then
 
		CFLAGS="$CFLAGS -D_SQ64"
 
	fi
 
	CFLAGS="$CFLAGS -I$SCRIPT_SRC_DIR"
 

	
 
	if [ -n "$png_config" ]; then
 
		CFLAGS="$CFLAGS -DWITH_PNG"
 
		CFLAGS="$CFLAGS `$png_config --cppflags --I_opts | tr '\n\r' '  '`"
 

	
 
		# The extra flags are unneeded for latest libpng-config, but some versions are so broken...
 
		if [ "$enable_static" != "0" ]; then
 
@@ -2713,24 +2734,62 @@ detect_lzma() {
 
			log 1 "configure: error: pkg-config liblzma couldn't be found"
 
			log 1 "configure: error: you supplied '$with_lzma', but it seems invalid"
 
			exit 1
 
		fi
 

	
 
		lzma_config=""
 
		return 0
 
	fi
 

	
 
	log 1 "checking liblzma... found"
 
}
 

	
 
detect_xdg_basedir() {
 
	# 0 means no, 1 is auto-detect, 2 is force
 
	if [ "$with_xdg_basedir" = "0" ]; then
 
		log 1 "checking libxdg_basedir... disabled"
 

	
 
		xdg_basedir_config=""
 
		return 0
 
	fi
 

	
 
	if [ "$with_xdg_basedir" = "1" ] || [ "$with_xdg_basedir" = "" ] || [ "$with_xdg_basedir" = "2" ]; then
 
		xdg_basedir_config="pkg-config libxdg-basedir"
 
	else
 
		xdg_basedir_config="$with_xdg_basedir"
 
	fi
 

	
 
	version=`$xdg_basedir_config --modversion 2>/dev/null`
 
	ret=$?
 
	log 2 "executing $xdg_basedir_config --modversion"
 
	log 2 "  returned $version"
 
	log 2 "  exit code $ret"
 

	
 
	if [ -z "$version" ] || [ "$ret" != "0" ]; then
 
		log 1 "checking libxdg_basedir... not found"
 

	
 
		# It was forced, so it should be found.
 
		if [ "$with_xdg_basedir" != "1" ]; then
 
			log 1 "configure: error: pkg-config libxdg_basedir couldn't be found"
 
			log 1 "configure: error: you supplied '$with_xdg_basedir', but it seems invalid"
 
			exit 1
 
		fi
 

	
 
		xdg_basedir_config=""
 
		return 0
 
	fi
 

	
 
	log 1 "checking libxdg_basedir... found"
 
}
 

	
 
detect_png() {
 
	# 0 means no, 1 is auto-detect, 2 is force
 
	if [ "$with_png" = "0" ]; then
 
		log 1 "checking libpng... disabled"
 

	
 
		png_config=""
 
		return 0
 
	fi
 

	
 
	if [ "$with_zlib" = "0" ] || [ -z "$zlib" ]; then
 
		if [ "$with_png" != "1" ]; then
 
			log 1 "checking libpng... no zlib"
 
@@ -3633,24 +3692,26 @@ showhelp() {
 
	echo "  --with-allegro[=allegro-config]"
 
	echo "                                 enables Allegro video driver support"
 
	echo "  --with-cocoa                   enables COCOA video driver (OSX ONLY)"
 
	echo "  --with-sdl[=sdl-config]        enables SDL video driver support"
 
	echo "  --with-zlib[=zlib.a]           enables zlib support"
 
	echo "  --with-liblzma[=liblzma.a]     enables liblzma support"
 
	echo "  --with-liblzo2[=liblzo2.a]     enables liblzo2 support"
 
	echo "  --with-png[=libpng-config]     enables libpng support"
 
	echo "  --with-freetype[=freetype-config]"
 
	echo "                                 enables libfreetype support"
 
	echo "  --with-fontconfig[=pkg-config fontconfig]"
 
	echo "                                 enables fontconfig support"
 
	echo "  --with-xdg-basedir[=pkg-config libxdg-basedir]"
 
	echo "                                 enables fontconfig support"
 
	echo "  --with-icu[=icu-config]        enables icu (used for right-to-left support)"
 
	echo "  --static-icu                   try to link statically (libsicu instead of"
 
	echo "                                 libicu; can fail as the new name is guessed)"
 
	echo "  --with-iconv[=iconv-path]      enables iconv support"
 
	echo "  --with-psp-config[=psp-config] enables psp-config support (PSP ONLY)"
 
	echo "  --disable-builtin-depend       disable use of builtin deps finder"
 
	echo "  --with-makedepend[=makedepend] enables makedepend support"
 
	echo "  --with-ccache                  enables ccache support"
 
	echo "  --with-distcc                  enables distcc support"
 
	echo "  --without-grfcodec             disable usage of grfcodec and re-generation of base sets"
 
	echo ""
 
	echo "Some influential environment variables:"
os/debian/control
Show inline comments
 
Source: openttd
 
Section: games
 
Priority: optional
 
Maintainer: Matthijs Kooijman <matthijs@stdin.nl>
 
Uploaders: Jordi Mallach <jordi@debian.org>
 
DM-Upload-Allowed: yes
 
Build-Depends: debhelper (>= 7.0.50), libsdl-dev, zlib1g-dev, libpng-dev, libfreetype6-dev, libfontconfig-dev, libicu-dev, liblzma-dev, liblzo2-dev
 
Build-Depends: debhelper (>= 7.0.50), libsdl-dev, zlib1g-dev, libpng-dev, libfreetype6-dev, libfontconfig-dev, libicu-dev, liblzma-dev, liblzo2-dev, libxdg-basedir-dev
 
Standards-Version: 3.8.4
 
Vcs-Browser: http://git.debian.org/?p=collab-maint/openttd.git
 
Vcs-Git: git://git.debian.org/collab-maint/openttd.git
 
Homepage: http://www.openttd.org/
 

	
 
Package: openttd
 
Architecture: any
 
Depends: ${shlibs:Depends}, ${misc:Depends}
 
Recommends: openttd-opengfx, x11-utils
 
Replaces: openttd-data
 
Conflicts: openttd-data
 
Suggests: openttd-opensfx, timidity, freepats
os/debian/rules
Show inline comments
 
@@ -8,25 +8,25 @@
 

	
 
DEB_HOST_GNU_TYPE=$(shell dpkg-architecture -qDEB_HOST_GNU_TYPE)
 
DEB_BUILD_GNU_TYPE=$(shell dpkg-architecture -qDEB_BUILD_GNU_TYPE)
 
ifneq ($(DEB_HOST_GNU_TYPE),$(DEB_BUILD_GNU_TYPE))
 
CROSS= --build $(DEB_BUILD_GNU_TYPE) --host $(DEB_HOST_GNU_TYPE)
 
endif
 

	
 
# Pass custom options to configure. Since it's not autoconf but a custom
 
# script, some of the option names are slightly different. We also need
 
# to be explicit about the dependencies, in case we're not running in a
 
# clean build root.
 
override_dh_auto_configure:
 
	./configure $(CROSS) --prefix-dir=/usr --install-dir=debian/openttd --without-allegro --with-zlib --with-sdl --with-png --with-freetype --with-fontconfig --with-icu --with-liblzo2 --with-lzma --without-iconv --disable-strip CFLAGS="$(CFLAGS) -g" LDFLAGS="$(LDFLAGS) -Wl,-as-needed"
 
	./configure $(CROSS) --prefix-dir=/usr --install-dir=debian/openttd --without-allegro --with-zlib --with-sdl --with-png --with-freetype --with-fontconfig --with-icu --with-liblzo2 --with-lzma --with-xdg-basedir --without-iconv --disable-strip CFLAGS="$(CFLAGS) -g" LDFLAGS="$(LDFLAGS) -Wl,-as-needed"
 

	
 
# Do some extra installation
 
override_dh_auto_install:
 
	$(MAKE) install DO_NOT_INSTALL_CHANGELOG=1 DO_NOT_INSTALL_LICENSE=1
 

	
 
	# Install the wrapper and make it executable
 
	install -d debian/openttd/usr/share/games/openttd/
 
	install -m755 debian/openttd-wrapper debian/openttd/usr/share/games/openttd/
 

	
 
# Don't do testing. Because the OpenTTD Makefile always does dependency
 
# generation (even on invalid targets), dh_auto_test thinks there is a
 
# "test" target, while there isn't.
readme.txt
Show inline comments
 
@@ -273,25 +273,26 @@ data directory.
 

	
 
The main OpenTTD directories can be found in various locations, depending on
 
your operating system:
 
	1. The current working directory (from where you started OpenTTD)
 
		For non-Windows operating systems OpenTTD will not scan for files in this
 
		directory if it is your personal directory, i.e. '~/', or when it is the
 
		root directory, i.e. '/'.
 
	2. Your personal directory
 
		Windows: C:\My Documents\OpenTTD (95, 98, ME)
 
		         C:\Documents and Settings\<username>\My Documents\OpenTTD (2000, XP)
 
		         C:\Users\<username>\Documents\OpenTTD (Vista, 7)
 
		Mac OSX: ~/Documents/OpenTTD
 
		Linux:   ~/.openttd
 
		Linux:   $XDG_DATA_HOME/openttd which is usually ~/.local/share/openttd when
 
		         built with XDG base directory support, otherwise ~/.openttd
 
	3. The shared directory
 
		Windows: C:\Documents and Settings\All Users\Shared Documents\OpenTTD (2000, XP)
 
		         C:\Users\Public\Documents\OpenTTD (Vista, 7)
 
		Mac OSX: /Library/Application Support/OpenTTD
 
		Linux:   not available
 
	4. The binary directory (where the OpenTTD executable is)
 
		Windows: C:\Program Files\OpenTTD
 
		Linux:   /usr/games
 
	5. The installation directory (Linux only)
 
		Linux:   /usr/share/games/openttd
 
	6. The application bundle (Mac OSX only)
 
		It includes the OpenTTD files (grf+lng) and it will work as long as they
 
@@ -313,28 +314,31 @@ chosen main OpenTTD directory:
 
	Savegames:           save
 
	Automatic Savegames: save/autosave
 
	Scenarios:           scenario
 

	
 
The (automatically created) directory content_download is for OpenTTD's internal
 
use and no files should be added to it or its subdirectories manually.
 

	
 
Notes:
 
	- Linux in the previous list means .deb, but most paths should be similar for
 
	  others.
 
	- The previous search order is also used for NewGRFs and openttd.cfg.
 
	- If openttd.cfg is not found, then it will be created using the 2, 4, 1, 3,
 
	  5 order.
 
	  5 order. When built with XDG base directory support, openttd.cfg will be
 
	  created in $XDG_CONFIG_HOME/openttd which is usually ~/.config/openttd.
 
	- Savegames will be relative to the config file only if there is no save/
 
	  directory in paths with higher priority than the config file path, but
 
	  autosaves and screenshots will always be relative to the config file.
 
	  Unless the configuration file is in $XDG_CONFIG_HOME/openttd, then all
 
	  other files will be saved under $XDG_DATA_HOME/openttd.
 

	
 
The preferred setup:
 
Place 3rd party files in shared directory (or in personal directory if you do
 
not have write access on shared directory) and have your openttd.cfg config
 
file in personal directory (where the game will then also place savegames and
 
screenshots).
 

	
 
4.3) Portable installations (portable media)
 
---- ---------------------------------------
 
You can install OpenTTD on external media so you can take it with you, i.e.
 
using a USB key, or a USB HDD, etc.
 
Create a directory where you shall store the game in (i.e. OpenTTD/).
src/fileio.cpp
Show inline comments
 
@@ -19,24 +19,28 @@
 
#include <windows.h>
 
# define access _taccess
 
#elif defined(__HAIKU__)
 
#include <Path.h>
 
#include <storage/FindDirectory.h>
 
#else
 
#include <unistd.h>
 
#include <pwd.h>
 
#endif
 
#include <sys/stat.h>
 
#include <algorithm>
 

	
 
#ifdef WITH_XDG_BASEDIR
 
#include "basedir.h"
 
#endif
 

	
 
/** Size of the #Fio data buffer. */
 
#define FIO_BUFFER_SIZE 512
 

	
 
/** Structure for keeping several open files with just one data buffer. */
 
struct Fio {
 
	byte *buffer, *buffer_end;             ///< position pointer in local buffer and last valid byte of buffer
 
	size_t pos;                            ///< current (system) position in file
 
	FILE *cur_fh;                          ///< current file handle
 
	const char *filename;                  ///< current filename
 
	FILE *handles[MAX_FILE_SLOTS];         ///< array of file handles we can have open
 
	byte buffer_start[FIO_BUFFER_SIZE];    ///< local buffer when read from file
 
	const char *filenames[MAX_FILE_SLOTS]; ///< array of filenames we (should) have open
 
@@ -1062,24 +1066,30 @@ bool DoScanWorkingDirectory()
 
	snprintf(tmp, lengthof(tmp), "%s%s", _searchpaths[SP_WORKING_DIR], PERSONAL_DIR);
 
	AppendPathSeparator(tmp, MAX_PATH);
 
	return strcmp(tmp, _searchpaths[SP_PERSONAL_DIR]) != 0;
 
}
 

	
 
/**
 
 * Determine the base (personal dir and game data dir) paths
 
 * @param exe the path to the executable
 
 */
 
void DetermineBasePaths(const char *exe)
 
{
 
	char tmp[MAX_PATH];
 
#if defined(WITH_XDG_BASEDIR) && defined(WITH_PERSONAL_DIR)
 
	snprintf(tmp, MAX_PATH, "%s" PATHSEP "%s", xdgDataHome(NULL),
 
			PERSONAL_DIR[0] == '.' ? &PERSONAL_DIR[1] : PERSONAL_DIR);
 
	AppendPathSeparator(tmp, MAX_PATH);
 
	_searchpaths[SP_PERSONAL_DIR_XDG] = strdup(tmp);
 
#endif
 
#if defined(__MORPHOS__) || defined(__AMIGA__) || defined(DOS) || defined(OS2) || !defined(WITH_PERSONAL_DIR)
 
	_searchpaths[SP_PERSONAL_DIR] = NULL;
 
#else
 
#ifdef __HAIKU__
 
	BPath path;
 
	find_directory(B_USER_SETTINGS_DIRECTORY, &path);
 
	const char *homedir = path.Path();
 
#else
 
	const char *homedir = getenv("HOME");
 

	
 
	if (homedir == NULL) {
 
		const struct passwd *pw = getpwuid(getuid());
 
@@ -1146,74 +1156,101 @@ extern void cocoaSetApplicationBundleDir
 
const char *_personal_dir;
 

	
 
/**
 
 * Acquire the base paths (personal dir and game data dir),
 
 * fill all other paths (save dir, autosave dir etc) and
 
 * make the save and scenario directories.
 
 * @param exe the path from the current path to the executable
 
 */
 
void DeterminePaths(const char *exe)
 
{
 
	DetermineBasePaths(exe);
 

	
 
#if defined(WITH_XDG_BASEDIR) && defined(WITH_PERSONAL_DIR)
 
	char config_home[MAX_PATH];
 
	snprintf(config_home, MAX_PATH, "%s" PATHSEP "%s", xdgConfigHome(NULL),
 
			PERSONAL_DIR[0] == '.' ? &PERSONAL_DIR[1] : PERSONAL_DIR);
 
	AppendPathSeparator(config_home, MAX_PATH);
 
#endif
 

	
 
	Searchpath sp;
 
	FOR_ALL_SEARCHPATHS(sp) {
 
		if (sp == SP_WORKING_DIR && !_do_scan_working_directory) continue;
 
		DEBUG(misc, 4, "%s added as search path", _searchpaths[sp]);
 
	}
 

	
 
	char *config_dir;
 
	if (_config_file != NULL) {
 
		char *dir = strdup(_config_file);
 
		char *end = strrchr(dir, PATHSEPCHAR);
 
		config_dir = strdup(_config_file);
 
		char *end = strrchr(config_dir, PATHSEPCHAR);
 
		if (end == NULL) {
 
			dir[0] = '\0';
 
			config_dir[0] = '\0';
 
		} else {
 
			end[1] = '\0';
 
		}
 
		_personal_dir = dir;
 
	} else {
 
		char personal_dir[MAX_PATH];
 
		if (FioFindFullPath(personal_dir, lengthof(personal_dir), BASE_DIR, "openttd.cfg") != NULL) {
 
			char *end = strrchr(personal_dir, PATHSEPCHAR);
 
			if (end != NULL) end[1] = '\0';
 
			_personal_dir = strdup(personal_dir);
 
			_config_file = str_fmt("%sopenttd.cfg", _personal_dir);
 
			config_dir = strdup(personal_dir);
 
			_config_file = str_fmt("%sopenttd.cfg", config_dir);
 
		} else {
 
#if defined(WITH_XDG_BASEDIR) && defined(WITH_PERSONAL_DIR)
 
			/* No previous configuration file found. Use the configuration folder from XDG. */
 
			config_dir = config_home;
 
#else
 
			static const Searchpath new_openttd_cfg_order[] = {
 
					SP_PERSONAL_DIR, SP_BINARY_DIR, SP_WORKING_DIR, SP_SHARED_DIR, SP_INSTALLATION_DIR
 
				};
 

	
 
			for (uint i = 0; i < lengthof(new_openttd_cfg_order); i++) {
 
				if (IsValidSearchPath(new_openttd_cfg_order[i])) {
 
					_personal_dir = strdup(_searchpaths[new_openttd_cfg_order[i]]);
 
					_config_file = str_fmt("%sopenttd.cfg", _personal_dir);
 
					config_dir = strdup(_searchpaths[new_openttd_cfg_order[i]]);
 
					break;
 
				}
 
			}
 
#endif
 
			_config_file = str_fmt("%sopenttd.cfg", config_dir);
 
		}
 
	}
 

	
 
	DEBUG(misc, 3, "%s found as personal directory", _personal_dir);
 
	DEBUG(misc, 3, "%s found as config directory", config_dir);
 

	
 
	_highscore_file = str_fmt("%shs.dat", _personal_dir);
 
	_highscore_file = str_fmt("%shs.dat", config_dir);
 
	extern char *_hotkeys_file;
 
	_hotkeys_file = str_fmt("%shotkeys.cfg", _personal_dir);
 
	_hotkeys_file = str_fmt("%shotkeys.cfg", config_dir);
 
	extern char *_windows_file;
 
	_windows_file = str_fmt("%swindows.cfg", _personal_dir);
 
	_windows_file = str_fmt("%swindows.cfg", config_dir);
 

	
 
#if defined(WITH_XDG_BASEDIR) && defined(WITH_PERSONAL_DIR)
 
	if (config_dir == config_home) {
 
		/* We are using the XDG configuration home for the config file,
 
		 * then store the rest in the XDG data home folder. */
 
		_personal_dir = _searchpaths[SP_PERSONAL_DIR_XDG];
 
		FioCreateDirectory(_personal_dir);
 
	} else
 
#endif
 
	{
 
		_personal_dir = config_dir;
 
	}
 

	
 
	/* Make the necessary folders */
 
#if !defined(__MORPHOS__) && !defined(__AMIGA__) && defined(WITH_PERSONAL_DIR)
 
	FioCreateDirectory(_personal_dir);
 
	FioCreateDirectory(config_dir);
 
	if (config_dir != _personal_dir) FioCreateDirectory(_personal_dir);
 
#endif
 

	
 
	DEBUG(misc, 3, "%s found as personal directory", _personal_dir);
 

	
 
	static const Subdirectory default_subdirs[] = {
 
		SAVE_DIR, AUTOSAVE_DIR, SCENARIO_DIR, HEIGHTMAP_DIR, BASESET_DIR, NEWGRF_DIR, AI_DIR, AI_LIBRARY_DIR, GAME_DIR, GAME_LIBRARY_DIR, SCREENSHOT_DIR
 
	};
 

	
 
	for (uint i = 0; i < lengthof(default_subdirs); i++) {
 
		char *dir = str_fmt("%s%s", _personal_dir, _subdirs[default_subdirs[i]]);
 
		FioCreateDirectory(dir);
 
		free(dir);
 
	}
 

	
 
	/* If we have network we make a directory for the autodownloading of content */
 
	_searchpaths[SP_AUTODOWNLOAD_DIR] = str_fmt("%s%s", _personal_dir, "content_download" PATHSEP);
src/fileio_type.h
Show inline comments
 
@@ -34,24 +34,27 @@ enum Subdirectory {
 
	GAME_LIBRARY_DIR, ///< Subdirectory for all GS libraries
 
	SCREENSHOT_DIR,   ///< Subdirectory for all screenshots
 
	NUM_SUBDIRS,   ///< Number of subdirectories
 
	NO_DIRECTORY,  ///< A path without any base directory
 
};
 

	
 
/**
 
 * Types of searchpaths OpenTTD might use
 
 */
 
enum Searchpath {
 
	SP_FIRST_DIR,
 
	SP_WORKING_DIR = SP_FIRST_DIR, ///< Search in the working directory
 
#if defined(WITH_XDG_BASEDIR) && defined(WITH_PERSONAL_DIR)
 
	SP_PERSONAL_DIR_XDG,           ///< Search in the personal directory from the XDG specification
 
#endif
 
	SP_PERSONAL_DIR,               ///< Search in the personal directory
 
	SP_SHARED_DIR,                 ///< Search in the shared directory, like 'Shared Files' under Windows
 
	SP_BINARY_DIR,                 ///< Search in the directory where the binary resides
 
	SP_INSTALLATION_DIR,           ///< Search in the installation directory
 
	SP_APPLICATION_BUNDLE_DIR,     ///< Search within the application bundle
 
	SP_AUTODOWNLOAD_DIR,           ///< Search within the autodownload directory
 
	NUM_SEARCHPATHS
 
};
 

	
 
DECLARE_POSTFIX_INCREMENT(Searchpath)
 

	
 
#endif /* FILEIO_TYPE_H */
0 comments (0 inline, 0 general)