~ubuntu-branches/ubuntu/precise/puredata/precise

« back to all changes in this revision

Viewing changes to src/s_file.c

  • Committer: Bazaar Package Importer
  • Author(s): Guenter Geiger (Debian/GNU)
  • Date: 2005-04-08 16:21:52 UTC
  • mfrom: (1.2.1 upstream) (2.1.1 hoary)
  • Revision ID: james.westby@ubuntu.com-20050408162152-88qyy276gx2qmx35
Tags: 0.38.4+amidi-3
* Incorporated mlock fix for 2.6 kernels
* moved allocation/deallocation out of midi poll() call for ALSA (this 
  cause problems on 2.6 kernel series when using -rt)

Show diffs side-by-side

added added

removed removed

Lines of Context:
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 */
15
 
int 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 */
28
 
void 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  */
43
 
void 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