Fix some greedy sed changes in imported code. Also provide a sys/types.h for compatib...
[kugel-rb.git] / apps / plugins / pdbox / PDa / src / s_file.c
blob4995e8704ea4c1fdf17bddfe25027a7960c96aed
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. */
5 /*
6 * this file contains file-handling routines.
7 */
9 #ifdef ROCKBOX
10 #include "plugin.h"
11 #include "../../pdbox.h"
12 #include "m_pd.h"
13 #include "s_stuff.h"
14 #else /* ROCKBOX */
15 #include "m_pd.h"
16 #include "s_stuff.h"
17 #include <sys/types.h>
18 #include <sys/stat.h>
19 #endif /* ROCKBOX */
21 /* LATER delete this? -- replaced by find_via_path() in s_path.c */
22 int sys_isreadablefile(const char *s)
24 #ifdef ROCKBOX
25 int fd;
27 if((fd = open(s, O_RDONLY)))
29 close(fd);
30 return 1;
32 else
33 return 0;
34 #else /* ROCKBOX */
35 struct stat statbuf;
36 int mode;
37 if (stat(s, &statbuf) < 0) return (0);
38 #ifdef UNIX
39 mode = statbuf.st_mode;
40 if (S_ISDIR(mode)) return (0);
41 #endif
42 return (1);
43 #endif /* ROCKBOX */
46 /* change '/' characters to the system's native file separator */
47 void sys_bashfilename(const char *from, char *to)
49 char c;
50 while((c = *from++))
52 #ifdef MSW
53 if (c == '/') c = '\\';
54 #endif
55 *to++ = c;
57 *to = 0;
61 /* change the system's native file separator to '/' characters */
62 void sys_unbashfilename(const char *from, char *to)
64 char c;
65 while((c = *from++))
67 #ifdef MSW
68 if (c == '\\') c = '/';
69 #endif
70 *to++ = c;
72 *to = 0;