summaryrefslogtreecommitdiff
path: root/audio/fcplay/files/patch-Main.cpp
blob: 05fd9ccda1379d2bc06d790d0e6238d4b4cdb5e7 (plain) (blame)
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
--- Main.cpp.orig	1997-03-03 21:47:00 UTC
+++ Main.cpp
@@ -1,8 +1,11 @@
-#include <fstream.h>
+#include <fstream>
 #include <limits.h>
 #include <signal.h>
 #include <stdlib.h>
-#include <string.h>
+#include <cstring>
+#include <iostream>
+using namespace std;
+#include <new>
 
 #include "FC.h"
 #include "MyTypes.h"
@@ -95,11 +98,7 @@ int main(int argc, char *argv[])
     streampos fileLen = 0;
   
     // open binary input file stream at end of file
-#if defined(HAVE_IOS_BIN)
-    ifstream myIn( argv[inFileArgN], ios::in | ios::bin | ios::ate | ios::nocreate );
-#else
-    ifstream myIn( argv[inFileArgN], ios::in | ios::binary | ios::ate | ios::nocreate );
-#endif
+    ifstream myIn( argv[inFileArgN], ios::in | ios::binary | ios::ate );
 	// As a replacement for !is_open(), bad() and the NOT-operator don't seem
 	// to work on all systems.
 #if defined(DONT_HAVE_IS_OPEN)
@@ -119,20 +118,20 @@ int main(int argc, char *argv[])
     fileLen = (udword)myIn.tellg();
 #endif
 	fileLen = myIn.tellg();
-	buffer = new ubyte[fileLen+extraFileBufLen];
+	buffer = new(std::nothrow) ubyte[(long int)fileLen+extraFileBufLen];
 	
 	myIn.seekg(0,ios::beg);
 	cout << "Loading" << flush;
 	streampos restFileLen = fileLen;
 	while ( restFileLen > INT_MAX )
     {
-        myIn.read( buffer + (fileLen - restFileLen), INT_MAX );
+        myIn.read( (char*)buffer + (fileLen - restFileLen), INT_MAX );
         restFileLen -= INT_MAX;
         cout << "." << flush;
 	}
 	if ( restFileLen > 0 )
     {
-        myIn.read( buffer + (fileLen - restFileLen), restFileLen );
+        myIn.read( (char*)buffer + (fileLen - restFileLen), restFileLen );
         cout << "." << flush;
 	}
 	cout << endl << flush;
@@ -147,7 +146,7 @@ int main(int argc, char *argv[])
     extern udword pcmFreq;
     pcmFreq = 44100;
 
-    ubyte* sampleBuffer = new ubyte[pcmFreq];
+    ubyte* sampleBuffer = new(std::nothrow) ubyte[pcmFreq];
 
     AudioConfig myAudioCfg;
     myAudioCfg.frequency = pcmFreq;