Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
P
purr-data
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Jonathan Wilkes
purr-data
Commits
656f9aac
Commit
656f9aac
authored
8 years ago
by
Albert Gräf
Browse files
Options
Downloads
Patches
Plain Diff
Make sure that we fall back to the default preferences if needed. Fixes
#234
.
parent
1ce4a09c
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!66
Make sure that we fall back to the default preferences if needed. Fixes #234.
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
pd/src/s_file.c
+34
-1
34 additions, 1 deletion
pd/src/s_file.c
with
34 additions
and
1 deletion
pd/src/s_file.c
+
34
−
1
View file @
656f9aac
...
@@ -280,6 +280,39 @@ static void sys_initloadpreferences(void)
...
@@ -280,6 +280,39 @@ static void sys_initloadpreferences(void)
FILE
*
fp
;
FILE
*
fp
;
size_t
sz
,
n
=
0
;
size_t
sz
,
n
=
0
;
int
res
;
int
res
;
char
default_prefs
[
FILENAME_MAX
];
// default prefs embedded in the package
char
embedded_prefs
[
FILENAME_MAX
];
// overrides others for standalone app
char
embedded_prefs_file
[
FILENAME_MAX
];
char
user_prefs_file
[
FILENAME_MAX
];
const
char
*
prefs
,
*
homedir
=
getenv
(
"HOME"
);
struct
stat
statbuf
;
// On the Mac, we first look for an embedded prefs file, then for a user
// prefs file, and fall back to the defaults in the package if none of
// these exist. Note that Pd-l2ork can't create standalone apps à la
// Pd-extended right now, but we might want to support them in the future,
// so we handle the embedded prefs case anyway.
snprintf
(
default_prefs
,
FILENAME_MAX
,
"%s/../org.puredata.pd-l2ork.default"
,
sys_libdir
->
s_name
);
snprintf
(
embedded_prefs
,
FILENAME_MAX
,
"%s/../org.puredata.pd-l2ork"
,
sys_libdir
->
s_name
);
snprintf
(
embedded_prefs_file
,
FILENAME_MAX
,
"%s.plist"
,
embedded_prefs
);
snprintf
(
user_prefs_file
,
FILENAME_MAX
,
"%s/Library/Preferences/org.puredata.pd-l2ork.plist"
,
homedir
);
if
(
stat
(
embedded_prefs_file
,
&
statbuf
)
==
0
)
{
// Read from and write to the embedded prefs (standalone app).
prefs
=
embedded_prefs
;
strncpy
(
current_prefs
,
embedded_prefs
,
FILENAME_MAX
);
}
else
if
(
stat
(
user_prefs_file
,
&
statbuf
)
==
0
)
{
// Read from and write to the user prefs.
prefs
=
current_prefs
;
strcpy
(
current_prefs
,
"org.puredata.pd-l2ork"
);
}
else
{
// Read from the package defaults and write to the user prefs.
prefs
=
default_prefs
;
strcpy
(
current_prefs
,
"org.puredata.pd-l2ork"
);
}
// This looks complicated, but is rather straightforward. The individual
// This looks complicated, but is rather straightforward. The individual
// stages of the pipe are:
// stages of the pipe are:
// 1. defaults export: grab our defaults in XML format
// 1. defaults export: grab our defaults in XML format
...
@@ -293,7 +326,7 @@ static void sys_initloadpreferences(void)
...
@@ -293,7 +326,7 @@ static void sys_initloadpreferences(void)
// "loadlib1" : "libdir", loadlib1: libdir
// "loadlib1" : "libdir", loadlib1: libdir
// "path1" : "\/System\/Library\/Fonts" path1: /System/Library/Fonts
// "path1" : "\/System\/Library\/Fonts" path1: /System/Library/Fonts
// }
// }
snprintf
(
cmdbuf
,
MAXPDSTRING
,
"defaults export %s - | plutil -convert json -r -o - - | sed -E -e 's/[{}]//g' -e 's/^ *
\"
(([^
\"
]|
\\\\
.)*)
\"
*: *
\"
(([^
\"
]|
\\\\
.)*)
\"
.*/
\\
1:
\\
3/' -e 's/
\\\\
(.)/
\\
1/g'"
,
current_
prefs
);
snprintf
(
cmdbuf
,
MAXPDSTRING
,
"defaults export %s - | plutil -convert json -r -o - - | sed -E -e 's/[{}]//g' -e 's/^ *
\"
(([^
\"
]|
\\\\
.)*)
\"
*: *
\"
(([^
\"
]|
\\\\
.)*)
\"
.*/
\\
1:
\\
3/' -e 's/
\\\\
(.)/
\\
1/g'"
,
prefs
);
// open the pipe
// open the pipe
fp
=
popen
(
cmdbuf
,
"r"
);
fp
=
popen
(
cmdbuf
,
"r"
);
if
(
!
fp
)
{
if
(
!
fp
)
{
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment