diff --git a/.hgignore b/.hgignore
index b6c427f82..c4b118779 100644
--- a/.hgignore
+++ b/.hgignore
@@ -76,6 +76,7 @@ test/testnative
test/testoverlay2
test/testplatform
test/testpower
+test/testfilesystem
test/testrelative
test/testrendercopyex
test/testrendertarget
diff --git a/Android.mk b/Android.mk
index 7338233c1..f3fcb3a19 100755
--- a/Android.mk
+++ b/Android.mk
@@ -33,6 +33,7 @@ LOCAL_SRC_FILES := \
$(wildcard $(LOCAL_PATH)/src/loadso/dlopen/*.c) \
$(wildcard $(LOCAL_PATH)/src/power/*.c) \
$(wildcard $(LOCAL_PATH)/src/power/android/*.c) \
+ $(wildcard $(LOCAL_PATH)/src/filesystem/dummy/*.c) \
$(wildcard $(LOCAL_PATH)/src/render/*.c) \
$(wildcard $(LOCAL_PATH)/src/render/*/*.c) \
$(wildcard $(LOCAL_PATH)/src/stdlib/*.c) \
diff --git a/CMakeLists.txt b/CMakeLists.txt
index d79b84bb1..8eca0c6b1 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -172,7 +172,7 @@ include_directories(${SDL2_BINARY_DIR}/include ${SDL2_SOURCE_DIR}/include)
set(SDL_SUBSYSTEMS
Atomic Audio Video Render Events Joystick Haptic Power Threads Timers
- File Loadso CPUinfo)
+ File Loadso CPUinfo Filesystem)
foreach(_SUB ${SDL_SUBSYSTEMS})
string(TOUPPER ${_SUB} _OPT)
option(SDL_${_OPT} "Enable the ${_SUB} subsystem" ON)
@@ -714,6 +714,13 @@ if(UNIX AND NOT APPLE)
endif(LINUX)
endif(SDL_POWER)
+ if(SDL_FILESYSTEM)
+ set(SDL_FILESYSTEM_UNIX 1)
+ file(GLOB FILESYSTEM_SOURCES ${SDL2_SOURCE_DIR}/src/unix/*.c)
+ set(SOURCE_FILES ${SOURCE_FILES} ${FILESYSTEM_SOURCES})
+ set(HAVE_SDL_FILESYSTEM TRUE)
+ endif(SDL_FILESYSTEM)
+
if(SDL_TIMERS)
set(SDL_TIMER_UNIX 1)
file(GLOB TIMER_SOURCES ${SDL2_SOURCE_DIR}/src/timer/unix/*.c)
@@ -814,6 +821,13 @@ elseif(WINDOWS)
set(HAVE_SDL_POWER TRUE)
endif(SDL_POWER)
+ if(SDL_FILESYSTEM)
+ set(SDL_FILESYSTEM_WINDOWS 1)
+ file(GLOB FILESYSTEM_SOURCES ${SDL2_SOURCE_DIR}/src/filesytem/windows/*.c)
+ set(SOURCE_FILES ${SOURCE_FILES} ${FILESYSTEM_SOURCES})
+ set(HAVE_SDL_FILESYSTEM TRUE)
+ endif(SDL_FILESYSTEM)
+
# Libraries for Win32 native and MinGW
list(APPEND EXTRA_LIBS user32 gdi32 winmm imm32 ole32 oleaut32 version uuid)
@@ -924,6 +938,13 @@ elseif(APPLE)
set(SDL_FRAMEWORK_IOKIT 1)
endif()
+ if(SDL_FILESYSTEM)
+ set(SDL_FILESYSTEM_COCOA 1)
+ file(GLOB FILESYSTEM_SOURCES ${SDL2_SOURCE_DIR}/src/filesystem/cocoa/*.m)
+ set(SOURCE_FILES ${SOURCE_FILES} ${FILESYSTEM_SOURCES})
+ set(HAVE_SDL_FILESYSTEM TRUE)
+ endif()
+
# Actually load the frameworks at the end so we don't duplicate include.
if(SDL_FRAMEWORK_COCOA)
find_library(COCOA_LIBRARY Cocoa)
@@ -973,6 +994,11 @@ elseif(BEOS)
set(SOURCE_FILES ${SOURCE_FILES} ${BWINDOW_SOURCES})
set(HAVE_SDL_VIDEO TRUE)
+ set(SDL_FILESYSTEM_BEOS 1)
+ file(GLOB FILESYSTEM_SOURCES ${SDL2_SOURCE_DIR}/src/beos/*.cc)
+ set(SOURCE_FILES ${SOURCE_FILES} ${FILESYSTEM_SOURCES})
+ set(HAVE_SDL_FILESYSTEM TRUE)
+
if(VIDEO_OPENGL)
# TODO: Use FIND_PACKAGE(OpenGL) instead
set(SDL_VIDEO_OPENGL 1)
@@ -1010,6 +1036,11 @@ if(NOT HAVE_SDL_LOADSO)
file(GLOB LOADSO_SOURCES ${SDL2_SOURCE_DIR}/src/loadso/dummy/*.c)
set(SOURCE_FILES ${SOURCE_FILES} ${LOADSO_SOURCES})
endif(NOT HAVE_SDL_LOADSO)
+if(NOT HAVE_SDL_FILESYSTEM)
+ set(SDL_FILESYSTEM_DISABLED 1)
+ file(GLOB FILESYSTEM_SOURCES ${SDL2_SOURCE_DIR}/src/filesystem/dummy/*.c)
+ set(SOURCE_FILES ${SOURCE_FILES} ${FILESYSTEM_SOURCES})
+endif(NOT HAVE_SDL_FILESYSTEM)
# We always need to have threads and timers around
if(NOT HAVE_SDL_THREADS)
diff --git a/Makefile.in b/Makefile.in
index ae6293e7d..da42661c5 100644
--- a/Makefile.in
+++ b/Makefile.in
@@ -54,6 +54,7 @@ HDRS = \
SDL_endian.h \
SDL_error.h \
SDL_events.h \
+ SDL_filesystem.h \
SDL_gamecontroller.h \
SDL_gesture.h \
SDL_haptic.h \
diff --git a/Makefile.minimal b/Makefile.minimal
index a06083230..6ec1ce81c 100644
--- a/Makefile.minimal
+++ b/Makefile.minimal
@@ -19,6 +19,7 @@ SOURCES = \
src/joystick/dummy/*.c \
src/loadso/dummy/*.c \
src/power/*.c \
+ src/filesystem/dummy/*.c \
src/render/*.c \
src/render/software/*.c \
src/stdlib/*.c \
diff --git a/Makefile.pandora b/Makefile.pandora
index de15c846b..bb89d52a6 100644
--- a/Makefile.pandora
+++ b/Makefile.pandora
@@ -19,7 +19,7 @@ SOURCES = ./src/*.c ./src/audio/*.c ./src/cpuinfo/*.c ./src/events/*.c \
./src/thread/pthread/SDL_systhread.c ./src/thread/pthread/SDL_syssem.c \
./src/thread/pthread/SDL_sysmutex.c ./src/thread/pthread/SDL_syscond.c \
./src/joystick/linux/*.c ./src/haptic/linux/*.c ./src/timer/unix/*.c \
- ./src/atomic/linux/*.c \
+ ./src/atomic/linux/*.c ./src/filesystem/unix/*.c \
./src/video/pandora/SDL_pandora.o ./src/video/pandora/SDL_pandora_events.o ./src/video/x11/*.c
diff --git a/Makefile.psp b/Makefile.psp
index 8bcdcb927..5e7dcd29a 100644
--- a/Makefile.psp
+++ b/Makefile.psp
@@ -31,6 +31,7 @@ OBJS= src/SDL.o \
src/joystick/psp/SDL_sysjoystick.o \
src/power/SDL_power.o \
src/power/psp/SDL_syspower.o \
+ src/filesystem/dummy/SDL_sysfilesystem.o \
src/render/SDL_render.o \
src/render/SDL_yuv_sw.o \
src/render/psp/SDL_render_psp.o \
diff --git a/VisualC/SDL/SDL_VS2008.vcproj b/VisualC/SDL/SDL_VS2008.vcproj
index 72eb2d4c9..1e7db21a3 100644
--- a/VisualC/SDL/SDL_VS2008.vcproj
+++ b/VisualC/SDL/SDL_VS2008.vcproj
@@ -427,6 +427,10 @@
RelativePath="..\..\include\SDL_events.h"
>
+
+
@@ -1088,6 +1092,10 @@
RelativePath="..\..\src\events\SDL_sysevents.h"
>
+
+
diff --git a/VisualC/SDL/SDL_VS2010.vcxproj b/VisualC/SDL/SDL_VS2010.vcxproj
index 4fa9111d2..58807a5af 100644
--- a/VisualC/SDL/SDL_VS2010.vcxproj
+++ b/VisualC/SDL/SDL_VS2010.vcxproj
@@ -229,6 +229,7 @@
+
@@ -430,6 +431,7 @@
+
diff --git a/VisualC/SDL/SDL_VS2012.vcxproj b/VisualC/SDL/SDL_VS2012.vcxproj
index 213c10cef..141bc6481 100644
--- a/VisualC/SDL/SDL_VS2012.vcxproj
+++ b/VisualC/SDL/SDL_VS2012.vcxproj
@@ -19,7 +19,7 @@
- SDL2
+ SDL2
{81CE8DAF-EBB2-4761-8E45-B71ABCCA8C68}
SDL
@@ -233,6 +233,7 @@
+
@@ -433,6 +434,7 @@
+
diff --git a/configure b/configure
index 41adac4b0..f4c3f6ae4 100755
--- a/configure
+++ b/configure
@@ -783,6 +783,7 @@ enable_events
enable_joystick
enable_haptic
enable_power
+enable_filesystem
enable_threads
enable_timers
enable_file
@@ -1496,6 +1497,7 @@ Optional Features:
--enable-haptic Enable the haptic (force feedback) subsystem
[[default=yes]]
--enable-power Enable the power subsystem [[default=yes]]
+ --enable-filesystem Enable the filesystem subsystem [[default=yes]]
--enable-threads Enable the threading subsystem [[default=yes]]
--enable-timers Enable the timer subsystem [[default=yes]]
--enable-file Enable the file subsystem [[default=yes]]
@@ -16767,6 +16769,7 @@ SOURCES="$SOURCES $srcdir/src/haptic/*.c"
SOURCES="$SOURCES $srcdir/src/joystick/*.c"
SOURCES="$SOURCES $srcdir/src/libm/*.c"
SOURCES="$SOURCES $srcdir/src/power/*.c"
+#SOURCES="$SOURCES $srcdir/src/filesystem/*.c"
SOURCES="$SOURCES $srcdir/src/render/*.c"
SOURCES="$SOURCES $srcdir/src/render/*/*.c"
SOURCES="$SOURCES $srcdir/src/stdlib/*.c"
@@ -16870,6 +16873,18 @@ if test x$enable_power != xyes; then
$as_echo "#define SDL_POWER_DISABLED 1" >>confdefs.h
+fi
+# Check whether --enable-filesystem was given.
+if test "${enable_filesystem+set}" = set; then :
+ enableval=$enable_filesystem;
+else
+ enable_filesystem=yes
+fi
+
+if test x$enable_filesystem != xyes; then
+
+$as_echo "#define SDL_FILESYSTEM_DISABLED 1" >>confdefs.h
+
fi
# Check whether --enable-threads was given.
if test "${enable_threads+set}" = set; then :
@@ -22120,6 +22135,14 @@ $as_echo "#define SDL_POWER_LINUX 1" >>confdefs.h
;;
esac
fi
+ # Set up files for the filesystem library
+ if test x$enable_filesystem = xyes; then
+
+$as_echo "#define SDL_FILESYSTEM_UNIX 1" >>confdefs.h
+
+ SOURCES="$SOURCES $srcdir/src/filesystem/unix/*.c"
+ have_filesystem=yes
+ fi
# Set up files for the timer library
if test x$enable_timers = xyes; then
@@ -22222,6 +22245,13 @@ $as_echo "#define SDL_POWER_WINDOWS 1" >>confdefs.h
SOURCES="$SOURCES $srcdir/src/power/windows/SDL_syspower.c"
have_power=yes
fi
+ if test x$enable_filesystem = xyes; then
+
+$as_echo "#define SDL_FILESYSTEM_WINDOWS 1" >>confdefs.h
+
+ SOURCES="$SOURCES $srcdir/src/filesystem/windows/SDL_sysfilesystem.c"
+ have_filesystem=yes
+ fi
# Set up files for the thread library
if test x$enable_threads = xyes; then
@@ -22355,6 +22385,14 @@ $as_echo "#define SDL_POWER_BEOS 1" >>confdefs.h
SOURCES="$SOURCES $srcdir/src/power/beos/*.c"
have_power=yes
fi
+ # Set up files for the system filesystem library
+ if test x$enable_filesystem = xyes; then
+
+$as_echo "#define SDL_FILESYSTEM_BEOS 1" >>confdefs.h
+
+ SOURCES="$SOURCES $srcdir/src/power/beos/*.cc"
+ have_filesystem=yes
+ fi
# The BeOS platform requires special setup.
SOURCES="$srcdir/src/main/beos/*.cc $SOURCES"
EXTRA_LDFLAGS="$EXTRA_LDFLAGS -lroot -lbe -lmedia -lgame -ldevice -ltextencoding"
@@ -22389,10 +22427,10 @@ $as_echo "#define SDL_POWER_BEOS 1" >>confdefs.h
# have_haptic=yes
# EXTRA_LDFLAGS="$EXTRA_LDFLAGS -Wl,-framework,ForceFeedback"
#fi
- # Set up files for the power library
- if test x$enable_power = xyes; then
- SOURCES="$SOURCES $srcdir/src/power/uikit/*.m"
- have_power=yes
+ # Set up files for the filesystem library
+ if test x$enable_filesystem = xyes; then
+ SOURCES="$SOURCES $srcdir/src/filesystem/cocoa/*.m"
+ have_filesystem=yes
fi
# Set up files for the timer library
if test x$enable_timers = xyes; then
@@ -22475,6 +22513,14 @@ $as_echo "#define SDL_POWER_MACOSX 1" >>confdefs.h
SOURCES="$SOURCES $srcdir/src/power/macosx/*.c"
have_power=yes
fi
+ # Set up files for the filesystem library
+ if test x$enable_filesystem = xyes; then
+
+$as_echo "#define SDL_FILESYSTEM_COCOA 1" >>confdefs.h
+
+ SOURCES="$SOURCES $srcdir/src/filesystem/cocoa/*.m"
+ have_filesystem=yes
+ fi
# Set up files for the timer library
if test x$enable_timers = xyes; then
@@ -22541,6 +22587,14 @@ $as_echo "#define SDL_TIMERS_DISABLED 1" >>confdefs.h
fi
SOURCES="$SOURCES $srcdir/src/timer/dummy/*.c"
fi
+if test x$have_filesystem != xyes; then
+ if test x$enable_filesystem = xyes; then
+
+$as_echo "#define SDL_FILESYSTEM_DISABLED 1" >>confdefs.h
+
+ fi
+ SOURCES="$SOURCES $srcdir/src/filesystem/dummy/*.c"
+fi
if test x$have_loadso != xyes; then
if test x$enable_loadso = xyes; then
diff --git a/configure.in b/configure.in
index de32e6a12..f9d0bf2ed 100644
--- a/configure.in
+++ b/configure.in
@@ -325,6 +325,7 @@ SOURCES="$SOURCES $srcdir/src/haptic/*.c"
SOURCES="$SOURCES $srcdir/src/joystick/*.c"
SOURCES="$SOURCES $srcdir/src/libm/*.c"
SOURCES="$SOURCES $srcdir/src/power/*.c"
+#SOURCES="$SOURCES $srcdir/src/filesystem/*.c"
SOURCES="$SOURCES $srcdir/src/render/*.c"
SOURCES="$SOURCES $srcdir/src/render/*/*.c"
SOURCES="$SOURCES $srcdir/src/stdlib/*.c"
@@ -382,6 +383,12 @@ AC_HELP_STRING([--enable-power], [Enable the power subsystem [[default=yes]]]),
if test x$enable_power != xyes; then
AC_DEFINE(SDL_POWER_DISABLED, 1, [ ])
fi
+AC_ARG_ENABLE(filesystem,
+AC_HELP_STRING([--enable-filesystem], [Enable the filesystem subsystem [[default=yes]]]),
+ , enable_filesystem=yes)
+if test x$enable_filesystem != xyes; then
+ AC_DEFINE(SDL_FILESYSTEM_DISABLED, 1, [ ])
+fi
AC_ARG_ENABLE(threads,
AC_HELP_STRING([--enable-threads], [Enable the threading subsystem [[default=yes]]]),
, enable_threads=yes)
@@ -2431,6 +2438,12 @@ case "$host" in
;;
esac
fi
+ # Set up files for the filesystem library
+ if test x$enable_filesystem = xyes; then
+ AC_DEFINE(SDL_FILESYSTEM_UNIX, 1, [ ])
+ SOURCES="$SOURCES $srcdir/src/filesystem/unix/*.c"
+ have_filesystem=yes
+ fi
# Set up files for the timer library
if test x$enable_timers = xyes; then
AC_DEFINE(SDL_TIMER_UNIX, 1, [ ])
@@ -2509,6 +2522,11 @@ AC_HELP_STRING([--enable-render-d3d], [enable the Direct3D render driver [[defau
SOURCES="$SOURCES $srcdir/src/power/windows/SDL_syspower.c"
have_power=yes
fi
+ if test x$enable_filesystem = xyes; then
+ AC_DEFINE(SDL_FILESYSTEM_WINDOWS, 1, [ ])
+ SOURCES="$SOURCES $srcdir/src/filesystem/windows/SDL_sysfilesystem.c"
+ have_filesystem=yes
+ fi
# Set up files for the thread library
if test x$enable_threads = xyes; then
AC_DEFINE(SDL_THREAD_WINDOWS, 1, [ ])
@@ -2591,6 +2609,12 @@ AC_HELP_STRING([--enable-render-d3d], [enable the Direct3D render driver [[defau
SOURCES="$SOURCES $srcdir/src/power/beos/*.c"
have_power=yes
fi
+ # Set up files for the system filesystem library
+ if test x$enable_filesystem = xyes; then
+ AC_DEFINE(SDL_FILESYSTEM_BEOS, 1, [ ])
+ SOURCES="$SOURCES $srcdir/src/power/beos/*.cc"
+ have_filesystem=yes
+ fi
# The BeOS platform requires special setup.
SOURCES="$srcdir/src/main/beos/*.cc $SOURCES"
EXTRA_LDFLAGS="$EXTRA_LDFLAGS -lroot -lbe -lmedia -lgame -ldevice -ltextencoding"
@@ -2630,6 +2654,11 @@ AC_HELP_STRING([--enable-render-d3d], [enable the Direct3D render driver [[defau
SOURCES="$SOURCES $srcdir/src/power/uikit/*.m"
have_power=yes
fi
+ # Set up files for the filesystem library
+ if test x$enable_filesystem = xyes; then
+ SOURCES="$SOURCES $srcdir/src/filesystem/cocoa/*.m"
+ have_filesystem=yes
+ fi
# Set up files for the timer library
if test x$enable_timers = xyes; then
SOURCES="$SOURCES $srcdir/src/timer/unix/*.c"
@@ -2703,6 +2732,12 @@ AC_HELP_STRING([--enable-render-d3d], [enable the Direct3D render driver [[defau
SOURCES="$SOURCES $srcdir/src/power/macosx/*.c"
have_power=yes
fi
+ # Set up files for the filesystem library
+ if test x$enable_filesystem = xyes; then
+ AC_DEFINE(SDL_FILESYSTEM_COCOA, 1, [ ])
+ SOURCES="$SOURCES $srcdir/src/filesystem/cocoa/*.m"
+ have_filesystem=yes
+ fi
# Set up files for the timer library
if test x$enable_timers = xyes; then
AC_DEFINE(SDL_TIMER_UNIX, 1, [ ])
@@ -2760,6 +2795,12 @@ if test x$have_timers != xyes; then
fi
SOURCES="$SOURCES $srcdir/src/timer/dummy/*.c"
fi
+if test x$have_filesystem != xyes; then
+ if test x$enable_filesystem = xyes; then
+ AC_DEFINE(SDL_FILESYSTEM_DISABLED, 1, [ ])
+ fi
+ SOURCES="$SOURCES $srcdir/src/filesystem/dummy/*.c"
+fi
if test x$have_loadso != xyes; then
if test x$enable_loadso = xyes; then
AC_DEFINE(SDL_LOADSO_DISABLED, 1, [ ])
diff --git a/include/SDL.h b/include/SDL.h
index ca098ae6e..8b8a61c14 100644
--- a/include/SDL.h
+++ b/include/SDL.h
@@ -74,6 +74,7 @@
#include "SDL_endian.h"
#include "SDL_error.h"
#include "SDL_events.h"
+#include "SDL_filesystem.h"
#include "SDL_joystick.h"
#include "SDL_gamecontroller.h"
#include "SDL_haptic.h"
diff --git a/include/SDL_config.h.cmake b/include/SDL_config.h.cmake
index 12c14fa24..500e72a2d 100644
--- a/include/SDL_config.h.cmake
+++ b/include/SDL_config.h.cmake
@@ -182,6 +182,7 @@
#cmakedefine SDL_TIMERS_DISABLED @SDL_TIMERS_DISABLED@
#cmakedefine SDL_VIDEO_DISABLED @SDL_VIDEO_DISABLED@
#cmakedefine SDL_POWER_DISABLED @SDL_POWER_DISABLED@
+#cmakedefine SDL_FILESYSTEM_DISABLED @SDL_FILESYSTEM_DISABLED@
/* Enable various audio drivers */
#cmakedefine SDL_AUDIO_DRIVER_ALSA @SDL_AUDIO_DRIVER_ALSA@
@@ -301,6 +302,13 @@
#cmakedefine SDL_POWER_BEOS @SDL_POWER_BEOS@
#cmakedefine SDL_POWER_HARDWIRED @SDL_POWER_HARDWIRED@
+/* Enable system filesystem support */
+#cmakedefine SDL_FILESYSTEM_BEOS @SDL_FILESYSTEM_BEOS@
+#cmakedefine SDL_FILESYSTEM_COCOA @SDL_FILESYSTEM_COCOA@
+#cmakedefine SDL_FILESYSTEM_DUMMY @SDL_FILESYSTEM_DUMMY@
+#cmakedefine SDL_FILESYSTEM_UNIX @SDL_FILESYSTEM_UNIX@
+#cmakedefine SDL_FILESYSTEM_WINDOWS @SDL_FILESYSTEM_WINDOWS@
+
/* Enable assembly routines */
#cmakedefine SDL_ASSEMBLY_ROUTINES @SDL_ASSEMBLY_ROUTINES@
#cmakedefine SDL_ALTIVEC_BLITTERS @SDL_ALTIVEC_BLITTERS@
diff --git a/include/SDL_config.h.in b/include/SDL_config.h.in
index 3f92d57b2..7bb12832f 100644
--- a/include/SDL_config.h.in
+++ b/include/SDL_config.h.in
@@ -184,6 +184,7 @@
#undef SDL_TIMERS_DISABLED
#undef SDL_VIDEO_DISABLED
#undef SDL_POWER_DISABLED
+#undef SDL_FILESYSTEM_DISABLED
/* Enable various audio drivers */
#undef SDL_AUDIO_DRIVER_ALSA
@@ -303,6 +304,13 @@
#undef SDL_POWER_BEOS
#undef SDL_POWER_HARDWIRED
+/* Enable system filesystem support */
+#undef SDL_FILESYSTEM_BEOS
+#undef SDL_FILESYSTEM_COCOA
+#undef SDL_FILESYSTEM_DUMMY
+#undef SDL_FILESYSTEM_UNIX
+#undef SDL_FILESYSTEM_WINDOWS
+
/* Enable assembly routines */
#undef SDL_ASSEMBLY_ROUTINES
#undef SDL_ALTIVEC_BLITTERS
diff --git a/include/SDL_config_android.h b/include/SDL_config_android.h
index 7c6b6cb51..0826415c6 100644
--- a/include/SDL_config_android.h
+++ b/include/SDL_config_android.h
@@ -136,4 +136,7 @@
/* Enable system power support */
#define SDL_POWER_ANDROID 1
+/* !!! FIXME: what does Android do for filesystem stuff? */
+#define SDL_FILESYSTEM_DUMMY 1
+
#endif /* _SDL_config_android_h */
diff --git a/include/SDL_config_iphoneos.h b/include/SDL_config_iphoneos.h
index b27b18973..ade296614 100644
--- a/include/SDL_config_iphoneos.h
+++ b/include/SDL_config_iphoneos.h
@@ -148,4 +148,7 @@
*/
#define SDL_IPHONE_MAX_GFORCE 5.0
+/* enable filesystem support */
+#define SDL_FILESYSTEM_COCOA 1
+
#endif /* _SDL_config_iphoneos_h */
diff --git a/include/SDL_config_macosx.h b/include/SDL_config_macosx.h
index 68a0ebb9b..9f2f76e3f 100644
--- a/include/SDL_config_macosx.h
+++ b/include/SDL_config_macosx.h
@@ -171,6 +171,9 @@
/* Enable system power support */
#define SDL_POWER_MACOSX 1
+/* enable filesystem support */
+#define SDL_FILESYSTEM_COCOA 1
+
/* Enable assembly routines */
#define SDL_ASSEMBLY_ROUTINES 1
#ifdef __ppc__
diff --git a/include/SDL_config_minimal.h b/include/SDL_config_minimal.h
index fe3cebc7e..3248bdda1 100644
--- a/include/SDL_config_minimal.h
+++ b/include/SDL_config_minimal.h
@@ -75,4 +75,7 @@ typedef unsigned long uintptr_t;
/* Enable the dummy video driver (src/video/dummy/\*.c) */
#define SDL_VIDEO_DRIVER_DUMMY 1
+/* Enable the dummy filesystem driver (src/filesystem/dummy/\*.c) */
+#define SDL_FILESYSTEM_DUMMY 1
+
#endif /* _SDL_config_minimal_h */
diff --git a/include/SDL_config_pandora.h b/include/SDL_config_pandora.h
index b93a1bc1a..4bfad4861 100644
--- a/include/SDL_config_pandora.h
+++ b/include/SDL_config_pandora.h
@@ -114,6 +114,7 @@
#define SDL_THREAD_PTHREAD_RECURSIVE_MUTEX_NP 1
#define SDL_TIMER_UNIX 1
+#define SDL_FILESYSTEM_UNIX 1
#define SDL_VIDEO_DRIVER_DUMMY 1
#define SDL_VIDEO_DRIVER_X11 1
diff --git a/include/SDL_config_psp.h b/include/SDL_config_psp.h
index 85cf53c27..09eef29d9 100644
--- a/include/SDL_config_psp.h
+++ b/include/SDL_config_psp.h
@@ -126,6 +126,9 @@
#define SDL_POWER_PSP 1
+/* !!! FIXME: what does PSP do for filesystem stuff? */
+#define SDL_FILESYSTEM_DUMMY 1
+
/* PSP doesn't have haptic device (src/haptic/dummy/\*.c) */
#define SDL_HAPTIC_DISABLED 1
diff --git a/include/SDL_config_windows.h b/include/SDL_config_windows.h
index 0b7621564..9f3448ec3 100644
--- a/include/SDL_config_windows.h
+++ b/include/SDL_config_windows.h
@@ -181,6 +181,9 @@ typedef unsigned int uintptr_t;
/* Enable system power support */
#define SDL_POWER_WINDOWS 1
+/* Enable filesystem support */
+#define SDL_FILESYSTEM_WINDOWS 1
+
/* Enable assembly routines (Win64 doesn't have inline asm) */
#ifndef _WIN64
#define SDL_ASSEMBLY_ROUTINES 1
diff --git a/include/SDL_filesystem.h b/include/SDL_filesystem.h
new file mode 100644
index 000000000..71ced94fd
--- /dev/null
+++ b/include/SDL_filesystem.h
@@ -0,0 +1,136 @@
+/*
+ Simple DirectMedia Layer
+ Copyright (C) 1997-2013 Sam Lantinga
+
+ This software is provided 'as-is', without any express or implied
+ warranty. In no event will the authors be held liable for any damages
+ arising from the use of this software.
+
+ Permission is granted to anyone to use this software for any purpose,
+ including commercial applications, and to alter it and redistribute it
+ freely, subject to the following restrictions:
+
+ 1. The origin of this software must not be misrepresented; you must not
+ claim that you wrote the original software. If you use this software
+ in a product, an acknowledgment in the product documentation would be
+ appreciated but is not required.
+ 2. Altered source versions must be plainly marked as such, and must not be
+ misrepresented as being the original software.
+ 3. This notice may not be removed or altered from any source distribution.
+*/
+
+/**
+ * \file SDL_filesystem.h
+ *
+ * \brief Include file for filesystem SDL API functions
+ */
+
+#ifndef _SDL_filesystem_h
+#define _SDL_filesystem_h
+
+#include "SDL_stdinc.h"
+
+#include "begin_code.h"
+
+/* Set up for C function definitions, even when using C++ */
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/**
+ * \brief Get the path where the application resides.
+ *
+ * Get the "base path". This is the directory where the application was run
+ * from, which is probably the installation directory, and may or may not
+ * be the process's current working directory.
+ *
+ * This returns an absolute path in UTF-8 encoding, and is guaranteed to
+ * end with a path separator ('\\' on Windows, '/' most other places).
+ *
+ * The pointer returned by this function is owned by you. Please call
+ * SDL_free() on the pointer when you are done with it, or it will be a
+ * memory leak. This is not necessarily a fast call, though, so you should
+ * call this once near startup and save the string if you need it.
+ *
+ * Some platforms can't determine the application's path, and on other
+ * platforms, this might be meaningless. In such cases, this function will
+ * return NULL.
+ *
+ * \return String of base dir in UTF-8 encoding, or NULL on error.
+ *
+ * \sa SDL_GetPrefPath
+ */
+extern DECLSPEC char *SDLCALL SDL_GetBasePath(void);
+
+/**
+ * \brief Get the user-and-app-specific path where files can be written.
+ *
+ * Get the "pref dir". This is meant to be where users can write personal
+ * files (preferences and save games, etc) that are specific to your
+ * application. This directory is unique per user, per application.
+ *
+ * This function will decide the appropriate location in the native filesystem,
+ * create the directory if necessary, and return a string of the absolute
+ * path to the directory in UTF-8 encoding.
+ *
+ * On Windows, the string might look like:
+ * "C:\\Users\\bob\\AppData\\Roaming\\My Company\\My Program Name"
+ *
+ * On Linux, the string might look like:
+ * "/home/bob/.local/share/My Program Name"
+ *
+ * On Mac OS X, the string might look like:
+ * "/Users/bob/Library/Application Support/My Program Name"
+ *
+ * (etc.)
+ *
+ * You specify the name of your organization (if it's not a real organization,
+ * your name or an Internet domain you own might do) and the name of your
+ * application. These should be untranslated proper names.
+ *
+ * Both the org and app strings may become part of a directory name, so
+ * please follow these rules:
+ *
+ * - Try to use the same org string (including case-sensitivity) for
+ * all your applications that use this function.
+ * - Always use a unique app string for each one, and make sure it never
+ * changes for an app once you've decided on it.
+ * - Unicode characters are legal, as long as it's UTF-8 encoded, but...
+ * - ...only use letters, numbers, and spaces. Avoid punctuation like
+ * "Game Name 2: Bad Guy's Revenge!" ... "Game Name 2" is sufficient.
+ *
+ * This returns an absolute path in UTF-8 encoding, and is guaranteed to
+ * end with a path separator ('\\' on Windows, '/' most other places).
+ *
+ * The pointer returned by this function is owned by you. Please call
+ * SDL_free() on the pointer when you are done with it, or it will be a
+ * memory leak. This is not necessarily a fast call, though, so you should
+ * call this once near startup and save the string if you need it.
+ *
+ * You should assume the path returned by this function is the only safe
+ * place to write files (and that SDL_GetBasePath(), while it might be
+ * writable, or even the parent of the returned path, aren't where you
+ * should be writing things).
+ *
+ * Some platforms can't determine the pref path, and on other
+ * platforms, this might be meaningless. In such cases, this function will
+ * return NULL.
+ *
+ * \param org The name of your organization.
+ * \param app The name of your application.
+ * \return UTF-8 string of user dir in platform-dependent notation. NULL
+ * if there's a problem (creating directory failed, etc).
+ *
+ * \sa SDL_GetBasePath
+ */
+extern DECLSPEC char *SDLCALL SDL_GetPrefPath(const char *org, const char *app);
+
+/* Ends C function definitions when using C++ */
+#ifdef __cplusplus
+}
+#endif
+#include "close_code.h"
+
+#endif /* _SDL_system_h */
+
+/* vi: set ts=4 sw=4 expandtab: */
diff --git a/src/filesystem/beos/SDL_sysfilesystem.cc b/src/filesystem/beos/SDL_sysfilesystem.cc
new file mode 100644
index 000000000..7b63fab34
--- /dev/null
+++ b/src/filesystem/beos/SDL_sysfilesystem.cc
@@ -0,0 +1,92 @@
+/*
+ Simple DirectMedia Layer
+ Copyright (C) 1997-2013 Sam Lantinga
+
+ This software is provided 'as-is', without any express or implied
+ warranty. In no event will the authors be held liable for any damages
+ arising from the use of this software.
+
+ Permission is granted to anyone to use this software for any purpose,
+ including commercial applications, and to alter it and redistribute it
+ freely, subject to the following restrictions:
+
+ 1. The origin of this software must not be misrepresented; you must not
+ claim that you wrote the original software. If you use this software
+ in a product, an acknowledgment in the product documentation would be
+ appreciated but is not required.
+ 2. Altered source versions must be plainly marked as such, and must not be
+ misrepresented as being the original software.
+ 3. This notice may not be removed or altered from any source distribution.
+*/
+#include "SDL_config.h"
+
+#ifdef SDL_FILESYSTEM_BEOS
+
+/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
+/* System dependent filesystem routines */
+
+#include
+#include
+#include
+
+#include "SDL_error.h"
+#include "SDL_stdinc.h"
+#include "SDL_assert.h"
+#include "SDL_filesystem.h"
+
+char *
+SDL_GetBasePath(void)
+{
+ image_info info;
+ int32 cookie = 0;
+
+ while (get_next_image_info(0, &cookie, &info) == B_OK) {
+ if (info.type == B_APP_IMAGE) {
+ break;
+ }
+ }
+
+ BEntry entry(info.name, true);
+ BPath path;
+ status_t rc = entry.GetPath(&path); /* (path) now has binary's path. */
+ SDL_assert(rc == B_OK);
+ rc = path.GetParent(&path); /* chop filename, keep directory. */
+ SDL_assert(rc == B_OK);
+ const char *str = path.Path();
+ SDL_assert(str != NULL);
+
+ const size_t len = SDL_strlen(str);
+ char *retval = (char *) SDL_malloc(len + 2);
+ if (!retval) {
+ SDL_OutOfMemory();
+ return NULL;
+ }
+
+ SDL_strcpy(retval, str);
+ retval[len] = '/';
+ retval[len+1] = '\0';
+ return retval;
+}
+
+
+char *
+SDL_GetPrefPath(const char *org, const char *app)
+{
+ // !!! FIXME: is there a better way to do this?
+ const char *home = SDL_getenv("HOME");
+ const char *append = "config/settings/";
+ const size_t len = SDL_strlen(home) + SDL_strlen(append) + SDL_strlen(app) + 2;
+ char *retval = (char *) SDL_malloc(len);
+ if (!retval) {
+ SDL_OutOfMemory();
+ } else {
+ SDL_snprintf(retval, len, "%s%s%s/", home, append, app);
+ create_directory(retval, 0700); // BeOS api: creates missing dirs
+ }
+
+ return retval;
+}
+
+#endif /* SDL_FILESYSTEM_BEOS */
+
+/* vi: set ts=4 sw=4 expandtab: */
diff --git a/src/filesystem/cocoa/SDL_sysfilesystem.m b/src/filesystem/cocoa/SDL_sysfilesystem.m
new file mode 100644
index 000000000..3c4597455
--- /dev/null
+++ b/src/filesystem/cocoa/SDL_sysfilesystem.m
@@ -0,0 +1,93 @@
+/*
+ Simple DirectMedia Layer
+ Copyright (C) 1997-2013 Sam Lantinga
+
+ This software is provided 'as-is', without any express or implied
+ warranty. In no event will the authors be held liable for any damages
+ arising from the use of this software.
+
+ Permission is granted to anyone to use this software for any purpose,
+ including commercial applications, and to alter it and redistribute it
+ freely, subject to the following restrictions:
+
+ 1. The origin of this software must not be misrepresented; you must not
+ claim that you wrote the original software. If you use this software
+ in a product, an acknowledgment in the product documentation would be
+ appreciated but is not required.
+ 2. Altered source versions must be plainly marked as such, and must not be
+ misrepresented as being the original software.
+ 3. This notice may not be removed or altered from any source distribution.
+*/
+#include "SDL_config.h"
+
+#ifdef SDL_FILESYSTEM_COCOA
+
+/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
+/* System dependent filesystem routines */
+
+#include
+#include
+
+#include "SDL_error.h"
+#include "SDL_stdinc.h"
+#include "SDL_filesystem.h"
+
+char *
+SDL_GetBasePath(void)
+{
+ NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
+ const char *base = [[[NSBundle mainBundle] bundlePath] UTF8String];
+ char *retval = NULL;
+ if (base) {
+ const size_t len = SDL_strlen(base) + 2;
+ retval = (char *) SDL_malloc(len);
+ if (retval == NULL) {
+ SDL_OutOfMemory();
+ } else {
+ SDL_snprintf(retval, len, "%s/", base);
+ }
+ }
+
+ [pool release];
+ return retval;
+}
+
+char *
+SDL_GetPrefPath(const char *org, const char *app)
+{
+ NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
+ NSArray *array = NSSearchPathForDirectoriesInDomains(NSApplicationSupportDirectory, NSUserDomainMask, YES);
+ char *retval = NULL;
+
+ (void) org; // unused on Mac OS X and iOS.
+
+ if ([array count] > 0) { // we only want the first item in the list.
+ NSString *str = [array objectAtIndex:0];
+ const char *base = [str UTF8String];
+ if (base) {
+ const size_t len = SDL_strlen(base) + SDL_strlen(app) + 3;
+ retval = (char *) SDL_malloc(len);
+ if (retval == NULL) {
+ SDL_OutOfMemory();
+ } else {
+ char *ptr;
+ SDL_snprintf(retval, len, "%s/%s/", base, app);
+ for (ptr = retval+1; *ptr; ptr++) {
+ if (*ptr == '/') {
+ *ptr = '\0';
+ mkdir(retval, 0700);
+ *ptr = '/';
+ }
+ }
+ mkdir(retval, 0700);
+ }
+ }
+ }
+
+ [pool release];
+ return retval;
+}
+
+#endif /* SDL_FILESYSTEM_COCOA */
+
+/* vi: set ts=4 sw=4 expandtab: */
diff --git a/src/filesystem/dummy/SDL_sysfilesystem.c b/src/filesystem/dummy/SDL_sysfilesystem.c
new file mode 100644
index 000000000..a6bd57767
--- /dev/null
+++ b/src/filesystem/dummy/SDL_sysfilesystem.c
@@ -0,0 +1,47 @@
+/*
+ Simple DirectMedia Layer
+ Copyright (C) 1997-2013 Sam Lantinga
+
+ This software is provided 'as-is', without any express or implied
+ warranty. In no event will the authors be held liable for any damages
+ arising from the use of this software.
+
+ Permission is granted to anyone to use this software for any purpose,
+ including commercial applications, and to alter it and redistribute it
+ freely, subject to the following restrictions:
+
+ 1. The origin of this software must not be misrepresented; you must not
+ claim that you wrote the original software. If you use this software
+ in a product, an acknowledgment in the product documentation would be
+ appreciated but is not required.
+ 2. Altered source versions must be plainly marked as such, and must not be
+ misrepresented as being the original software.
+ 3. This notice may not be removed or altered from any source distribution.
+*/
+#include "SDL_config.h"
+
+#ifdef SDL_FILESYSTEM_DUMMY
+
+/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
+/* System dependent filesystem routines */
+
+#include "SDL_error.h"
+#include "SDL_filesystem.h"
+
+char *
+SDL_GetBasePath(void)
+{
+ SDL_Unsupported();
+ return NULL;
+}
+
+char *
+SDL_GetPrefPath(const char *org, const char *app)
+{
+ SDL_Unsupported();
+ return NULL;
+}
+
+#endif /* SDL_FILESYSTEM_DUMMY */
+
+/* vi: set ts=4 sw=4 expandtab: */
diff --git a/src/filesystem/unix/SDL_sysfilesystem.c b/src/filesystem/unix/SDL_sysfilesystem.c
new file mode 100644
index 000000000..326637e78
--- /dev/null
+++ b/src/filesystem/unix/SDL_sysfilesystem.c
@@ -0,0 +1,161 @@
+/*
+ Simple DirectMedia Layer
+ Copyright (C) 1997-2013 Sam Lantinga
+
+ This software is provided 'as-is', without any express or implied
+ warranty. In no event will the authors be held liable for any damages
+ arising from the use of this software.
+
+ Permission is granted to anyone to use this software for any purpose,
+ including commercial applications, and to alter it and redistribute it
+ freely, subject to the following restrictions:
+
+ 1. The origin of this software must not be misrepresented; you must not
+ claim that you wrote the original software. If you use this software
+ in a product, an acknowledgment in the product documentation would be
+ appreciated but is not required.
+ 2. Altered source versions must be plainly marked as such, and must not be
+ misrepresented as being the original software.
+ 3. This notice may not be removed or altered from any source distribution.
+*/
+#include "SDL_config.h"
+
+#ifdef SDL_FILESYSTEM_UNIX
+
+/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
+/* System dependent filesystem routines */
+
+#include
+
+#include "SDL_error.h"
+#include "SDL_stdinc.h"
+#include "SDL_filesystem.h"
+
+static char *readSymLink(const char *path)
+{
+ char *retval = NULL;
+ ssize_t len = 64;
+ ssize_t rc = -1;
+
+ while (1)
+ {
+ char *ptr = (char *) SDL_realloc(retval, (size_t) len);
+ if (ptr == NULL) {
+ SDL_OutOfMemory();
+ break;
+ }
+
+ retval = ptr;
+
+ rc = readlink(path, retval, len);
+ if (rc == -1) {
+ break; /* not a symlink, i/o error, etc. */
+ } else if (rc < len) {
+ retval[rc] = '\0'; /* readlink doesn't null-terminate. */
+ return retval; /* we're good to go. */
+ }
+
+ len *= 2; /* grow buffer, try again. */
+ }
+
+ if (retval != NULL) {
+ SDL_free(retval);
+ }
+ return NULL;
+}
+
+
+char *
+SDL_GetBasePath(void)
+{
+ char *retval = NULL;
+
+ /* is a Linux-style /proc filesystem available? */
+ if (access("/proc", F_OK) {
+ retval = readSymLink("/proc/self/exe");
+ if (retval == NULL) {
+ /* older kernels don't have /proc/self ... try PID version... */
+ char path[64];
+ const int rc = (int) SDL_snprintf(path, sizeof(path),
+ "/proc/%llu/exe",
+ (unsigned long long) getpid());
+ if ( (rc > 0) && (rc < sizeof(path)) ) {
+ retval = readSymLink(path);
+ }
+ }
+ }
+
+ /* If we had access to argv[0] here, we could check it for a path,
+ or troll through $PATH looking for it, too. */
+
+ if (retval != NULL) { /* chop off filename. */
+ char *ptr = SDL_strrchr(retval, '/');
+ if (ptr != NULL) {
+ *(ptr+1) = '\0';
+ } else { /* shouldn't happen, but just in case... */
+ SDL_free(retval);
+ retval = NULL;
+ }
+ }
+
+ if (retval != NULL) {
+ /* try to shrink buffer... */
+ char *ptr = (char *) SDL_realloc(retval, strlen(retval) + 1);
+ if (ptr != NULL)
+ retval = ptr; /* oh well if it failed. */
+ }
+
+ return retval;
+}
+
+char *
+SDL_GetPrefPath(const char *org, const char *app)
+{
+ /*
+ * We use XDG's base directory spec, even if you're not on Linux.
+ * This isn't strictly correct, but the results are relatively sane
+ * in any case.
+ *
+ * http://standards.freedesktop.org/basedir-spec/basedir-spec-latest.html
+ */
+ const char *envr = SDL_getenv("XDG_DATA_HOME");
+ const char *append = "/";
+ char *retval = NULL;
+ char *ptr = NULL;
+ size_t len = 0;
+
+ if (!envr) {
+ /* You end up with "$HOME/.local/share/Game Name 2" */
+ envr = SDL_getenv("HOME");
+ if (!envr) {
+ /* we could take heroic measures with /etc/passwd, but oh well. */
+ SDL_SetError("neither XDG_DATA_HOME nor HOME environment is set");
+ return NULL;
+ }
+ append = ".local/share/";
+ } /* if */
+
+ len = SDL_strlen(envr) + SDL_strlen(append) + SDL_strlen(app) + 2;
+ retval = (char *) SDL_malloc(len);
+ if (!retval) {
+ SDL_OutOfMemory();
+ return NULL;
+ }
+
+ SDL_snprintf(retval, len, "%s%s%s/", envr, append, app);
+
+ for (ptr = retval+1; *ptr; ptr++) {
+ if (*ptr == '/') {
+ *ptr = '\0';
+ mkdir(retval, 0700);
+ *ptr = '/';
+ }
+ }
+ mkdir(retval, 0700);
+
+ return retval;
+}
+
+#endif /* SDL_FILESYSTEM_UNIX */
+
+/* vi: set ts=4 sw=4 expandtab: */
diff --git a/src/filesystem/windows/SDL_sysfilesystem.c b/src/filesystem/windows/SDL_sysfilesystem.c
new file mode 100644
index 000000000..fc17d5e0f
--- /dev/null
+++ b/src/filesystem/windows/SDL_sysfilesystem.c
@@ -0,0 +1,96 @@
+/*
+ Simple DirectMedia Layer
+ Copyright (C) 1997-2013 Sam Lantinga
+
+ This software is provided 'as-is', without any express or implied
+ warranty. In no event will the authors be held liable for any damages
+ arising from the use of this software.
+
+ Permission is granted to anyone to use this software for any purpose,
+ including commercial applications, and to alter it and redistribute it
+ freely, subject to the following restrictions:
+
+ 1. The origin of this software must not be misrepresented; you must not
+ claim that you wrote the original software. If you use this software
+ in a product, an acknowledgment in the product documentation would be
+ appreciated but is not required.
+ 2. Altered source versions must be plainly marked as such, and must not be
+ misrepresented as being the original software.
+ 3. This notice may not be removed or altered from any source distribution.
+*/
+#include "SDL_config.h"
+
+#ifdef SDL_FILESYSTEM_WINDOWS
+
+/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
+/* System dependent filesystem routines */
+
+#include "SDL_error.h"
+#include "SDL_windows.h"
+#include "SDL_stdinc.h"
+#include "SDL_filesystem.h"
+
+char *
+SDL_GetBasePath(void)
+{
+ TCHAR path[MAX_PATH];
+ const DWORD len = GetModuleFileName(NULL, path, SDL_arraysize(path));
+ size_t i;
+
+ SDL_assert(len < SDL_arraysize(path));
+
+ if (len == 0) {
+ WIN_SetError("Couldn't locate our .exe");
+ return NULL;
+ }
+
+ for (i = len-1; i > 0; i--) {
+ if (path[i] == '\\') {
+ break;
+ }
+ }
+
+ SDL_assert(i > 0); /* Should have been an absolute path. */
+ path[i+1] = '\0'; /* chop off filename. */
+ return WIN_StringToUTF8(path);
+}
+
+char *
+SDL_GetPrefPath(const char *org, const char *app)
+{
+ /*
+ * Vista and later has a new API for this, but SHGetFolderPath works there,
+ * and apparently just wraps the new API. This is the new way to do it:
+ *
+ * SHGetKnownFolderPath(FOLDERID_RoamingAppData, KF_FLAG_CREATE,
+ * NULL, &wszPath);
+ */
+
+ TCHAR path[MAX_PATH];
+ char *utf8 = NULL;
+ char *retval = NULL;
+
+ if (!SUCCEEDED(SHGetFolderPath(NULL, CSIDL_APPDATA | CSIDL_FLAG_CREATE, NULL, 0, path))) {
+ WIN_SetError("Couldn't locate our prefpath");
+ return NULL;
+ }
+
+ utf8 = WIN_StringToUTF8(path);
+ if (utf8) {
+ const size_t len = SDL_strlen(utf8) + SDL_strlen(org) + SDL_strlen(app) + 4;
+ retval = (char *) SDL_malloc(len);
+ if (!retval) {
+ SDL_free(utf8);
+ SDL_OutOfMemory();
+ return NULL;
+ }
+ SDL_snprintf(retval, len, "%s\\%s\\%s\\", utf8, org, app);
+ SDL_free(utf8);
+ }
+
+ return retval;
+}
+
+#endif /* SDL_FILESYSTEM_WINDOWS */
+
+/* vi: set ts=4 sw=4 expandtab: */
diff --git a/test/Makefile.in b/test/Makefile.in
index 2a39afc6b..ed0fce36a 100644
--- a/test/Makefile.in
+++ b/test/Makefile.in
@@ -36,6 +36,7 @@ TARGETS = \
testoverlay2$(EXE) \
testplatform$(EXE) \
testpower$(EXE) \
+ testfilesystem$(EXE) \
testrendertarget$(EXE) \
testresample$(EXE) \
testscale$(EXE) \
@@ -180,6 +181,9 @@ testplatform$(EXE): $(srcdir)/testplatform.c
testpower$(EXE): $(srcdir)/testpower.c
$(CC) -o $@ $^ $(CFLAGS) $(LIBS)
+testfilesystem$(EXE): $(srcdir)/testfilesystem.c
+ $(CC) -o $@ $^ $(CFLAGS) $(LIBS)
+
testrendertarget$(EXE): $(srcdir)/testrendertarget.c
$(CC) -o $@ $^ $(CFLAGS) $(LIBS)
diff --git a/test/testfilesystem.c b/test/testfilesystem.c
new file mode 100644
index 000000000..e1f251371
--- /dev/null
+++ b/test/testfilesystem.c
@@ -0,0 +1,33 @@
+/*
+ Copyright (C) 1997-2013 Sam Lantinga
+
+ This software is provided 'as-is', without any express or implied
+ warranty. In no event will the authors be held liable for any damages
+ arising from the use of this software.
+
+ Permission is granted to anyone to use this software for any purpose,
+ including commercial applications, and to alter it and redistribute it
+ freely.
+*/
+/* Simple test of power subsystem. */
+
+#include
+#include "SDL.h"
+
+int
+main(int argc, char *argv[])
+{
+ /* Enable standard application logging */
+ SDL_LogSetPriority(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO);
+
+ if (SDL_Init(0) == -1) {
+ SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "SDL_Init() failed: %s\n", SDL_GetError());
+ return 1;
+ }
+
+ SDL_Log("base path: '%s'\n", SDL_GetBasePath());
+ SDL_Log("pref path: '%s'\n", SDL_GetPrefPath("libsdl", "testfilesystem"));
+
+ SDL_Quit();
+ return 0;
+}