File: sndwin32.c

package info (click to toggle)
audacity 0.98-3
  • links: PTS
  • area: main
  • in suites: woody
  • size: 2,896 kB
  • ctags: 4,089
  • sloc: cpp: 26,099; ansic: 4,961; sh: 2,465; makefile: 156; perl: 23
file content (78 lines) | stat: -rw-r--r-- 1,337 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
#include <windows.h>
#include <io.h>
#include <fcntl.h>
#include <stdio.h>
#include <sys/stat.h>

#include "snd.h"
#include "sndfileio.h"

#define PERMISSION 0x0644

void snd_fail(char *msg)
{
    MessageBox(0, msg, 0, 0);
    //exit(1);
}

int snd_file_open(char *fname, int mode)
{
    int file;
    if (mode == SND_RDONLY) mode = _O_RDONLY;
    else mode = _O_RDWR;
    file = _open(fname, mode | _O_BINARY);
    return file;
}


int snd_file_creat(char *fname)
{
    int file = _open(fname, _O_TRUNC | _O_WRONLY | 
                            _O_CREAT | _O_BINARY, _S_IREAD | _S_IWRITE);
    return file;
}


long snd_file_len(int file)
{
    long len;
    struct stat statbuf;

    fstat(file ,&statbuf);
    len = (long) statbuf.st_size;  /* get length of file */
    return len;
}


long snd_file_read(int fp, char *data, long len)
{
    return read(fp, data, len);
}


long snd_file_write(int fp, char *data, long len)
{
    return write(fp, data, len);
}


int snd_file_close(int fp)
{
    return close(fp);
}


int snd_file_lseek(int file, long offset, int param)
{
    if (param == SND_SEEK_CUR) param = SEEK_CUR;
    else if (param == SND_SEEK_SET) param = SEEK_SET;
    else param = SEEK_END;
    return _lseek(file, offset, param);
}


void *snd_alloc(size_t s) { return malloc(s); }


void snd_free(void *a) { free(a); }