Fixed bug 2374 - Update copyright for 2014...
Is it that time already??
2 Simple DirectMedia Layer
3 Copyright (C) 1997-2014 Sam Lantinga <slouken@libsdl.org>
5 This software is provided 'as-is', without any express or implied
6 warranty. In no event will the authors be held liable for any damages
7 arising from the use of this software.
9 Permission is granted to anyone to use this software for any purpose,
10 including commercial applications, and to alter it and redistribute it
11 freely, subject to the following restrictions:
13 1. The origin of this software must not be misrepresented; you must not
14 claim that you wrote the original software. If you use this software
15 in a product, an acknowledgment in the product documentation would be
16 appreciated but is not required.
17 2. Altered source versions must be plainly marked as such, and must not be
18 misrepresented as being the original software.
19 3. This notice may not be removed or altered from any source distribution.
21 #include "../../SDL_internal.h"
23 #ifdef SDL_FILESYSTEM_HAIKU
25 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
26 /* System dependent filesystem routines */
28 #include <os/kernel/image.h>
29 #include <os/storage/Directory.h>
30 #include <os/storage/Entry.h>
31 #include <os/storage/Path.h>
33 #include "SDL_error.h"
34 #include "SDL_stdinc.h"
35 #include "SDL_assert.h"
36 #include "SDL_filesystem.h"
44 while (get_next_image_info(0, &cookie, &info) == B_OK) {
45 if (info.type == B_APP_IMAGE) {
50 BEntry entry(info.name, true);
52 status_t rc = entry.GetPath(&path); /* (path) now has binary's path. */
53 SDL_assert(rc == B_OK);
54 rc = path.GetParent(&path); /* chop filename, keep directory. */
55 SDL_assert(rc == B_OK);
56 const char *str = path.Path();
57 SDL_assert(str != NULL);
59 const size_t len = SDL_strlen(str);
60 char *retval = (char *) SDL_malloc(len + 2);
66 SDL_memcpy(retval, str, len);
74 SDL_GetPrefPath(const char *org, const char *app)
76 // !!! FIXME: is there a better way to do this?
77 const char *home = SDL_getenv("HOME");
78 const char *append = "config/settings/";
79 const size_t len = SDL_strlen(home) + SDL_strlen(append) + SDL_strlen(org) + SDL_strlen(app) + 3;
80 char *retval = (char *) SDL_malloc(len);
84 SDL_snprintf(retval, len, "%s%s%s/%s/", home, append, org, app);
85 create_directory(retval, 0700); // Haiku api: creates missing dirs
91 #endif /* SDL_FILESYSTEM_HAIKU */
93 /* vi: set ts=4 sw=4 expandtab: */