Lines Matching refs:file

7  * This file contains the host wrapper functions for stdio, stdlib, etc.
10 * file system calls. The file locator (EAS_FILE_LOCATOR) handle passed
13 * using a file system, you can use the locator handle to point to
18 * Modify this file to suit the needs of your particular system.
21 * a MIDI type 1 file that can be played.
23 * EAS_HW_FILE is a structure to support the file I/O functions. It
24 * comprises the base memory pointer, the file read pointer, and
25 * the dup flag, which when sets, indicates that the file handle has
28 * base memory pointer and file read pointer to the duplicate handle.
33 * you may not use this file except in compliance with the License.
79 * the file size and read position.
104 /* need to track file opens for duplicate handles */
198 * Open a file for read or write
204 EAS_HW_FILE *file;
215 /* find an empty entry in the file table */
216 file = hwInstData->files;
220 if (file->buffer == NULL)
222 /* open the file */
226 /* determine the file size */
229 if ((file->fileSize = ftell(ioFile)) == -1L)
235 file->buffer = EAS_HWMalloc(hwInstData, file->fileSize);
236 if (file->buffer == NULL)
242 /* read the file into memory */
243 temp = (int) fread(file->buffer, (size_t) file->fileSize, 1, ioFile);
245 /* close the file - don't need it any more */
248 /* check for error reading file */
253 file->filePos = 0;
254 file->dup = EAS_FALSE;
256 *pFile = file;
259 file++;
270 * Read data from a file
275 EAS_RESULT EAS_HWReadFile (EAS_HW_DATA_HANDLE hwInstData, EAS_FILE_HANDLE file, void *pBuffer, EAS_I32 n, EAS_I32 *pBytesRead)
280 if (file->buffer == NULL)
284 count = file->fileSize - file->filePos;
290 EAS_HWMemCpy(pBuffer, &file->buffer[file->filePos], count);
291 file->filePos += count;
304 * Read a byte from a file
309 EAS_RESULT EAS_HWGetByte (EAS_HW_DATA_HANDLE hwInstData, EAS_FILE_HANDLE file, void *p)
313 if (file->buffer == NULL)
316 /* check for end of file */
317 if (file->filePos >= file->fileSize)
324 *((EAS_U8*) p) = file->buffer[file->filePos++];
332 * Returns the current location in the file
337 EAS_RESULT EAS_HWGetWord (EAS_HW_DATA_HANDLE hwInstData, EAS_FILE_HANDLE file, void *p, EAS_BOOL msbFirst)
342 /* read 2 bytes from the file */
343 if ((result = EAS_HWGetByte(hwInstData, file, &c1)) != EAS_SUCCESS)
345 if ((result = EAS_HWGetByte(hwInstData, file, &c2)) != EAS_SUCCESS)
361 * Returns the current location in the file
366 EAS_RESULT EAS_HWGetDWord (EAS_HW_DATA_HANDLE hwInstData, EAS_FILE_HANDLE file, void *p, EAS_BOOL msbFirst)
371 /* read 4 bytes from the file */
372 if ((result = EAS_HWGetByte(hwInstData, file, &c1)) != EAS_SUCCESS)
374 if ((result = EAS_HWGetByte(hwInstData, file, &c2)) != EAS_SUCCESS)
376 if ((result = EAS_HWGetByte(hwInstData, file, &c3)) != EAS_SUCCESS)
378 if ((result = EAS_HWGetByte(hwInstData, file, &c4)) != EAS_SUCCESS)
394 * Returns the current location in the file
399 EAS_RESULT EAS_HWFilePos (EAS_HW_DATA_HANDLE hwInstData, EAS_FILE_HANDLE file, EAS_I32 *pPosition)
403 if (file->buffer == NULL)
406 *pPosition = file->filePos;
414 * Seek to a specific location in the file
419 EAS_RESULT EAS_HWFileSeek (EAS_HW_DATA_HANDLE hwInstData, EAS_FILE_HANDLE file, EAS_I32 position)
423 if (file->buffer == NULL)
427 if ((position < 0) || (position > file->fileSize))
431 file->filePos = position;
444 EAS_RESULT EAS_HWFileSeekOfs (EAS_HW_DATA_HANDLE hwInstData, EAS_FILE_HANDLE file, EAS_I32 position)
448 if (file->buffer == NULL)
451 /* determine the file position */
452 position += file->filePos;
453 if ((position < 0) || (position > file->fileSize))
457 file->filePos = position;
465 * Return the file length
470 EAS_RESULT EAS_HWFileLength (EAS_HW_DATA_HANDLE hwInstData, EAS_FILE_HANDLE file, EAS_I32 *pLength)
474 if (file->buffer == NULL)
477 *pLength = file->fileSize;
485 * Duplicate a file handle
489 EAS_RESULT EAS_HWDupHandle (EAS_HW_DATA_HANDLE hwInstData, EAS_FILE_HANDLE file, EAS_FILE_HANDLE *pDupFile)
495 if (file->buffer == NULL)
498 /* find an empty entry in the file table */
507 dupFile->filePos = file->filePos;
508 dupFile->fileSize = file->fileSize;
509 dupFile->buffer = file->buffer;
512 dupFile->dup = file->dup = EAS_TRUE;