File: wxsnd.cpp

package info (click to toggle)
nyquist 3.24%2Bds-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 58,156 kB
  • sloc: ansic: 74,757; lisp: 18,169; java: 10,942; cpp: 6,688; sh: 175; xml: 58; makefile: 40; python: 15
file content (101 lines) | stat: -rw-r--r-- 1,462 bytes parent folder | download | duplicates (9)
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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
/*
 * wxWindows port of snd library
 *
 * Dominic Mazzoni
 */

// For compilers that support precompilation, includes "wx/wx.h".
#include "wx/wxprec.h"

#ifdef __BORLANDC__
#pragma hdrstop
#endif

#ifndef WX_PRECOMP
#include "wx/wx.h"
#endif

#include "wx/file.h"

#include "wxsnd.h"

extern "C" {

void snd_fail(char *msg)
{
    wxMessageBox(msg);
}

int wxsnd_open(char *fname, int mode)
{
  wxFile *f = new wxFile();	  
  
  if (mode == O_RDONLY)
      f->Open(fname, wxFile::read);
    else
      f->Open(fname, wxFile::read_write);
    
  if (!f->IsOpened())
    return 0;
  
  return (int)f;
}

int wxsnd_creat(char *fname, int perms)
{
  wxFile *f = new wxFile();	  
  
    f->Create(fname);
    
  if (!f->IsOpened())
    return 0;
  
  return (int)f;
}

int wxsnd_lseek(int file, int offset, int param)
{
  wxFile *f = (wxFile *)file;
  
  if (param == L_SET)
    f->Seek(offset, wxFromStart);
  else if (param == L_INCR)
    f->Seek(offset, wxFromCurrent);
  else
    f->Seek(offset, wxFromEnd);
  
  return offset;
}

int wxsnd_read(int fp, char *data, int len)
{
    wxFile *f = (wxFile *)fp;
    
    return f->Read(data, len);
}

int wxsnd_write(int fp, char *data, int len)
{
    wxFile *f = (wxFile *)fp;
    
    return f->Write(data, len);
}

int wxsnd_close(int fp)
{
    wxFile *f = (wxFile *)fp;
    
    if (f)
      delete f;
    
  return 1;
}

long wxsnd_getfilelen(int fp)
{
    wxFile *f = (wxFile *)fp;

    return f->Length();
}

};