Allow organization to be NULL in GetPrefPath

Having SDL_GetPrefPath always use the organization breaks a couple of
things for me. Given that not all applications really have an
appropriate “organization” anyway, it would be nice to have a way for
programs to elect not to provide one.

Making the organization directory simply not exist when ‘org’ is NULL
(or the empty string) seems to me a nice way of implementing this. As-is
passing NULL is either going to crash or create a directory called
"(null)", depending on platform sprintf() behaviour, so I doubt that
changing this will break anything anyone is actually using.

I’ve attached a patch that implements this on all currently platforms
(including windows), though I haven’t tested it on anything but linux.

Thoughts?
– David
-------------- next part --------------
A non-text attachment was scrubbed…
Name: SDL_filesystem_org_null.patch
Type: text/x-patch
Size: 4934 bytes
Desc: not available
URL: http://lists.libsdl.org/pipermail/sdl-libsdl.org/attachments/20131026/2ca3279c/attachment.bin

Am I not correct in that the org kind of serves the same purpose as
Apple/Java vendor identifiers?

Apple’s is com.apple, and I also have stuff like org.mozilla,
com.vmware, etc. I even have a couple of org.github.* and
org.sourceforge.* items in my ~/Library/Preferences directory.
~/Library/Application\ Support is not nearly so nicely organized
sadly. There’s a few reverse URLs in there, but most are either
folders with app names (if the vendor only has one app) or a company
name and app name folders inside. Which is basically what you’re
discussing here.

I can imagine there’s a few things out there that don’t have a
website or domain name, but not many anymore. The organization
doesn’t really have to imply anything fiscal or legal.

I’m not opposed to the patch, but I’d personally always supply a
working organization to the function, just in case I wind up
fabulously successful with a dozen or so popular games that players
are beating a path to my door and offering me dump trucks worth of
money to keep making them. (Yeah, that’ll happen!)

JosephOn Sat, Oct 26, 2013 at 10:40:02AM +0800, David Gow wrote:

Having SDL_GetPrefPath always use the organization breaks a couple of
things for me. Given that not all applications really have an
appropriate “organization” anyway, it would be nice to have a way for
programs to elect not to provide one.

Making the organization directory simply not exist when ‘org’ is NULL
(or the empty string) seems to me a nice way of implementing this.
As-is passing NULL is either going to crash or create a directory
called “(null)”, depending on platform sprintf() behaviour, so I
doubt that changing this will break anything anyone is actually
using.

I’ve attached a patch that implements this on all currently platforms
(including windows), though I haven’t tested it on anything but
linux.

Thoughts?
– David

HG changeset patch

User David Gow

Date 1382753419 -28800

Sat Oct 26 10:10:19 2013 +0800

Node ID 1b499142c825e11987f2700f3db02a90400edc1c

Parent 59b3e715fab6901bed62ec628b9d3b34b5008e46

Do not include ‘org’ if null in GetPrefPath

diff -r 59b3e715fab6 -r 1b499142c825 src/filesystem/beos/SDL_sysfilesystem.cc
— a/src/filesystem/beos/SDL_sysfilesystem.cc Wed Oct 23 20:58:39 2013 -0700
+++ b/src/filesystem/beos/SDL_sysfilesystem.cc Sat Oct 26 10:10:19 2013 +0800
@@ -76,12 +76,22 @@
// !!! 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(org) + SDL_strlen(app) + 3;
  • // Handle the case when ‘org’ is NULL or empty.
  • size_t len;
  • if (!org || !org[0]) {
  •    len = SDL_strlen(home) + SDL_strlen(append) + SDL_strlen(app) + 2;
    
  • } else {
  •    len = SDL_strlen(home) + SDL_strlen(append) + SDL_strlen(org) + SDL_strlen(app) + 3;
    
  • }
    char *retval = (char *) SDL_malloc(len);
    if (!retval) {
    SDL_OutOfMemory();
    } else {
  •    SDL_snprintf(retval, len, "%s%s%s/%s/", home, append, org, app);
    
  •    if (!org || !org[0]) {
    
  •        SDL_snprintf(retval, len, "%s%s/%s/", home, append, app);
    
  •    } else {
    
  •        SDL_snprintf(retval, len, "%s%s%s/%s/", home, append, org, app);
    
  •    }
      create_directory(retval, 0700);  // BeOS api: creates missing dirs
    
    }

