include/readFile.h File Reference

This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  readFile

Functions

readFile readFile_open (char *filename)
void readFile_close (struct readFile readFile)
int readFile_checkOpen (char *filename)


Function Documentation

int readFile_checkOpen ( char *  filename  ) 

Definition at line 59 of file readFile.c.

Referenced by readdb_open().

00060 {
00061         FILE* file;
00062 
00063         if ((file = fopen(filename, "r")) != NULL)
00064     {
00065         fclose(file);
00066         return 1;
00067         }
00068     else
00069                 return 0;
00070 }

Here is the caller graph for this function:

void readFile_close ( struct readFile  readFile  ) 

Definition at line 73 of file readFile.c.

References readFile::address, readFile::fileDescriptor, and readFile::fileSize.

Referenced by main(), readdb_close(), and readdb_nextVolume().

00074 {
00075         if (munmap(readFile.address, readFile.fileSize) < 0)
00076         {
00077         fprintf(stderr, "%s\n", strerror(errno));
00078                 fprintf(stderr, "Error unmapping file\n");
00079                 exit(-1);
00080         }
00081         close(readFile.fileDescriptor);
00082 }

Here is the caller graph for this function:

struct readFile readFile_open ( char *  filename  )  [read]

Definition at line 22 of file readFile.c.

References readFile::address, readFile::fileDescriptor, and readFile::fileSize.

Referenced by main(), readdb_nextVolume(), and readdb_open().

00023 {
00024         struct stat fileStats;
00025         struct readFile readFile;
00026 
00027         // Open file for reading
00028         if ((readFile.fileDescriptor = open(filename, O_RDONLY)) == -1)
00029         {
00030         fprintf(stderr, "%s\n", strerror(errno));
00031                 fprintf(stderr, "Error opening file %s for reading\n", filename);
00032                 exit(-1);
00033         }
00034 
00035         // Get length of file
00036         if (fstat(readFile.fileDescriptor, &fileStats) == -1)
00037         {
00038         fprintf(stderr, "%s\n", strerror(errno));
00039                 fprintf(stderr, "Error opening file %s for reading\n", filename);
00040                 exit(-1);
00041         }
00042         readFile.fileSize = fileStats.st_size;
00043 
00044     // Map address to fileSize bytes of application address space
00045     readFile.address = mmap(0, readFile.fileSize, PROT_READ, MAP_SHARED, readFile.fileDescriptor, 0);
00046 
00047     // Check for error in mapping
00048         if (readFile.address == (void*)MAP_FAILED)
00049         {
00050         fprintf(stderr, "%s\n", strerror(errno));
00051                 fprintf(stderr, "Error opening file %s for reading\n", filename);
00052                 exit(-1);
00053         }
00054 
00055         return readFile;
00056 }

Here is the caller graph for this function:


Generated on Wed Dec 19 20:51:25 2007 for fsa-blast by  doxygen 1.5.2