Commit a0c1d7e8 authored by Andrea Bulgarelli's avatar Andrea Bulgarelli
Browse files

added File::fsize() and a parameter to File::open

parent 2fc79095
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -115,6 +115,9 @@ public:
    ///  Count the number of string lines into a text file.
    long getNumberOfStringLines();
    
    ///  The dimension of the file
    dword fsize();

    static dword byte_read;

    static dword char_read;
+4 −2
Original line number Diff line number Diff line
@@ -46,6 +46,8 @@ public:
        return 0;
    };
    
    virtual dword setpos(dword offset) throw(PacketExceptionIO*);

protected:

    File* file;
+2 −0
Original line number Diff line number Diff line
@@ -36,6 +36,8 @@ public:

    virtual void close() throw(PacketExceptionIO*);

	///first parameter: filename
	///second parameter: fopen modes: w, r, a (optional)
    virtual bool open(char** parameters) throw(PacketExceptionIO*);

    virtual bool writeByteStream(ByteStreamPtr b) throw(PacketExceptionIO*);
+15 −0
Original line number Diff line number Diff line
@@ -345,3 +345,18 @@ bool File::writeByteStream(ByteStreamPtr b) throw(PacketExceptionIO*)
    return true;

}

dword File::fsize(){
	if(closed)
		return 0;
		
    long prev=ftell(fp);
    if(prev == -1L)
    	return 0;
    fseek(fp, 0L, SEEK_END);
    long sz=ftell(fp);
    if(sz == -1L)
    	return 0;
    fseek(fp,prev,SEEK_SET); //go back to where we were
    return sz;
}
+4 −0
Original line number Diff line number Diff line
@@ -74,3 +74,7 @@ char* InputFile::readString() throw(PacketExceptionIO*)
    eof = file->isEOF();
    return c;
}

dword InputFile::setpos(dword offset) throw(PacketExceptionIO*) {
	return file->setpos(offset);
}
Loading