diff -r 59b3e715fab6 -r 1b499142c825 src/filesystem/cocoa/SDL_sysfilesystem.m
— a/src/filesystem/cocoa/SDL_sysfilesystem.m Wed Oct 23 20:58:39 2013 -0700
+++ b/src/filesystem/cocoa/SDL_sysfilesystem.m Sat Oct 26 10:10:19 2013 +0800
@@ -77,13 +77,22 @@
NSString *str = [array objectAtIndex:0];
const char *base = [str fileSystemRepresentation];
if (base) {

  •        const size_t len = SDL_strlen(base) + SDL_strlen(org) + SDL_strlen(app) + 4;
    
  •        size_t len;
    
  •        if (!org || !org[0]) {
    
  •            len = SDL_strlen(base) + SDL_strlen(app) + 3;
    
  •        } else {
    
  •            len = SDL_strlen(base) + SDL_strlen(org) + SDL_strlen(app) + 4;
    
  •        }
          retval = (char *) SDL_malloc(len);
          if (retval == NULL) {
              SDL_OutOfMemory();
          } else {
              char *ptr;
    
  •            SDL_snprintf(retval, len, "%s/%s/%s/", base, org, app);
    
  •            if (!org || !org[0]) {
    
  •                SDL_snprintf(retval, len, "%s/%s/", base, app);
    
  •            } else {
    
  •                SDL_snprintf(retval, len, "%s/%s/%s/", base, org, app);
    
  •            }
              for (ptr = retval+1; *ptr; ptr++) {
                  if (*ptr == '/') {
                      *ptr = '\0';
    

diff -r 59b3e715fab6 -r 1b499142c825 src/filesystem/unix/SDL_sysfilesystem.c
— a/src/filesystem/unix/SDL_sysfilesystem.c Wed Oct 23 20:58:39 2013 -0700
+++ b/src/filesystem/unix/SDL_sysfilesystem.c Sat Oct 26 10:10:19 2013 +0800
@@ -178,14 +178,21 @@
if (envr[len - 1] == ‘/’)
append += 1;

  • len += SDL_strlen(append) + SDL_strlen(org) + SDL_strlen(app) + 3;
  • if (!org || !org[0])
  •    len += SDL_strlen(append) + SDL_strlen(app) + 2;
    
  • else
  •    len += SDL_strlen(append) + SDL_strlen(org) + SDL_strlen(app) + 3;
    
  • retval = (char *) SDL_malloc(len);
    if (!retval) {
    SDL_OutOfMemory();
    return NULL;
    }
  • SDL_snprintf(retval, len, “%s%s%s/%s/”, envr, append, org, app);
  • if (!org || !org[0])

  •    SDL_snprintf(retval, len, "%s%s%s/", envr, append, app);
    
  • else

  •    SDL_snprintf(retval, len, "%s%s%s/%s/", envr, append, org, app);
    

    for (ptr = retval+1; *ptr; ptr++) {
    if (*ptr == ‘/’) {
    diff -r 59b3e715fab6 -r 1b499142c825 src/filesystem/windows/SDL_sysfilesystem.c
    — a/src/filesystem/windows/SDL_sysfilesystem.c Wed Oct 23 20:58:39 2013 -0700
    +++ b/src/filesystem/windows/SDL_sysfilesystem.c Sat Oct 26 10:10:19 2013 +0800
    @@ -80,14 +80,23 @@

    utf8 = WIN_StringToUTF8(path);
    if (utf8) {

  •    const size_t len = SDL_strlen(utf8) + SDL_strlen(org) + SDL_strlen(app) + 4;
    
  •    size_t len;
    
  •    if (!org || !org[0]) {
    
  •        len = SDL_strlen(utf8) + SDL_strlen(app) + 3;
    
  •    } else {
    
  •        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);
    
  •    if (!org || !org[0]) {
    
  •        SDL_snprintf(retval, len, "%s\\%s\\", utf8, app);
    
  •    } else {
    
  •        SDL_snprintf(retval, len, "%s\\%s\\%s\\", utf8, org, app);
    
  •    }
      SDL_free(utf8);
    
    }

SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org

The organization is there just to reduce the likelihood of conflicts
in case two programs happen to use the same name (otherwise they’ll
end up sharing the files). By not using the organization you just make
a clash more likely, nothing else.

This has nothing to do with sites at all, so I’m not sure how having
or not having a site is relevant. You’ll probably prefer to use the
proper name of the developer instead of something based on a site
address.

2013/10/27, T. Joseph Carter :> Am I not correct in that the org kind of serves the same purpose as

Apple/Java vendor identifiers?

Apple’s is com.apple, and I also have stuff like org.mozilla,
com.vmware, etc. I even have a couple of org.github.* and
org.sourceforge.* items in my ~/Library/Preferences directory.
~/Library/Application\ Support is not nearly so nicely organized
sadly. There’s a few reverse URLs in there, but most are either
folders with app names (if the vendor only has one app) or a company
name and app name folders inside. Which is basically what you’re
discussing here.

I can imagine there’s a few things out there that don’t have a
website or domain name, but not many anymore. The organization
doesn’t really have to imply anything fiscal or legal.

I’m not opposed to the patch, but I’d personally always supply a
working organization to the function, just in case I wind up
fabulously successful with a dozen or so popular games that players
are beating a path to my door and offering me dump trucks worth of
money to keep making them. (Yeah, that’ll happen!)

Joseph

On Sat, Oct 26, 2013 at 10:40:02AM +0800, David Gow wrote:

Having SDL_GetPrefPath always use the organization breaks a couple of
things for me. Given that not all applications really have an
appropriate “organization” anyway, it would be nice to have a way for
programs to elect not to provide one.

Making the organization directory simply not exist when ‘org’ is NULL
(or the empty string) seems to me a nice way of implementing this.
As-is passing NULL is either going to crash or create a directory
called “(null)”, depending on platform sprintf() behaviour, so I
doubt that changing this will break anything anyone is actually
using.

I’ve attached a patch that implements this on all currently platforms
(including windows), though I haven’t tested it on anything but
linux.

Thoughts?
– David

HG changeset patch

User David Gow

Date 1382753419 -28800

Sat Oct 26 10:10:19 2013 +0800

Node ID 1b499142c825e11987f2700f3db02a90400edc1c

Parent 59b3e715fab6901bed62ec628b9d3b34b5008e46

Do not include ‘org’ if null in GetPrefPath

diff -r 59b3e715fab6 -r 1b499142c825
src/filesystem/beos/SDL_sysfilesystem.cc
— a/src/filesystem/beos/SDL_sysfilesystem.cc Wed Oct 23 20:58:39 2013
-0700
+++ b/src/filesystem/beos/SDL_sysfilesystem.cc Sat Oct 26 10:10:19 2013
+0800
@@ -76,12 +76,22 @@
// !!! 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(org) + SDL_strlen(app) + 3;
  • // Handle the case when ‘org’ is NULL or empty.
  • size_t len;
  • if (!org || !org[0]) {
  •    len = SDL_strlen(home) + SDL_strlen(append) + SDL_strlen(app) +
    

2;

  • } else {
  •    len = SDL_strlen(home) + SDL_strlen(append) + SDL_strlen(org) +
    

SDL_strlen(app) + 3;

  • }
    char *retval = (char *) SDL_malloc(len);
    if (!retval) {
    SDL_OutOfMemory();
    } else {
  •    SDL_snprintf(retval, len, "%s%s%s/%s/", home, append, org, app);
    
  •    if (!org || !org[0]) {
    
  •        SDL_snprintf(retval, len, "%s%s/%s/", home, append, app);
    
  •    } else {
    
  •        SDL_snprintf(retval, len, "%s%s%s/%s/", home, append, org,
    

app);

  •    }
      create_directory(retval, 0700);  // BeOS api: creates missing
    

dirs
}

diff -r 59b3e715fab6 -r 1b499142c825
src/filesystem/cocoa/SDL_sysfilesystem.m
— a/src/filesystem/cocoa/SDL_sysfilesystem.m Wed Oct 23 20:58:39 2013
-0700
+++ b/src/filesystem/cocoa/SDL_sysfilesystem.m Sat Oct 26 10:10:19 2013
+0800
@@ -77,13 +77,22 @@
NSString *str = [array objectAtIndex:0];
const char *base = [str fileSystemRepresentation];
if (base) {

  •        const size_t len = SDL_strlen(base) + SDL_strlen(org) +
    

SDL_strlen(app) + 4;

  •        size_t len;
    
  •        if (!org || !org[0]) {
    
  •            len = SDL_strlen(base) + SDL_strlen(app) + 3;
    
  •        } else {
    
  •            len = SDL_strlen(base) + SDL_strlen(org) + SDL_strlen(app)
    
  • 4;
  •        }
          retval = (char *) SDL_malloc(len);
          if (retval == NULL) {
              SDL_OutOfMemory();
          } else {
              char *ptr;
    
  •            SDL_snprintf(retval, len, "%s/%s/%s/", base, org, app);
    
  •            if (!org || !org[0]) {
    
  •                SDL_snprintf(retval, len, "%s/%s/", base, app);
    
  •            } else {
    
  •                SDL_snprintf(retval, len, "%s/%s/%s/", base, org,
    

app);

  •            }
              for (ptr = retval+1; *ptr; ptr++) {
                  if (*ptr == '/') {
                      *ptr = '\0';
    

diff -r 59b3e715fab6 -r 1b499142c825
src/filesystem/unix/SDL_sysfilesystem.c
— a/src/filesystem/unix/SDL_sysfilesystem.c Wed Oct 23 20:58:39 2013
-0700
+++ b/src/filesystem/unix/SDL_sysfilesystem.c Sat Oct 26 10:10:19 2013
+0800
@@ -178,14 +178,21 @@
if (envr[len - 1] == ‘/’)
append += 1;

  • len += SDL_strlen(append) + SDL_strlen(org) + SDL_strlen(app) + 3;
  • if (!org || !org[0])
  •    len += SDL_strlen(append) + SDL_strlen(app) + 2;
    
  • else
  •    len += SDL_strlen(append) + SDL_strlen(org) + SDL_strlen(app) +
    

3;
+
retval = (char *) SDL_malloc(len);
if (!retval) {
SDL_OutOfMemory();
return NULL;
}

  • SDL_snprintf(retval, len, “%s%s%s/%s/”, envr, append, org, app);
  • if (!org || !org[0])

  •    SDL_snprintf(retval, len, "%s%s%s/", envr, append, app);
    
  • else

  •    SDL_snprintf(retval, len, "%s%s%s/%s/", envr, append, org, app);
    

    for (ptr = retval+1; *ptr; ptr++) {
    if (*ptr == ‘/’) {
    diff -r 59b3e715fab6 -r 1b499142c825
    src/filesystem/windows/SDL_sysfilesystem.c
    — a/src/filesystem/windows/SDL_sysfilesystem.c Wed Oct 23 20:58:39 2013
    -0700
    +++ b/src/filesystem/windows/SDL_sysfilesystem.c Sat Oct 26 10:10:19 2013
    +0800
    @@ -80,14 +80,23 @@

    utf8 = WIN_StringToUTF8(path);
    if (utf8) {

  •    const size_t len = SDL_strlen(utf8) + SDL_strlen(org) +
    

SDL_strlen(app) + 4;

  •    size_t len;
    
  •    if (!org || !org[0]) {
    
  •        len = SDL_strlen(utf8) + SDL_strlen(app) + 3;
    
  •    } else {
    
  •        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);
    
  •    if (!org || !org[0]) {
    
  •        SDL_snprintf(retval, len, "%s\\%s\\", utf8, app);
    
  •    } else {
    
  •        SDL_snprintf(retval, len, "%s\\%s\\%s\\", utf8, org, app);
    
  •    }
      SDL_free(utf8);
    
    }

SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org


SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org

Again, the site URL serves the same purpose in the Mac’s Preferences
folder?it just disambiguates the namespace a bit. It’s just the
standard way that Apple has chosen to do so. Some apps do not follow
this standard, and when they do not it’s kind of weird.

Like I said, I don’t object to the patch. ?But if you’re expected to
provide something not NULL, at least to other targets, Linux should
not be different?even if you are expected to provide “”.

JosephOn Sun, Oct 27, 2013 at 01:56:59AM -0200, Sik the hedgehog wrote:

The organization is there just to reduce the likelihood of conflicts
in case two programs happen to use the same name (otherwise they’ll
end up sharing the files). By not using the organization you just make
a clash more likely, nothing else.

This has nothing to do with sites at all, so I’m not sure how having
or not having a site is relevant. You’ll probably prefer to use the
proper name of the developer instead of something based on a site
address.

2013/10/27, T. Joseph Carter <@T_Joseph_Carter>:

Am I not correct in that the org kind of serves the same purpose as
Apple/Java vendor identifiers?

Apple’s is com.apple, and I also have stuff like org.mozilla,
com.vmware, etc. I even have a couple of org.github.* and
org.sourceforge.* items in my ~/Library/Preferences directory.
~/Library/Application\ Support is not nearly so nicely organized
sadly. There’s a few reverse URLs in there, but most are either
folders with app names (if the vendor only has one app) or a company
name and app name folders inside. Which is basically what you’re
discussing here.

I can imagine there’s a few things out there that don’t have a
website or domain name, but not many anymore. The organization
doesn’t really have to imply anything fiscal or legal.

I’m not opposed to the patch, but I’d personally always supply a
working organization to the function, just in case I wind up
fabulously successful with a dozen or so popular games that players
are beating a path to my door and offering me dump trucks worth of
money to keep making them. (Yeah, that’ll happen!)

Joseph

On Sat, Oct 26, 2013 at 10:40:02AM +0800, David Gow wrote:

Having SDL_GetPrefPath always use the organization breaks a couple of
things for me. Given that not all applications really have an
appropriate “organization” anyway, it would be nice to have a way for
programs to elect not to provide one.

Making the organization directory simply not exist when ‘org’ is NULL
(or the empty string) seems to me a nice way of implementing this.
As-is passing NULL is either going to crash or create a directory
called “(null)”, depending on platform sprintf() behaviour, so I
doubt that changing this will break anything anyone is actually
using.

I’ve attached a patch that implements this on all currently platforms
(including windows), though I haven’t tested it on anything but
linux.

Thoughts?
– David

HG changeset patch

User David Gow

Date 1382753419 -28800

Sat Oct 26 10:10:19 2013 +0800

Node ID 1b499142c825e11987f2700f3db02a90400edc1c

Parent 59b3e715fab6901bed62ec628b9d3b34b5008e46

Do not include ‘org’ if null in GetPrefPath

diff -r 59b3e715fab6 -r 1b499142c825
src/filesystem/beos/SDL_sysfilesystem.cc
— a/src/filesystem/beos/SDL_sysfilesystem.cc Wed Oct 23 20:58:39 2013
-0700
+++ b/src/filesystem/beos/SDL_sysfilesystem.cc Sat Oct 26 10:10:19 2013
+0800
@@ -76,12 +76,22 @@
// !!! 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(org) + SDL_strlen(app) + 3;
  • // Handle the case when ‘org’ is NULL or empty.
  • size_t len;
  • if (!org || !org[0]) {
  •    len = SDL_strlen(home) + SDL_strlen(append) + SDL_strlen(app) +
    

2;

  • } else {
  •    len = SDL_strlen(home) + SDL_strlen(append) + SDL_strlen(org) +
    

SDL_strlen(app) + 3;

  • }
    char *retval = (char *) SDL_malloc(len);
    if (!retval) {
    SDL_OutOfMemory();
    } else {
  •    SDL_snprintf(retval, len, "%s%s%s/%s/", home, append, org, app);
    
  •    if (!org || !org[0]) {
    
  •        SDL_snprintf(retval, len, "%s%s/%s/", home, append, app);
    
  •    } else {
    
  •        SDL_snprintf(retval, len, "%s%s%s/%s/", home, append, org,
    

app);

  •    }
      create_directory(retval, 0700);  // BeOS api: creates missing
    

dirs
}

diff -r 59b3e715fab6 -r 1b499142c825
src/filesystem/cocoa/SDL_sysfilesystem.m
— a/src/filesystem/cocoa/SDL_sysfilesystem.m Wed Oct 23 20:58:39 2013
-0700
+++ b/src/filesystem/cocoa/SDL_sysfilesystem.m Sat Oct 26 10:10:19 2013
+0800
@@ -77,13 +77,22 @@
NSString *str = [array objectAtIndex:0];
const char *base = [str fileSystemRepresentation];
if (base) {

  •        const size_t len = SDL_strlen(base) + SDL_strlen(org) +
    

SDL_strlen(app) + 4;

  •        size_t len;
    
  •        if (!org || !org[0]) {
    
  •            len = SDL_strlen(base) + SDL_strlen(app) + 3;
    
  •        } else {
    
  •            len = SDL_strlen(base) + SDL_strlen(org) + SDL_strlen(app)
    
  • 4;
  •        }
          retval = (char *) SDL_malloc(len);
          if (retval == NULL) {
              SDL_OutOfMemory();
          } else {
              char *ptr;
    
  •            SDL_snprintf(retval, len, "%s/%s/%s/", base, org, app);
    
  •            if (!org || !org[0]) {
    
  •                SDL_snprintf(retval, len, "%s/%s/", base, app);
    
  •            } else {
    
  •                SDL_snprintf(retval, len, "%s/%s/%s/", base, org,
    

app);

  •            }
              for (ptr = retval+1; *ptr; ptr++) {
                  if (*ptr == '/') {
                      *ptr = '\0';
    

diff -r 59b3e715fab6 -r 1b499142c825
src/filesystem/unix/SDL_sysfilesystem.c
— a/src/filesystem/unix/SDL_sysfilesystem.c Wed Oct 23 20:58:39 2013
-0700
+++ b/src/filesystem/unix/SDL_sysfilesystem.c Sat Oct 26 10:10:19 2013
+0800
@@ -178,14 +178,21 @@
if (envr[len - 1] == ‘/’)
append += 1;

  • len += SDL_strlen(append) + SDL_strlen(org) + SDL_strlen(app) + 3;
  • if (!org || !org[0])
  •    len += SDL_strlen(append) + SDL_strlen(app) + 2;
    
  • else
  •    len += SDL_strlen(append) + SDL_strlen(org) + SDL_strlen(app) +
    

3;
+
retval = (char *) SDL_malloc(len);
if (!retval) {
SDL_OutOfMemory();
return NULL;
}

  • SDL_snprintf(retval, len, “%s%s%s/%s/”, envr, append, org, app);
  • if (!org || !org[0])

  •    SDL_snprintf(retval, len, "%s%s%s/", envr, append, app);
    
  • else

  •    SDL_snprintf(retval, len, "%s%s%s/%s/", envr, append, org, app);
    

    for (ptr = retval+1; *ptr; ptr++) {
    if (*ptr == ‘/’) {
    diff -r 59b3e715fab6 -r 1b499142c825
    src/filesystem/windows/SDL_sysfilesystem.c
    — a/src/filesystem/windows/SDL_sysfilesystem.c Wed Oct 23 20:58:39 2013
    -0700
    +++ b/src/filesystem/windows/SDL_sysfilesystem.c Sat Oct 26 10:10:19 2013
    +0800
    @@ -80,14 +80,23 @@

    utf8 = WIN_StringToUTF8(path);
    if (utf8) {

  •    const size_t len = SDL_strlen(utf8) + SDL_strlen(org) +
    

SDL_strlen(app) + 4;

  •    size_t len;
    
  •    if (!org || !org[0]) {
    
  •        len = SDL_strlen(utf8) + SDL_strlen(app) + 3;
    
  •    } else {
    
  •        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);
    
  •    if (!org || !org[0]) {
    
  •        SDL_snprintf(retval, len, "%s\\%s\\", utf8, app);
    
  •    } else {
    
  •        SDL_snprintf(retval, len, "%s\\%s\\%s\\", utf8, org, app);
    
  •    }
      SDL_free(utf8);
    
    }

SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org


SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org


SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org

Making the organization directory simply not exist when ‘org’ is NULL
(or the empty string) seems to me a nice way of implementing this. As-is
passing NULL is either going to crash or create a directory called
"(null)", depending on platform sprintf() behaviour, so I doubt that
changing this will break anything anyone is actually using.

No, there’s no reason to not to provide something. Make up a name. You
don’t have to file incorporation papers or anything.

More seriously: we currently use the organization on every
platform–even if they aren’t required–but for the ones that do
require it: what should we use when the app specifies NULL?

(I will accept a patch that fails cleanly instead of crashing if the
app passes NULL, though!)

–ryan.

No, it’s a proper name, like Windows expects (and Mac’s
~/Library/Application Support tolerates).

–ryan.On 10/26/13 10:15 PM, T. Joseph Carter wrote:

Am I not correct in that the org kind of serves the same purpose as
Apple/Java vendor identifiers?

Apple’s is com.apple, and I also have stuff like org.mozilla,
com.vmware, etc.

I’d say it’s expected in both cases.

~/Library/Application Support/Some Name/* is the norm, including by
Apple’s own stuff. The use of a Java-like identifier is expected in
~/Library/Preferences is tolerated, but uncommon. The converse is
true, of course.

Still, it’s about namespace preservation. I’m with you that it
should not ever be NULL. Give it something, because on some
platforms it’s not optional.

JosephOn Sun, Oct 27, 2013 at 09:12:34PM -0400, Ryan C. Gordon wrote:

Am I not correct in that the org kind of serves the same purpose as
Apple/Java vendor identifiers?

Apple’s is com.apple, and I also have stuff like org.mozilla,
com.vmware, etc.

No, it’s a proper name, like Windows expects (and Mac’s
~/Library/Application Support tolerates).