~ubuntu-branches/ubuntu/saucy/glib2.0/saucy-proposed

« back to all changes in this revision

Viewing changes to glib/gutils.c

  • Committer: Package Import Robot
  • Author(s): Iain Lane
  • Date: 2013-08-21 10:08:49 UTC
  • mfrom: (1.63.24)
  • Revision ID: package-import@ubuntu.com-20130821100849-enhti9o2tk0iug5r
Tags: 2.37.6-1ubuntu1
* Resynchronise with Debian, remaining change:
  - Build-Depend on python:any for cross-building.

Show diffs side-by-side

added added

removed removed

Lines of Context:
963
963
/**
964
964
 * g_get_tmp_dir:
965
965
 *
966
 
 * Gets the directory to use for temporary files. This is found from 
967
 
 * inspecting the environment variables <envar>TMPDIR</envar>, 
968
 
 * <envar>TMP</envar>, and <envar>TEMP</envar> in that order. If none 
969
 
 * of those are defined "/tmp" is returned on UNIX and "C:\" on Windows. 
970
 
 * The encoding of the returned string is system-defined. On Windows, 
971
 
 * it is always UTF-8. The return value is never %NULL or the empty string.
 
966
 * Gets the directory to use for temporary files.
 
967
 *
 
968
 * On UNIX, this is taken from the <envar>TMPDIR</envar> environment
 
969
 * variable.  If the variable is not set, <literal>P_tmpdir</literal> is
 
970
 * used, as defined by the system C library.  Failing that, a hard-coded
 
971
 * default of "/tmp" is returned.
 
972
 *
 
973
 * On Windows, the <envar>TEMP</envar> environment variable is used,
 
974
 * with the root directory of the Windows installation (eg: "C:\") used
 
975
 * as a default.
 
976
 *
 
977
 * The encoding of the returned string is system-defined. On Windows, it
 
978
 * is always UTF-8. The return value is never %NULL or the empty string.
972
979
 *
973
980
 * Returns: the directory to use for temporary files.
974
981
 */
981
988
    {
982
989
      gchar *tmp;
983
990
 
 
991
#ifdef G_OS_WIN32
 
992
      tmp = g_strdup (g_getenv ("TEMP"));
 
993
 
 
994
      if (tmp == NULL || *tmp == '\0')
 
995
        {
 
996
          g_free (tmp);
 
997
          tmp = get_windows_directory_root ();
 
998
        }
 
999
#else /* G_OS_WIN32 */
984
1000
      tmp = g_strdup (g_getenv ("TMPDIR"));
985
1001
 
986
 
      if (tmp == NULL || *tmp == '\0')
987
 
        {
988
 
          g_free (tmp);
989
 
          tmp = g_strdup (g_getenv ("TMP"));
990
 
        }
991
 
 
992
 
      if (tmp == NULL || *tmp == '\0')
993
 
        {
994
 
          g_free (tmp);
995
 
          tmp = g_strdup (g_getenv ("TEMP"));
996
 
        }
997
 
 
998
 
#ifdef G_OS_WIN32
999
 
      if (tmp == NULL || *tmp == '\0')
1000
 
        {
1001
 
          g_free (tmp);
1002
 
          tmp = get_windows_directory_root ();
1003
 
        }
1004
 
#else
1005
 
 
1006
1002
#ifdef P_tmpdir
1007
1003
      if (tmp == NULL || *tmp == '\0')
1008
1004
        {
1013
1009
          if (k > 1 && G_IS_DIR_SEPARATOR (tmp[k - 1]))
1014
1010
            tmp[k - 1] = '\0';
1015
1011
        }
1016
 
#endif
 
1012
#endif /* P_tmpdir */
1017
1013
 
1018
1014
      if (tmp == NULL || *tmp == '\0')
1019
1015
        {