Lines Matching defs:file
3 * File:
7 * This file contains the host wrapper functions for stdio, stdlib, etc.
9 * The file locator (EAS_FILE_LOCATOR) handle passed to
12 * Modify this file to suit the needs of your particular system.
15 * a MIDI type 1 file that can be played.
17 * EAS_HW_FILE is a structure to support the file I/O functions. It
18 * comprises the file descriptor, the file read pointer, and
19 * the dup flag, which when set, indicates that the file handle has
20 * been duplicated, and offset and length within the file.
25 * you may not use this file except in compliance with the License.
72 // 100 max file handles == 3 * (nb tracks(32) + 1 for the segment) + 1 for jet file
84 * the file size and read position.
111 EAS_HW_FILE *file;
114 /* need to track file opens for duplicate handles */
121 file = (*pHWInstData)->files;
124 file->fd = -1;
125 file++;
233 * Open a file for read or write
239 EAS_HW_FILE *file;
250 /* find an empty entry in the file table */
251 file = hwInstData->files;
255 if (file->fd < 0)
258 /* open the file */
263 /* else file is already open */
267 /* determine the file size */
273 if ((file->fileSize = lseek(fd, 0, SEEK_CUR)) == -1L) {
279 // file size was passed in
281 file->fileSize = (EAS_I32) locator->length;
284 file->fd = fd;
285 file->offset = locator->offset;
288 file->filePos = 0;
289 file->dup = EAS_FALSE;
291 *pFile = file;
294 file++;
306 * Read data from a file
311 EAS_RESULT EAS_HWReadFile (EAS_HW_DATA_HANDLE hwInstData, EAS_FILE_HANDLE file, void *pBuffer, EAS_I32 n, EAS_I32 *pBytesRead)
316 if (file->fd < 0)
323 count = file->fileSize - file->filePos;
331 lseek(file->fd, file->filePos + file->offset, SEEK_SET);
332 count = read(file->fd, pBuffer, count);
334 file->filePos += count;
347 * Read a byte from a file
352 EAS_RESULT EAS_HWGetByte (EAS_HW_DATA_HANDLE hwInstData, EAS_FILE_HANDLE file, void *p)
355 return EAS_HWReadFile(hwInstData, file, p, 1, &numread);
362 * Read a 16 bit word from a file
367 EAS_RESULT EAS_HWGetWord (EAS_HW_DATA_HANDLE hwInstData, EAS_FILE_HANDLE file, void *p, EAS_BOOL msbFirst)
372 /* read 2 bytes from the file */
373 if ((result = EAS_HWGetByte(hwInstData, file, &c1)) != EAS_SUCCESS)
375 if ((result = EAS_HWGetByte(hwInstData, file, &c2)) != EAS_SUCCESS)
391 * Returns the current location in the file
396 EAS_RESULT EAS_HWGetDWord (EAS_HW_DATA_HANDLE hwInstData, EAS_FILE_HANDLE file, void *p, EAS_BOOL msbFirst)
401 /* read 4 bytes from the file */
402 if ((result = EAS_HWGetByte(hwInstData, file, &c1)) != EAS_SUCCESS)
404 if ((result = EAS_HWGetByte(hwInstData, file, &c2)) != EAS_SUCCESS)
406 if ((result = EAS_HWGetByte(hwInstData, file, &c3)) != EAS_SUCCESS)
408 if ((result = EAS_HWGetByte(hwInstData, file, &c4)) != EAS_SUCCESS)
424 * Returns the current location in the file
429 EAS_RESULT EAS_HWFilePos (EAS_HW_DATA_HANDLE hwInstData, EAS_FILE_HANDLE file, EAS_I32 *pPosition)
433 if (file->fd < 0)
436 *pPosition = file->filePos;
444 * Seek to a specific location in the file
449 EAS_RESULT EAS_HWFileSeek (EAS_HW_DATA_HANDLE hwInstData, EAS_FILE_HANDLE file, EAS_I32 position)
453 if (file->fd < 0)
457 if ((position < 0) || (position > file->fileSize))
461 file->filePos = position;
474 EAS_RESULT EAS_HWFileSeekOfs (EAS_HW_DATA_HANDLE hwInstData, EAS_FILE_HANDLE file, EAS_I32 position)
478 if (file->fd < 0)
481 /* determine the file position */
482 position += file->filePos;
483 if ((position < 0) || (position > file->fileSize))
487 file->filePos = position;
495 * Return the file length
500 EAS_RESULT EAS_HWFileLength (EAS_HW_DATA_HANDLE hwInstData, EAS_FILE_HANDLE file, EAS_I32 *pLength)
504 if (file->fd < 0)
507 *pLength = file->fileSize;
515 * Duplicate a file handle
519 EAS_RESULT EAS_HWDupHandle (EAS_HW_DATA_HANDLE hwInstData, EAS_FILE_HANDLE file, EAS_FILE_HANDLE *pDupFile)
525 if (file->fd < 0)
528 /* find an empty entry in the file table */
536 dupFile->filePos = file->filePos;
537 dupFile->fileSize = file->fileSize;
538 dupFile->fd = file->fd;
539 dupFile->offset = file->offset;
542 dupFile->dup = file->dup = EAS_TRUE;
609 /* no duplicates - close the file */