Annotation of hatari/src/gui-osx/paths.m, revision 1.1

1.1     ! root        1: /*
        !             2:  Hatari - paths.m
        !             3: 
        !             4:  This file is distributed under the GNU General Public License, version 2
        !             5:  or at your option any later version. Read the file gpl.txt for details.
        !             6: 
        !             7:  macOS Objective-C helper function for accessing user configured
        !             8:  screenshot path
        !             9: 
        !            10:  */
        !            11: 
        !            12: #import <Foundation/Foundation.h>
        !            13: 
        !            14: #include "main.h"
        !            15: #include "paths.h"
        !            16: 
        !            17: /**
        !            18:  * Returns the user configured screenshot path property, or if none is found
        !            19:  * uses the macOS default of ~/Desktop/. Caller is responsible for freeing
        !            20:  * the returned pointer.
        !            21:  */
        !            22: char *Paths_GetMacScreenShotDir(void) {
        !            23: 
        !            24:        /* Allocate memory for storing the path string */
        !            25:        char *psPath = malloc(FILENAME_MAX);
        !            26:        if (!psPath)
        !            27:        {
        !            28:                fprintf(stderr, "Out of memory (Paths_GetMacScreenShotDir)\n");
        !            29:                exit(-1);
        !            30:        }
        !            31: 
        !            32:        NSString *keyValue = nil;
        !            33:        NSUserDefaults *defaults = [[NSUserDefaults alloc] init];
        !            34:        if(defaults != nil) {
        !            35:                [defaults addSuiteNamed:@"com.apple.screencapture.plist"];
        !            36:                keyValue = [defaults stringForKey:@"location"];
        !            37:        }
        !            38:        if (keyValue!=nil) {
        !            39:                strncpy(psPath, [keyValue UTF8String], FILENAME_MAX);
        !            40:        } else {
        !            41:                snprintf(psPath, FILENAME_MAX, "%s%c%s",
        !            42:                         Paths_GetUserHome(), PATHSEP, "Desktop");
        !            43:        }
        !            44: 
        !            45:        return psPath;
        !            46: }

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.