Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
David MacDonald
purr-data
Commits
586f5fcc
Commit
586f5fcc
authored
Jan 22, 2017
by
Jonathan Wilkes
Browse files
Merge branch 'aggraef/purr-data-testing'
parents
1f813229
7be15ee6
Changes
1
Hide whitespace changes
Inline
Side-by-side
pd/src/s_file.c
View file @
586f5fcc
...
...
@@ -331,6 +331,25 @@ static void sys_donesavepreferences( void)
#endif
/* __APPLE__ */
#ifdef _WIN32
static
int
check_exists
(
const
char
*
path
)
{
char
pathbuf
[
MAXPDSTRING
];
wchar_t
ucs2path
[
MAXPDSTRING
];
sys_bashfilename
(
path
,
pathbuf
);
u8_utf8toucs2
(
ucs2path
,
MAXPDSTRING
,
pathbuf
,
MAXPDSTRING
-
1
);
return
(
0
==
_waccess
(
ucs2path
,
0
));
}
#else
#include <unistd.h>
static
int
check_exists
(
const
char
*
path
)
{
char
pathbuf
[
MAXPDSTRING
];
sys_bashfilename
(
path
,
pathbuf
);
return
(
0
==
access
(
pathbuf
,
0
));
}
#endif
void
sys_loadpreferences
(
void
)
{
int
naudioindev
,
audioindev
[
MAXAUDIOINDEV
],
chindev
[
MAXAUDIOINDEV
];
...
...
@@ -475,6 +494,8 @@ void sys_loadpreferences( void)
sprintf
(
keybuf
,
"path%d"
,
i
+
1
);
if
(
!
sys_getpreference
(
keybuf
,
prefbuf
,
MAXPDSTRING
))
break
;
else
if
(
!
check_exists
(
prefbuf
))
// AG: ignore non-existent paths
continue
;
sys_searchpath
=
namelist_append_files
(
sys_searchpath
,
prefbuf
);
}
if
(
sys_getpreference
(
"standardpath"
,
prefbuf
,
MAXPDSTRING
))
...
...
@@ -644,19 +665,11 @@ void glob_savepreferences(t_pd *dummy)
int
sys_n_recent_files
=
0
;
char
*
sys_recent_files
[
MAX_RECENT_FILES
];
static
int
fexists
(
const
char
*
s
)
{
FILE
*
fp
=
sys_fopen
(
s
,
"r"
);
if
(
!
fp
)
return
0
;
sys_fclose
(
fp
);
return
1
;
}
void
sys_add_recent_file
(
const
char
*
s
)
{
int
i
;
// only add the file if it actually exists
if
(
!
f
exists
(
s
))
return
;
if
(
!
check_
exists
(
s
))
return
;
for
(
i
=
0
;
i
<
sys_n_recent_files
&&
strcmp
(
sys_recent_files
[
i
],
s
);
i
++
)
;
if
(
i
<
sys_n_recent_files
)
{
// already got an existing entry, move it to the front
...
...
@@ -736,7 +749,7 @@ void sys_load_recent_files(void)
int
l
=
strlen
(
filenamebuf
);
if
(
l
>
0
&&
filenamebuf
[
l
-
1
]
==
'\n'
)
filenamebuf
[
--
l
]
=
0
;
// only add files which actually exist
if
(
l
==
0
||
!
f
exists
(
filenamebuf
))
continue
;
if
(
l
==
0
||
!
check_
exists
(
filenamebuf
))
continue
;
s
=
strdup
(
filenamebuf
);
if
(
s
)
sys_recent_files
[
sys_n_recent_files
++
]
=
s
;
}
...
...
@@ -755,7 +768,7 @@ void sys_load_recent_files(void)
if
(
!
sys_getpreference
(
keybuf
,
prefbuf
,
MAXPDSTRING
))
break
;
l
=
strlen
(
prefbuf
);
if
(
l
==
0
||
!
f
exists
(
prefbuf
))
continue
;
if
(
l
==
0
||
!
check_
exists
(
prefbuf
))
continue
;
s
=
strdup
(
prefbuf
);
if
(
s
)
sys_recent_files
[
sys_n_recent_files
++
]
=
s
;
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment