Main Page   Alphabetical List   Compound List   File List   Compound Members   File Members   Related Pages  

File Class Reference

Keeps all information, dependecies etc for one file. More...

#include <file.h>

Collaboration diagram for File:

Collaboration graph
[legend]
List of all members.

Public Methods

 File (const char *fname)
 Initializes all inner structures. More...

 ~File ()
 Deletes paths and next.

void setGraphExcluded (int n, bool state)
 Tells this file that it should be excluded from the graph number n when it's drawn. More...

const char* getFileName (void)
const char* getPath (void)
const char* getFullName (void)
File* getNext ()
int getExtension (void)
File* addNextFile (File *file)
 Adds the File object after itself, unless it is NULL in which case nothing happens. More...

void resolveDependencies (void)
 Parses the source-file (if its .c/.cc/.cpp or .h/.hh/.hpp) and extracts include statements. More...

void print (bool recursive=false)
 Prints the contents of a file object. More...

void tagRebuild (void)
 Tags all files that need be rebuilt. More...

void writeCompilation (FILE *stream, const char *compiler)
 Writes all compilation lines to a stream. More...

void writeLink (FILE *stream, const char *executable, const char *linker, const char *linkerTail)
 Writes the final link directive to a stream. More...

bool writeDot (const char *dotFile)
 Writes a number of dot-graphs. More...


Static Public Methods

void addFile (File *file)
 Adds a file to the fileRoot. More...

void printRegistered (void)
 Prints the name of all files registered in the two pointers fileRoot and otherFilesRoot.


Private Methods

void noDuplicates (const char *fname)
 Loads all lines in fname and discards lines that exactly like a previously encountered line, leaving only unique lines with no duplicates. More...

char* warpPath (char *incPath)
void writeDotNodes (FILE *stream, bool followCPP=false)
 Writes a dot graph of the dependencies. More...

void writeDotCPPs (FILE *stream, File *from)
 Writes a dot graph of the CPP-files dependencies. More...

void writeDotCPPs2 (FILE *stream)
 Writes a dot graph of the dependencies for CPP-files and header files with class definitions in them. More...

void writeDotCPPsubs (FILE *stream, File *from, bool CPPOnly=false)
 Writes a dot graph of the CPP-files dependencies. More...

void getIncludePath (char **paths, int &count)
 Determines the include path needed. More...

void writeObjects (FILE *stream)
 Dumps all rebuilt objects (including path) to a stream. More...

bool isObjFileOld (time_t t)
 Asks recursively, following the header files from the dependencies, if any of them are newer than t. More...

bool isNewer (time_t t)
File* addDependency (File *file)
 Adds a File as a dependency. More...

int getStats (void)
 Gets stats about the File, if that isn't possible the return is non-zero.

void disectFilename (void)
 Splits the fullName into path and filename.

void guess (void)
 If the extension is CPP then a File is added as objFile with a faked extension of obj.


Private Attributes

char* fullName
char * path
char * fileName
char * dotName
int extension
struct stat stats
File* objFile
File* cppFile [MAXDEPEND]
File* hFile [MAXDEPEND]
File* next
bool rebuild
bool scanned
bool tagged
bool compiled
bool objected
bool included
bool dotted
bool subDotted
bool ageChecked
bool excluded [EXCLUDELISTS]
 This list needs to be expanded when implementation of more exclude lists is made.

bool hasClass
 If extension is EXTH and the word class appears in the file and if guess found no EXTCPP-file then the file "has the class".

int hFileCount
int cppFileCount

Static Private Methods

const char* stripPath (const char *incPath)
void clearIncluded (void)
 Sets all included flags to false to allow the building of a new include path. More...

void clearAgeChecked (void)
 Sets all ageChecked flags to false to allow a new object file to be checked for rebuild. More...

void clearDotted (void)
 Sets all dotted flags to false to allow the building of new dot output. More...

void clearSubDotted (void)
 Sets all subDotted flags to false to allow the building of new dot output. More...

File* findFile (const char *fname, const char *ext, bool &aCopy)
 Attempts to create a File object from a filename and an extension (the current extension is switched to the supplied). More...

File* getFileNoPath (const char *fname)
 Runs through the linked list starting in fileRoot, searching for the file named fname. More...


Detailed Description

