void TFileViewer::readFile( const char *fName ) { delete fileName; limit.x = 0; fileName = newStr( fName ); fileLines = new TLineCollection(5, 5); ifstream fileToView( fName ); if( !fileToView ) { messageBox( "Invalid drive or directory", mfError | mfOKButton ); isValid = False; } else { char line[maxLineLength+1]; while( !lowMemory() && !fileToView.eof() && fileToView.get( line, sizeof line ) != 0 ) { char c; fileToView.get(c); // grab trailing newline limit.x = max( limit.x, strlen( line ) ); fileLines->insert( newStr( line ) ); } isValid = True; } limit.y = fileLines->getCount(); }
/* * Incarca continutul fisierului in buffere interne. */ void TInterior::readFile(const char *fileName) { ifstream fileToView(fileName); if (fileToView) { char buf[maxLineLength]; while (lineCount < maxLines && fileToView.getline(buf, maxLineLength) != 0) { lines[lineCount] = newStr(buf); lineCount++; } } }
void readFile( const char *fileName ) { ifstream fileToView( fileName ); if( !fileToView ) { cout << "Invalid file name..." << endl; exit( 1 ); } else { char buf[maxLineLength]; while( lineCount < maxLines && fileToView.getline( buf, maxLineLength ) != 0 ) { lines[lineCount] = newStr( buf ); lineCount++; } } }