home *** CD-ROM | disk | FTP | other *** search
- /*-- Rev Header - do NOT edit!
- *
- * Filename : editfile.cc
- * Purpose : Eine Klasse, die das Bearbeiten von Files erleichtert
- *
- * Program : -
- * Author : Gerhard Müller
- * Copyright: (c) by Gerhard Müller
- * Creation : Tue Sep 7 02:26:39 1993
- *
- * compile :
- *
- * Compile version : 0.1
- * Ext. Version : 0.1
- *
- * REVISION HISTORY
- *
- * Date Comment
- * ------------------------ -------------------------------------------------
- * Fri Sep 17 00:45:42 1993 Took from CED_Help, seems to work quite well
- *
- *-- REV_END --
- */
-
- /*
- * C++-Includes, C++-Definitionen
- *
- */
-
- #include "editfile.h"
-
-
- void editfile::_intern_editfile(BPTR fh)
- {
- index=0;
- mem=0;
- strings=0;
-
- goodflag=FALSE; /* not successful */
-
- if(size=GetFileSize(fh))
- {
- if(mem=(char *)AllocVec(size+1,MEMF_ANY))
- {
- LONG temp_len = Read(fh, mem,size);
-
- if(temp_len == size)
- {
- char *t=mem;
-
- *(t+size)=0; // Buffer Null-Terminieren
-
- // Alle 0x0a durch 0x00 ersetzen und dabei Anzahl merken
-
- for(strings=0 ; t< (mem+size); t++)
- {
-
- // im File war schon eine 0...
-
- if(!*t) { strings++; }
-
-
- // aus \n 0 machen...
-
- if(*t=='\n') { *t=0; strings++; }
-
- }
-
-
- // Speicher für Tabelle holen
-
- if(index=(char **)AllocVec((strings+1)*4,MEMF_ANY))
- {
-
- // Indextabelle erstellen...
-
- ULONG x;
-
- char *start=mem;
-
- for(x=0, t=mem; t < (mem+size); t++)
- {
- if(! (*t))
- {
- index[x]=start;
- start=t+1;
- x++;
- }
- }
-
- index[x]=0;
-
- goodflag=TRUE;
-
- // FreeVec in destructor
- }
- else
- {
- // out of memory
-
- err.DosError(ERROR_NO_FREE_STORE);
- }
-
- }
- else
- {
- // Read-Error
-
- err.NotifyError("read error occurred !");
- }
-
- // FreeVec in destructor
- }
- else
- {
- // no mem
-
- err.DosError(ERROR_NO_FREE_STORE);
- }
- }
- else
- {
- // no file-length
-
- err.DosError(ERROR_OBJECT_WRONG_TYPE);
- }
- }
-
-
-