Keeps all information, dependecies etc for one file.

If getFileName returns NULL, then the file doesn't exist.

Basically it is a linked list of File objects, but that is just a practical way of managing them.

Author(s):
Philip Bergen
Version:
1.0

Definition at line 53 of file file.h.


Constructor & Destructor Documentation

File::File ( const char * fname ) [inline]
 

Initializes all inner structures.

Parameters:
fname   The complete absolute or relative path to the file to represent.

Definition at line 61 of file file.h.

Referenced by findFile().

File::~File ( ) [inline]
 

Deletes paths and next.

Definition at line 117 of file file.h.


Member Function Documentation

File * File::addDependency ( File * file ) [inline, private]
 

Adds a File as a dependency.

If MAXDEPEND is reached the program is halted.

Parameters:
file   Any File object from a header file. If it is not a header file then nothing is added.
Returns:
The file-pointer.

Definition at line 958 of file file.h.

Referenced by guess(), and resolveDependencies().

void File::addFile ( File * file ) [inline, static]
 

Adds a file to the fileRoot.

Parameters:
file   Any file that has not already been added to the fileRoot.

Definition at line 1259 of file file.h.

Referenced by Maker::Maker(), Maker::addHeaderFiles(), guess(), and resolveDependencies().

File * File::addNextFile ( File * file ) [inline]
 

Adds the File object after itself, unless it is NULL in which case nothing happens.

No sorting.

Parameters:
file   Any file object that is not already in the list!
Returns:
The supplied File object.

Definition at line 189 of file file.h.

void File::clearAgeChecked ( void ) [inline, static, private]
 

Sets all ageChecked flags to false to allow a new object file to be checked for rebuild.

Recursive along next.

Definition at line 1150 of file file.h.

Referenced by tagRebuild().

void File::clearDotted ( void ) [inline, static, private]
 

Sets all dotted flags to false to allow the building of new dot output.

Recursive along next.

Definition at line 1165 of file file.h.

Referenced by writeDot().

void File::clearIncluded ( void ) [inline, static, private]
 

Sets all included flags to false to allow the building of a new include path.

Recursive along next.

Definition at line 1135 of file file.h.

Referenced by writeCompilation().

void File::clearSubDotted ( void ) [inline, static, private]
 

Sets all subDotted flags to false to allow the building of new dot output.

Recursive along next.

Definition at line 1180 of file file.h.

Referenced by writeDot(), and writeDotCPPs2().

void File::disectFilename ( void ) [inline, private]
 

Splits the fullName into path and filename.

Definition at line 1028 of file file.h.

Referenced by File().

File* File::findFile ( const char * fname,
const char * ext,
bool & aCopy ) [inline, static, private]
 

Attempts to create a File object from a filename and an extension (the current extension is switched to the supplied).

Parameters:
fname   Any filename with or without path.
ext   Any extension with out leading dot. If NULL the extension is left unchanged.
Returns:
A new File object if the file existed else NULL;

Definition at line 1198 of file file.h.

Referenced by guess(), and resolveDependencies().

int File::getExtension ( void ) [inline]
 

Returns:
0 for unknown file type, 1 for .h/.hh/.hpp files, 2 for .c/.cc/.cpp files and 3 for .o/.obj files.

Definition at line 178 of file file.h.

Referenced by Maker::addHeaderFiles().

const char * File::getFileName ( void ) [inline]
 

Returns:
The fileName without path. If NULL then the File does not exist.

Definition at line 144 of file file.h.

Referenced by Maker::addHeaderFiles(), and Maker::generateDotOutput().

File* File::getFileNoPath ( const char * fname ) [inline, static, private]
 

Runs through the linked list starting in fileRoot, searching for the file named fname.

Comparing ONLY the fileName NOT the whole name and path!!!

Parameters:
fname   Any file with .h/.hh/.hpp extension.
Returns:
A opinter to the File object or NULL if it is not in the chain.

Definition at line 1239 of file file.h.

Referenced by findFile(), and resolveDependencies().

const char * File::getFullName ( void ) [inline]
 

Returns:
The fullName, if NULL then the File is screwed.

Definition at line 161 of file file.h.

void File::getIncludePath ( char ** paths,
int & count ) [inline, private]
 

Determines the include path needed.

Recursive.

