Mercurial > hg > dmlib
annotate src/dmfile.c @ 2260:972d56ad2b78
Do closedir() in dmResourcesLoadDirectory(), even when under Win32.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Mon, 17 Jun 2019 00:49:21 +0300 |
parents | 5046458d6c34 |
children | 36edd316184a |
rev | line source |
---|---|
0 | 1 /* |
2 * DMLib | |
414
c452a459e552
Clear up the file descriptions.
Matti Hamalainen <ccr@tnsp.org>
parents:
405
diff
changeset
|
3 * -- Standard I/O (stdio) file write/read endianess helpers |
0 | 4 * Programmed and designed by Matti 'ccr' Hamalainen |
5 * (C) Copyright 2011 Tecnic Software productions (TNSP) | |
6 */ | |
7 #include "dmfile.h" | |
8 | |
9 | |
405
d0257d0004f6
Implement dm_{read,write}_byte() and constify.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
10 BOOL dm_fread_str(FILE *f, void *buf, const size_t len) |
0 | 11 { |
12 return fread(buf, len, 1, f) == 1; | |
13 } | |
14 | |
15 | |
405
d0257d0004f6
Implement dm_{read,write}_byte() and constify.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
16 BOOL dm_fread_byte(FILE *f, Uint8 *val) |
d0257d0004f6
Implement dm_{read,write}_byte() and constify.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
17 { |
438
c1f6def0c1da
Adjust dm_fread_byte() and dm_fwrite_byte() stdio helper functions to match
Matti Hamalainen <ccr@tnsp.org>
parents:
414
diff
changeset
|
18 int tmp = fgetc(f); |
c1f6def0c1da
Adjust dm_fread_byte() and dm_fwrite_byte() stdio helper functions to match
Matti Hamalainen <ccr@tnsp.org>
parents:
414
diff
changeset
|
19 *val = tmp; |
c1f6def0c1da
Adjust dm_fread_byte() and dm_fwrite_byte() stdio helper functions to match
Matti Hamalainen <ccr@tnsp.org>
parents:
414
diff
changeset
|
20 return tmp != EOF; |
405
d0257d0004f6
Implement dm_{read,write}_byte() and constify.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
21 } |
d0257d0004f6
Implement dm_{read,write}_byte() and constify.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
22 |
d0257d0004f6
Implement dm_{read,write}_byte() and constify.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
23 |
0 | 24 #define DM_DEFINE_FFUNC(xname, xtype, xmacro) \ |
25 BOOL dm_fread_ ## xname (FILE *f, xtype *v) { \ | |
26 xtype result; \ | |
27 if (fread(&result, sizeof( xtype ), 1, f) != 1) \ | |
28 return FALSE; \ | |
29 *v = DM_ ## xmacro ## _TO_NATIVE (result); \ | |
30 return TRUE; \ | |
31 } | |
32 | |
33 #include "dmfiletmpl.h" | |
34 | |
35 #undef DM_DEFINE_FFUNC | |
36 | |
405
d0257d0004f6
Implement dm_{read,write}_byte() and constify.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
37 |
d0257d0004f6
Implement dm_{read,write}_byte() and constify.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
38 BOOL dm_fwrite_str(FILE *f, const void *buf, const size_t len) |
0 | 39 { |
40 return fwrite(buf, len, 1, f) == 1; | |
41 } | |
42 | |
43 | |
405
d0257d0004f6
Implement dm_{read,write}_byte() and constify.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
44 BOOL dm_fwrite_byte(FILE *f, const Uint8 val) |
d0257d0004f6
Implement dm_{read,write}_byte() and constify.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
45 { |
438
c1f6def0c1da
Adjust dm_fread_byte() and dm_fwrite_byte() stdio helper functions to match
Matti Hamalainen <ccr@tnsp.org>
parents:
414
diff
changeset
|
46 return fputc(val, f) == val; |
405
d0257d0004f6
Implement dm_{read,write}_byte() and constify.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
47 } |
d0257d0004f6
Implement dm_{read,write}_byte() and constify.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
48 |
d0257d0004f6
Implement dm_{read,write}_byte() and constify.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
49 |
0 | 50 #define DM_DEFINE_FFUNC(xname, xtype, xmacro) \ |
405
d0257d0004f6
Implement dm_{read,write}_byte() and constify.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
51 BOOL dm_fwrite_ ## xname (FILE *f, const xtype v) { \ |
0 | 52 xtype result = DM_NATIVE_TO_ ## xmacro (v); \ |
789 | 53 return fwrite(&result, sizeof( xtype ), 1, f) == 1; \ |
0 | 54 } |
55 | |
56 #include "dmfiletmpl.h" | |
57 | |
58 #undef DM_DEFINE_FFUNC | |
567
b2b461829c61
Move utility function dmReadDataFile() to dmfile module instead.
Matti Hamalainen <ccr@tnsp.org>
parents:
438
diff
changeset
|
59 |
b2b461829c61
Move utility function dmReadDataFile() to dmfile module instead.
Matti Hamalainen <ccr@tnsp.org>
parents:
438
diff
changeset
|
60 |
1474
6b1f41ca300a
Add dmWriteDataFile() helper function.
Matti Hamalainen <ccr@tnsp.org>
parents:
1473
diff
changeset
|
61 int dmWriteDataFile(FILE *fh, const char *filename, const Uint8 *buf, const size_t bufSize) |
6b1f41ca300a
Add dmWriteDataFile() helper function.
Matti Hamalainen <ccr@tnsp.org>
parents:
1473
diff
changeset
|
62 { |
1523
1750498bc746
Fix a warning in dmWriteDataFile().
Matti Hamalainen <ccr@tnsp.org>
parents:
1474
diff
changeset
|
63 int res = DMERR_OK; |
1474
6b1f41ca300a
Add dmWriteDataFile() helper function.
Matti Hamalainen <ccr@tnsp.org>
parents:
1473
diff
changeset
|
64 |
1523
1750498bc746
Fix a warning in dmWriteDataFile().
Matti Hamalainen <ccr@tnsp.org>
parents:
1474
diff
changeset
|
65 if (fh == NULL && filename != NULL && |
1750498bc746
Fix a warning in dmWriteDataFile().
Matti Hamalainen <ccr@tnsp.org>
parents:
1474
diff
changeset
|
66 (fh = fopen(filename, "wb")) == NULL) |
1474
6b1f41ca300a
Add dmWriteDataFile() helper function.
Matti Hamalainen <ccr@tnsp.org>
parents:
1473
diff
changeset
|
67 { |
1523
1750498bc746
Fix a warning in dmWriteDataFile().
Matti Hamalainen <ccr@tnsp.org>
parents:
1474
diff
changeset
|
68 res = dmGetErrno(); |
1750498bc746
Fix a warning in dmWriteDataFile().
Matti Hamalainen <ccr@tnsp.org>
parents:
1474
diff
changeset
|
69 return dmError(res, |
1750498bc746
Fix a warning in dmWriteDataFile().
Matti Hamalainen <ccr@tnsp.org>
parents:
1474
diff
changeset
|
70 "Could not open '%s' for writing: %s.\n", |
1750498bc746
Fix a warning in dmWriteDataFile().
Matti Hamalainen <ccr@tnsp.org>
parents:
1474
diff
changeset
|
71 filename, dmErrorStr(res)); |
1474
6b1f41ca300a
Add dmWriteDataFile() helper function.
Matti Hamalainen <ccr@tnsp.org>
parents:
1473
diff
changeset
|
72 } |
6b1f41ca300a
Add dmWriteDataFile() helper function.
Matti Hamalainen <ccr@tnsp.org>
parents:
1473
diff
changeset
|
73 |
6b1f41ca300a
Add dmWriteDataFile() helper function.
Matti Hamalainen <ccr@tnsp.org>
parents:
1473
diff
changeset
|
74 if (fh == NULL) |
6b1f41ca300a
Add dmWriteDataFile() helper function.
Matti Hamalainen <ccr@tnsp.org>
parents:
1473
diff
changeset
|
75 { |
1523
1750498bc746
Fix a warning in dmWriteDataFile().
Matti Hamalainen <ccr@tnsp.org>
parents:
1474
diff
changeset
|
76 res = dmError(DMERR_NULLPTR, |
1474
6b1f41ca300a
Add dmWriteDataFile() helper function.
Matti Hamalainen <ccr@tnsp.org>
parents:
1473
diff
changeset
|
77 "NULL filename and stream pointers.\n"); |
1523
1750498bc746
Fix a warning in dmWriteDataFile().
Matti Hamalainen <ccr@tnsp.org>
parents:
1474
diff
changeset
|
78 goto error; |
1474
6b1f41ca300a
Add dmWriteDataFile() helper function.
Matti Hamalainen <ccr@tnsp.org>
parents:
1473
diff
changeset
|
79 } |
6b1f41ca300a
Add dmWriteDataFile() helper function.
Matti Hamalainen <ccr@tnsp.org>
parents:
1473
diff
changeset
|
80 |
1695
ce3e56cfa9b9
Improve error checking in dmWriteDataFile().
Matti Hamalainen <ccr@tnsp.org>
parents:
1523
diff
changeset
|
81 if (fwrite(buf, 1, bufSize, fh) != bufSize) |
1474
6b1f41ca300a
Add dmWriteDataFile() helper function.
Matti Hamalainen <ccr@tnsp.org>
parents:
1473
diff
changeset
|
82 { |
6b1f41ca300a
Add dmWriteDataFile() helper function.
Matti Hamalainen <ccr@tnsp.org>
parents:
1473
diff
changeset
|
83 res = dmGetErrno(); |
6b1f41ca300a
Add dmWriteDataFile() helper function.
Matti Hamalainen <ccr@tnsp.org>
parents:
1473
diff
changeset
|
84 dmError(res, |
6b1f41ca300a
Add dmWriteDataFile() helper function.
Matti Hamalainen <ccr@tnsp.org>
parents:
1473
diff
changeset
|
85 "Error writing data to '%s': %s\n", |
6b1f41ca300a
Add dmWriteDataFile() helper function.
Matti Hamalainen <ccr@tnsp.org>
parents:
1473
diff
changeset
|
86 filename, dmErrorStr(res)); |
6b1f41ca300a
Add dmWriteDataFile() helper function.
Matti Hamalainen <ccr@tnsp.org>
parents:
1473
diff
changeset
|
87 } |
6b1f41ca300a
Add dmWriteDataFile() helper function.
Matti Hamalainen <ccr@tnsp.org>
parents:
1473
diff
changeset
|
88 |
1523
1750498bc746
Fix a warning in dmWriteDataFile().
Matti Hamalainen <ccr@tnsp.org>
parents:
1474
diff
changeset
|
89 error: |
1474
6b1f41ca300a
Add dmWriteDataFile() helper function.
Matti Hamalainen <ccr@tnsp.org>
parents:
1473
diff
changeset
|
90 if (fh != NULL) |
6b1f41ca300a
Add dmWriteDataFile() helper function.
Matti Hamalainen <ccr@tnsp.org>
parents:
1473
diff
changeset
|
91 fclose(fh); |
6b1f41ca300a
Add dmWriteDataFile() helper function.
Matti Hamalainen <ccr@tnsp.org>
parents:
1473
diff
changeset
|
92 |
6b1f41ca300a
Add dmWriteDataFile() helper function.
Matti Hamalainen <ccr@tnsp.org>
parents:
1473
diff
changeset
|
93 return res; |
6b1f41ca300a
Add dmWriteDataFile() helper function.
Matti Hamalainen <ccr@tnsp.org>
parents:
1473
diff
changeset
|
94 } |
6b1f41ca300a
Add dmWriteDataFile() helper function.
Matti Hamalainen <ccr@tnsp.org>
parents:
1473
diff
changeset
|
95 |
6b1f41ca300a
Add dmWriteDataFile() helper function.
Matti Hamalainen <ccr@tnsp.org>
parents:
1473
diff
changeset
|
96 |
567
b2b461829c61
Move utility function dmReadDataFile() to dmfile module instead.
Matti Hamalainen <ccr@tnsp.org>
parents:
438
diff
changeset
|
97 #define BUF_SIZE_INITIAL (16*1024) |
b2b461829c61
Move utility function dmReadDataFile() to dmfile module instead.
Matti Hamalainen <ccr@tnsp.org>
parents:
438
diff
changeset
|
98 #define BUF_SIZE_GROW (4*1024) |
b2b461829c61
Move utility function dmReadDataFile() to dmfile module instead.
Matti Hamalainen <ccr@tnsp.org>
parents:
438
diff
changeset
|
99 |
1473
c543f5ae92d5
Cleanup dmReadDataFile() helper function.
Matti Hamalainen <ccr@tnsp.org>
parents:
1102
diff
changeset
|
100 int dmReadDataFile(FILE *ffh, const char *filename, Uint8 **pbuf, size_t *pbufSize) |
567
b2b461829c61
Move utility function dmReadDataFile() to dmfile module instead.
Matti Hamalainen <ccr@tnsp.org>
parents:
438
diff
changeset
|
101 { |
1473
c543f5ae92d5
Cleanup dmReadDataFile() helper function.
Matti Hamalainen <ccr@tnsp.org>
parents:
1102
diff
changeset
|
102 FILE *fh = NULL; |
567
b2b461829c61
Move utility function dmReadDataFile() to dmfile module instead.
Matti Hamalainen <ccr@tnsp.org>
parents:
438
diff
changeset
|
103 int res = DMERR_OK; |
b2b461829c61
Move utility function dmReadDataFile() to dmfile module instead.
Matti Hamalainen <ccr@tnsp.org>
parents:
438
diff
changeset
|
104 Uint8 *dataBuf = NULL; |
b2b461829c61
Move utility function dmReadDataFile() to dmfile module instead.
Matti Hamalainen <ccr@tnsp.org>
parents:
438
diff
changeset
|
105 size_t readSize, dataSize, dataRead, dataPos; |
1102
e06abfde6c39
Cosmetics pass: Remove excess whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
1087
diff
changeset
|
106 |
1473
c543f5ae92d5
Cleanup dmReadDataFile() helper function.
Matti Hamalainen <ccr@tnsp.org>
parents:
1102
diff
changeset
|
107 if (ffh != NULL) |
c543f5ae92d5
Cleanup dmReadDataFile() helper function.
Matti Hamalainen <ccr@tnsp.org>
parents:
1102
diff
changeset
|
108 fh = ffh; |
567
b2b461829c61
Move utility function dmReadDataFile() to dmfile module instead.
Matti Hamalainen <ccr@tnsp.org>
parents:
438
diff
changeset
|
109 else |
b2b461829c61
Move utility function dmReadDataFile() to dmfile module instead.
Matti Hamalainen <ccr@tnsp.org>
parents:
438
diff
changeset
|
110 if (filename != NULL) |
b2b461829c61
Move utility function dmReadDataFile() to dmfile module instead.
Matti Hamalainen <ccr@tnsp.org>
parents:
438
diff
changeset
|
111 { |
1473
c543f5ae92d5
Cleanup dmReadDataFile() helper function.
Matti Hamalainen <ccr@tnsp.org>
parents:
1102
diff
changeset
|
112 if ((fh = fopen(filename, "rb")) == NULL) |
2227
5046458d6c34
Remove unnecessary error message.
Matti Hamalainen <ccr@tnsp.org>
parents:
1695
diff
changeset
|
113 return DMERR_FOPEN; |
567
b2b461829c61
Move utility function dmReadDataFile() to dmfile module instead.
Matti Hamalainen <ccr@tnsp.org>
parents:
438
diff
changeset
|
114 } |
1473
c543f5ae92d5
Cleanup dmReadDataFile() helper function.
Matti Hamalainen <ccr@tnsp.org>
parents:
1102
diff
changeset
|
115 |
c543f5ae92d5
Cleanup dmReadDataFile() helper function.
Matti Hamalainen <ccr@tnsp.org>
parents:
1102
diff
changeset
|
116 if (fh == NULL) |
567
b2b461829c61
Move utility function dmReadDataFile() to dmfile module instead.
Matti Hamalainen <ccr@tnsp.org>
parents:
438
diff
changeset
|
117 { |
958
985225a93aeb
Add error code parameter to dmError() and dmErrorVA().
Matti Hamalainen <ccr@tnsp.org>
parents:
812
diff
changeset
|
118 return dmError(DMERR_NULLPTR, |
985225a93aeb
Add error code parameter to dmError() and dmErrorVA().
Matti Hamalainen <ccr@tnsp.org>
parents:
812
diff
changeset
|
119 "NULL filename and stream pointers.\n"); |
567
b2b461829c61
Move utility function dmReadDataFile() to dmfile module instead.
Matti Hamalainen <ccr@tnsp.org>
parents:
438
diff
changeset
|
120 } |
b2b461829c61
Move utility function dmReadDataFile() to dmfile module instead.
Matti Hamalainen <ccr@tnsp.org>
parents:
438
diff
changeset
|
121 |
b2b461829c61
Move utility function dmReadDataFile() to dmfile module instead.
Matti Hamalainen <ccr@tnsp.org>
parents:
438
diff
changeset
|
122 // Allocate initial data buffer |
b2b461829c61
Move utility function dmReadDataFile() to dmfile module instead.
Matti Hamalainen <ccr@tnsp.org>
parents:
438
diff
changeset
|
123 readSize = dataSize = BUF_SIZE_INITIAL; |
b2b461829c61
Move utility function dmReadDataFile() to dmfile module instead.
Matti Hamalainen <ccr@tnsp.org>
parents:
438
diff
changeset
|
124 if ((dataBuf = dmMalloc(dataSize)) == NULL) |
b2b461829c61
Move utility function dmReadDataFile() to dmfile module instead.
Matti Hamalainen <ccr@tnsp.org>
parents:
438
diff
changeset
|
125 { |
958
985225a93aeb
Add error code parameter to dmError() and dmErrorVA().
Matti Hamalainen <ccr@tnsp.org>
parents:
812
diff
changeset
|
126 res = dmError(DMERR_MALLOC, |
985225a93aeb
Add error code parameter to dmError() and dmErrorVA().
Matti Hamalainen <ccr@tnsp.org>
parents:
812
diff
changeset
|
127 "Error allocating memory for data, %d bytes.\n", dataSize); |
567
b2b461829c61
Move utility function dmReadDataFile() to dmfile module instead.
Matti Hamalainen <ccr@tnsp.org>
parents:
438
diff
changeset
|
128 goto error; |
b2b461829c61
Move utility function dmReadDataFile() to dmfile module instead.
Matti Hamalainen <ccr@tnsp.org>
parents:
438
diff
changeset
|
129 } |
b2b461829c61
Move utility function dmReadDataFile() to dmfile module instead.
Matti Hamalainen <ccr@tnsp.org>
parents:
438
diff
changeset
|
130 |
1473
c543f5ae92d5
Cleanup dmReadDataFile() helper function.
Matti Hamalainen <ccr@tnsp.org>
parents:
1102
diff
changeset
|
131 // Read the data |
c543f5ae92d5
Cleanup dmReadDataFile() helper function.
Matti Hamalainen <ccr@tnsp.org>
parents:
1102
diff
changeset
|
132 dataPos = dataRead = 0; |
c543f5ae92d5
Cleanup dmReadDataFile() helper function.
Matti Hamalainen <ccr@tnsp.org>
parents:
1102
diff
changeset
|
133 while (!feof(fh) && !ferror(fh)) |
567
b2b461829c61
Move utility function dmReadDataFile() to dmfile module instead.
Matti Hamalainen <ccr@tnsp.org>
parents:
438
diff
changeset
|
134 { |
1473
c543f5ae92d5
Cleanup dmReadDataFile() helper function.
Matti Hamalainen <ccr@tnsp.org>
parents:
1102
diff
changeset
|
135 size_t read = fread(dataBuf + dataPos, 1, readSize, fh); |
567
b2b461829c61
Move utility function dmReadDataFile() to dmfile module instead.
Matti Hamalainen <ccr@tnsp.org>
parents:
438
diff
changeset
|
136 dataPos += read; |
b2b461829c61
Move utility function dmReadDataFile() to dmfile module instead.
Matti Hamalainen <ccr@tnsp.org>
parents:
438
diff
changeset
|
137 dataRead += read; |
b2b461829c61
Move utility function dmReadDataFile() to dmfile module instead.
Matti Hamalainen <ccr@tnsp.org>
parents:
438
diff
changeset
|
138 |
b2b461829c61
Move utility function dmReadDataFile() to dmfile module instead.
Matti Hamalainen <ccr@tnsp.org>
parents:
438
diff
changeset
|
139 if (dataRead >= dataSize) |
b2b461829c61
Move utility function dmReadDataFile() to dmfile module instead.
Matti Hamalainen <ccr@tnsp.org>
parents:
438
diff
changeset
|
140 { |
b2b461829c61
Move utility function dmReadDataFile() to dmfile module instead.
Matti Hamalainen <ccr@tnsp.org>
parents:
438
diff
changeset
|
141 readSize = BUF_SIZE_GROW; |
b2b461829c61
Move utility function dmReadDataFile() to dmfile module instead.
Matti Hamalainen <ccr@tnsp.org>
parents:
438
diff
changeset
|
142 dataSize += BUF_SIZE_GROW; |
b2b461829c61
Move utility function dmReadDataFile() to dmfile module instead.
Matti Hamalainen <ccr@tnsp.org>
parents:
438
diff
changeset
|
143 if ((dataBuf = dmRealloc(dataBuf, dataSize)) == NULL) |
b2b461829c61
Move utility function dmReadDataFile() to dmfile module instead.
Matti Hamalainen <ccr@tnsp.org>
parents:
438
diff
changeset
|
144 { |
958
985225a93aeb
Add error code parameter to dmError() and dmErrorVA().
Matti Hamalainen <ccr@tnsp.org>
parents:
812
diff
changeset
|
145 res = dmError(DMERR_MALLOC, |
985225a93aeb
Add error code parameter to dmError() and dmErrorVA().
Matti Hamalainen <ccr@tnsp.org>
parents:
812
diff
changeset
|
146 "Error reallocating memory for data, %d bytes.\n", |
985225a93aeb
Add error code parameter to dmError() and dmErrorVA().
Matti Hamalainen <ccr@tnsp.org>
parents:
812
diff
changeset
|
147 dataSize); |
567
b2b461829c61
Move utility function dmReadDataFile() to dmfile module instead.
Matti Hamalainen <ccr@tnsp.org>
parents:
438
diff
changeset
|
148 goto error; |
b2b461829c61
Move utility function dmReadDataFile() to dmfile module instead.
Matti Hamalainen <ccr@tnsp.org>
parents:
438
diff
changeset
|
149 } |
b2b461829c61
Move utility function dmReadDataFile() to dmfile module instead.
Matti Hamalainen <ccr@tnsp.org>
parents:
438
diff
changeset
|
150 } |
b2b461829c61
Move utility function dmReadDataFile() to dmfile module instead.
Matti Hamalainen <ccr@tnsp.org>
parents:
438
diff
changeset
|
151 else |
b2b461829c61
Move utility function dmReadDataFile() to dmfile module instead.
Matti Hamalainen <ccr@tnsp.org>
parents:
438
diff
changeset
|
152 break; |
b2b461829c61
Move utility function dmReadDataFile() to dmfile module instead.
Matti Hamalainen <ccr@tnsp.org>
parents:
438
diff
changeset
|
153 } |
b2b461829c61
Move utility function dmReadDataFile() to dmfile module instead.
Matti Hamalainen <ccr@tnsp.org>
parents:
438
diff
changeset
|
154 |
b2b461829c61
Move utility function dmReadDataFile() to dmfile module instead.
Matti Hamalainen <ccr@tnsp.org>
parents:
438
diff
changeset
|
155 *pbufSize = dataRead; |
b2b461829c61
Move utility function dmReadDataFile() to dmfile module instead.
Matti Hamalainen <ccr@tnsp.org>
parents:
438
diff
changeset
|
156 *pbuf = dataBuf; |
b2b461829c61
Move utility function dmReadDataFile() to dmfile module instead.
Matti Hamalainen <ccr@tnsp.org>
parents:
438
diff
changeset
|
157 |
b2b461829c61
Move utility function dmReadDataFile() to dmfile module instead.
Matti Hamalainen <ccr@tnsp.org>
parents:
438
diff
changeset
|
158 error: |
1473
c543f5ae92d5
Cleanup dmReadDataFile() helper function.
Matti Hamalainen <ccr@tnsp.org>
parents:
1102
diff
changeset
|
159 if (ffh != fh) |
c543f5ae92d5
Cleanup dmReadDataFile() helper function.
Matti Hamalainen <ccr@tnsp.org>
parents:
1102
diff
changeset
|
160 fclose(fh); |
1102
e06abfde6c39
Cosmetics pass: Remove excess whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
1087
diff
changeset
|
161 |
567
b2b461829c61
Move utility function dmReadDataFile() to dmfile module instead.
Matti Hamalainen <ccr@tnsp.org>
parents:
438
diff
changeset
|
162 return res; |
b2b461829c61
Move utility function dmReadDataFile() to dmfile module instead.
Matti Hamalainen <ccr@tnsp.org>
parents:
438
diff
changeset
|
163 } |