summaryrefslogtreecommitdiff
path: root/apps/plugins/pdbox/PDa/src/s_file.c
diff options
context:
space:
mode:
authorPeter D'Hoye <peter.dhoye@gmail.com>2009-05-22 21:58:48 +0000
committerPeter D'Hoye <peter.dhoye@gmail.com>2009-05-22 21:58:48 +0000
commit513389b4c1bc8afe4b2dc9947c534bfeb105e3da (patch)
tree10e673b35651ac567fed2eda0c679c7ade64cbc6 /apps/plugins/pdbox/PDa/src/s_file.c
parent95fa7f6a2ef466444fbe3fe87efc6d5db6b77b36 (diff)
downloadrockbox-513389b4c1bc8afe4b2dc9947c534bfeb105e3da.tar.gz
rockbox-513389b4c1bc8afe4b2dc9947c534bfeb105e3da.zip
Add FS #10214. Initial commit of the original PDa code for the GSoC Pure Data plugin project of Wincent Balin. Stripped some non-sourcefiles and added a rockbox readme that needs a bit more info from Wincent. Is added to CATEGORIES and viewers, but not yet to SUBDIRS (ie doesn't build yet)
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@21044 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'apps/plugins/pdbox/PDa/src/s_file.c')
-rw-r--r--apps/plugins/pdbox/PDa/src/s_file.c110
1 files changed, 110 insertions, 0 deletions
diff --git a/apps/plugins/pdbox/PDa/src/s_file.c b/apps/plugins/pdbox/PDa/src/s_file.c
new file mode 100644
index 0000000000..2d3c4e5580
--- /dev/null
+++ b/apps/plugins/pdbox/PDa/src/s_file.c
@@ -0,0 +1,110 @@
1/* Copyright (c) 1997-1999 Miller Puckette.
2* For information on usage and redistribution, and for a DISCLAIMER OF ALL
3* WARRANTIES, see the file, "LICENSE.txt," in this distribution. */
4
5/*
6 * this file contains file-handling routines.
7 */
8
9#include "m_pd.h"
10#include "s_stuff.h"
11#include <sys/types.h>
12#include <sys/stat.h>
13
14 /* LATER delete this? -- replaced by find_via_path() in s_path.c */
15int sys_isreadablefile(const char *s)
16{
17 struct stat statbuf;
18 int mode;
19 if (stat(s, &statbuf) < 0) return (0);
20#ifdef UNIX
21 mode = statbuf.st_mode;
22 if (S_ISDIR(mode)) return (0);
23#endif
24 return (1);
25}
26
27 /* change '/' characters to the system's native file separator */
28void sys_bashfilename(const char *from, char *to)
29{
30 char c;
31 while (c = *from++)
32 {
33#ifdef MSW
34 if (c == '/') c = '\\';
35#endif
36 *to++ = c;
37 }
38 *to = 0;
39}
40
41
42 /* change the system's native file separator to '/' characters */
43void sys_unbashfilename(const char *from, char *to)
44{
45 char c;
46 while (c = *from++)
47 {
48#ifdef MSW
49 if (c == '\\') c = '/';
50#endif
51 *to++ = c;
52 }
53 *to = 0;
54}
55
56/* Copyright (c) 1997-1999 Miller Puckette.
57* For information on usage and redistribution, and for a DISCLAIMER OF ALL
58* WARRANTIES, see the file, "LICENSE.txt," in this distribution. */
59
60/*
61 * this file contains file-handling routines.
62 */
63
64#include "m_pd.h"
65#include "s_stuff.h"
66#include <sys/types.h>
67#include <sys/stat.h>
68
69 /* LATER delete this? -- replaced by find_via_path() in s_path.c */
70int sys_isreadablefile(const char *s)
71{
72 struct stat statbuf;
73 int mode;
74 if (stat(s, &statbuf) < 0) return (0);
75#ifdef UNIX
76 mode = statbuf.st_mode;
77 if (S_ISDIR(mode)) return (0);
78#endif
79 return (1);
80}
81
82 /* change '/' characters to the system's native file separator */
83void sys_bashfilename(const char *from, char *to)
84{
85 char c;
86 while (c = *from++)
87 {
88#ifdef MSW
89 if (c == '/') c = '\\';
90#endif
91 *to++ = c;
92 }
93 *to = 0;
94}
95
96
97 /* change the system's native file separator to '/' characters */
98void sys_unbashfilename(const char *from, char *to)
99{
100 char c;
101 while (c = *from++)
102 {
103#ifdef MSW
104 if (c == '\\') c = '/';
105#endif
106 *to++ = c;
107 }
108 *to = 0;
109}
110