Parameters:
paths   A list of previous paths (to avoid adding the same more than once).
count   The number of strings in paths. Is incremented when new paths are added.

Definition at line 852 of file file.h.

Referenced by writeCompilation().

File * File::getNext ( ) [inline]
 

Returns:
The next pointer.

Definition at line 169 of file file.h.

Referenced by Maker::generateDotOutput().

const char * File::getPath ( void ) [inline]
 

Returns:
The path without fileName. If NULL then the File is in local directory.

Definition at line 153 of file file.h.

int File::getStats ( void ) [inline, private]
 

Gets stats about the File, if that isn't possible the return is non-zero.

Definition at line 1020 of file file.h.

Referenced by File().

void File::guess ( void ) [inline, private]
 

If the extension is CPP then a File is added as objFile with a faked extension of obj.

Definition at line 1078 of file file.h.

Referenced by File().

bool File::isNewer ( time_t t ) [inline, private]
 

Parameters:
t   A UNIX-style time.
Returns:
true if the queried file is newer than t.

Definition at line 946 of file file.h.

Referenced by isObjFileOld().

bool File::isObjFileOld ( time_t t ) [inline, private]
 

Asks recursively, following the header files from the dependencies, if any of them are newer than t.

Parameters:
t   The modification time of the object file.
Returns:
true if the objectFile is too old.

Definition at line 921 of file file.h.

Referenced by tagRebuild().

void File::noDuplicates ( const char * fname ) [inline, private]
 

Loads all lines in fname and discards lines that exactly like a previously encountered line, leaving only unique lines with no duplicates.

Those lines are written to the file fname.

Parameters:
fname   Name and path to a file that will be purged of duplicate lines.

Definition at line 528 of file file.h.

Referenced by writeDot().

void File::print ( bool recursive = false ) [inline]
 

Prints the contents of a file object.

Parameters:
recursive   If true then next is followed.

Definition at line 315 of file file.h.

Referenced by printRegistered().

void File::printRegistered ( void ) [inline, static]
 

Prints the name of all files registered in the two pointers fileRoot and otherFilesRoot.

Definition at line 1278 of file file.h.

void File::resolveDependencies ( void ) [inline]
 

Parses the source-file (if its .c/.cc/.cpp or .h/.hh/.hpp) and extracts include statements.

Standard path includes in brackets are ignored.

All include statements after line 128 is ignored. First occurence of the word 'class' on the beginning of a line terminates the parsing of the file.

Recursively calls its dependencies and cppFile if any.

File objects are sought through the fileRoot.

Definition at line 215 of file file.h.

Referenced by Maker::resolveDependencies().

void File::setGraphExcluded ( int n,
bool state ) [inline]
 

Tells this file that it should be excluded from the graph number n when it's drawn.

Parameters:
n   The exclude list to enable.
state   The state to put entry in exclude list to.

Definition at line 132 of file file.h.

Referenced by Maker::generateDotOutput().

const char* File::stripPath ( const char * incPath ) [inline, static, private]
 

Parameters:
incPath   Any include path.
Returns:
A pointer in the supplied string pointing at the filename after the path. Caller must NOT DELETE!

Definition at line 630 of file file.h.

Referenced by getFileNoPath().

void File::tagRebuild ( void ) [inline]
 

Tags all files that need be rebuilt.

Recursive.

Definition at line 342 of file file.h.

Referenced by Maker::resolveDependencies().

char * File::warpPath ( char * incPath ) [inline, private]
 

Parameters:
incPath   Any include path.
Returns:
A static string of a path less relative. Caller must NOT DELETE!

Definition at line 584 of file file.h.

Referenced by resolveDependencies().

void File::writeCompilation ( FILE * stream,
const char * compiler ) [inline]
 

Writes all compilation lines to a stream.

Recursive.

Parameters:
stream   Any open stream.
compiler   The compiler string from OptionReader.
See also:
OptionReader::getCompiler()

Definition at line 385 of file file.h.

Referenced by Maker::generateMakescript().

bool File::writeDot ( const char * dotFile ) [inline]
 

Writes a number of dot-graphs.

Parameters:
dotFile   The dot file name from OptionReader.
Returns:
True if successful.
See also:
OptionReader::getDotoutput

Definition at line 446 of file file.h.

