• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1/* GLIB - Library of useful routines for C programming
2 * Copyright (C) 2018-2019  Patrick Griffis, James Westman
3 *
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
8 *
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12 * Lesser General Public License for more details.
13 *
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, see <http://www.gnu.org/licenses/>.
16 */
17
18#include "config.h"
19
20#include <Foundation/Foundation.h>
21#include "gutils.h"
22#include "gstrfuncs.h"
23
24static gchar *
25find_folder (NSSearchPathDirectory type)
26{
27  gchar *filename;
28  NSString *path;
29  NSArray *paths;
30
31  paths = NSSearchPathForDirectoriesInDomains (type, NSUserDomainMask, YES);
32  path = [paths firstObject];
33  if (path == nil)
34    {
35      return NULL;
36    }
37
38  filename = g_strdup ([path UTF8String]);
39
40  return filename;
41}
42
43void
44load_user_special_dirs_macos(gchar **table)
45{
46  table[G_USER_DIRECTORY_DESKTOP] = find_folder (NSDesktopDirectory);
47  table[G_USER_DIRECTORY_DOCUMENTS] = find_folder (NSDocumentDirectory);
48  table[G_USER_DIRECTORY_DOWNLOAD] = find_folder (NSDownloadsDirectory);
49  table[G_USER_DIRECTORY_MUSIC] = find_folder (NSMusicDirectory);
50  table[G_USER_DIRECTORY_PICTURES] = find_folder (NSPicturesDirectory);
51  table[G_USER_DIRECTORY_PUBLIC_SHARE] = find_folder (NSSharedPublicDirectory);
52  table[G_USER_DIRECTORY_TEMPLATES] = NULL;
53  table[G_USER_DIRECTORY_VIDEOS] = find_folder (NSMoviesDirectory);
54}