3
Copyright (C) 1999 Martin Vogt
5
This program is free software; you can redistribute it and/or modify
6
it under the terms of the GNU Library General Public License as published by
7
the Free Software Foundation.
9
For more information look at the file COPYRIGHT in this package
15
#include "fileInputStream.h"
18
FileInputStream::FileInputStream() {
25
FileInputStream::~FileInputStream() {
30
int FileInputStream::open(const char* dest) {
37
if (strlen(dest) == 1) {
38
if (strncmp(dest,"-",1)==0) {
39
file=::fdopen(0,"rb");
42
// load out of current dir if no full path is given
44
file=fopen(dest,"rb");
49
perror("cannot open file");
54
fileLen=(long)fileStat.st_size;
56
int back=(file!=NULL);
61
void FileInputStream::close() {
70
int FileInputStream::isOpen() {
75
int FileInputStream::eof() {
88
int FileInputStream::read(char* ptr,int size) {
92
cout << "size is <= 0!"<<endl;
96
bytesRead=fread(ptr,1,size,file);
99
cerr << "read on not open file want:"<<size<<endl;
103
//perror("zero bytes fread");
110
int FileInputStream::seek(long posInBytes) {
112
if (isOpen()==false) {
117
pos=fseek(file,posInBytes,SEEK_SET);
121
//perror("seek in setBytePos");
128
long FileInputStream::getByteLength() {
133
long FileInputStream::getBytePosition() {
145
void FileInputStream::print() {
146
printf("pos in file:%8x\n",(int)getBytePosition());