Referenced by Maker::generateDotOutput().

void File::writeDotCPPs ( FILE * stream,
File * from ) [inline, private]
 

Writes a dot graph of the CPP-files dependencies.

Recursive.

Parameters:
stream   Any open stream.
from   The File that will be depending on this if this is a CPP-file.

Definition at line 709 of file file.h.

Referenced by writeDot().

void File::writeDotCPPs2 ( FILE * stream ) [inline, private]
 

Writes a dot graph of the dependencies for CPP-files and header files with class definitions in them.

Recursive.

Parameters:
stream   Any open stream.
from   The File that will be depending on this if this is a CPP-file.

Definition at line 751 of file file.h.

Referenced by writeDot().

void File::writeDotCPPsubs ( FILE * stream,
File * from,
bool CPPOnly = false ) [inline, private]
 

Writes a dot graph of the CPP-files dependencies.

Recursive.

Parameters:
stream   Any open stream.
from   The File that will be depending on this if this is a CPP-file. MUST NOT BE NULL!

Definition at line 817 of file file.h.

Referenced by writeDotCPPs2().

void File::writeDotNodes ( FILE * stream,
bool followCPP = false ) [inline, private]
 

Writes a dot graph of the dependencies.

Recursive.

Parameters:
stream   Any open stream.
followCPP   If true the recursion goes into the CPP-files as well.

Definition at line 651 of file file.h.

Referenced by writeDot().

void File::writeLink ( FILE * stream,
const char * executable,
const char * linker,
const char * linkerTail ) [inline]
 

Writes the final link directive to a stream.

Parameters:
stream   Any open stream.
executable   The target file name for the executable from OptionReader.
linker   The linker command from OptionReader.
linkerTail   The linker tailing string from OptionReader.
See also:
OptionReader::getExecutable , OptionReader::getLinker , OptionReader::getLinkerTail

Definition at line 431 of file file.h.

Referenced by Maker::generateMakescript().

void File::writeObjects ( FILE * stream ) [inline, private]
 

Dumps all rebuilt objects (including path) to a stream.

Recursive.

Parameters:
stream   Any stream that is open.

Definition at line 892 of file file.h.

Referenced by writeLink().


Member Data Documentation

bool File::ageChecked [private]
 

Definition at line 1296 of file file.h.

bool File::compiled [private]
 

Definition at line 1296 of file file.h.

File* File::cppFile[MAXDEPEND] [private]
 

Definition at line 1293 of file file.h.

int File::cppFileCount [private]
 

Definition at line 1304 of file file.h.

char * File::dotName [private]
 

Definition at line 1289 of file file.h.

bool File::dotted [private]
 

Definition at line 1296 of file file.h.

bool File::excluded [private]
 

This list needs to be expanded when implementation of more exclude lists is made.

Definition at line 1300 of file file.h.

int File::extension [private]
 

Definition at line 1290 of file file.h.

char * File::fileName [private]
 

Definition at line 1289 of file file.h.

char* File::fullName [private]
 

Definition at line 1289 of file file.h.

File* File::hFile[MAXDEPEND] [private]
 

Definition at line 1294 of file file.h.

int File::hFileCount [private]
 

Definition at line 1304 of file file.h.

bool File::hasClass [private]
 

If extension is EXTH and the word class appears in the file and if guess found no EXTCPP-file then the file "has the class".

Definition at line 1303 of file file.h.

bool File::included [private]
 

Definition at line 1296 of file file.h.

File* File::next [private]
 

Definition at line 1295 of file file.h.

File* File::objFile [private]
 

Definition at line 1292 of file file.h.

bool File::objected [private]
 

Definition at line 1296 of file file.h.

char * File::path [private]
 

Definition at line 1289 of file file.h.

bool File::rebuild [private]
 

Definition at line 1296 of file file.h.

bool File::scanned [private]
 

Definition at line 1296 of file file.h.

struct stat File::stats [private]
 

Definition at line 1291 of file file.h.

bool File::subDotted [private]
 

Definition at line 1296 of file file.h.

bool File::tagged [private]
 

Definition at line 1296 of file file.h.


The documentation for this class was generated from the following file:
Generated at Mon May 14 00:45:44 2001 for Maker by doxygen1.2.6 written by Dimitri van Heesch, © 1997-2001