Riportate modifiche dalla R9702 per quanto riguarda l'apertura di
files senza indice, utile per scaricare un file con indice danneggiato. Tolta fatal_box() nel caso si tenti di scrivere una stringa piu' lunga del campo: ora tronca i valori alfanumerici alla lunghezza massima, mentre quelli numerici vengono azzerati. git-svn-id: svn://10.65.10.50/trunk@5389 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
		
							parent
							
								
									f77367a05d
								
							
						
					
					
						commit
						569760adf1
					
				| @ -199,11 +199,7 @@ void  __putfieldbuff(byte l, byte d, byte t, const char* s, char* recout) | ||||
| 
 | ||||
|   len = strlen(s); | ||||
|    | ||||
|   if (len > l)  | ||||
|   { | ||||
|     yesnofatal_box("Impossibile scrivere %d caratteri su di un campo di %d", (int)len, (int)l); | ||||
|     return; | ||||
|   }   | ||||
|   const bool exceeded = len > l; | ||||
| 
 | ||||
|   if ((t == _intfld)     || | ||||
|       (t == _longfld)    || | ||||
| @ -213,7 +209,7 @@ void  __putfieldbuff(byte l, byte d, byte t, const char* s, char* recout) | ||||
|       (t == _longzerofld) | ||||
|       ) | ||||
|   { | ||||
|     if (len == 0) | ||||
|     if (len == 0 || exceeded) | ||||
|     { | ||||
|       strcpy(s2, "0"); | ||||
|       s = s2; | ||||
| @ -226,6 +222,8 @@ void  __putfieldbuff(byte l, byte d, byte t, const char* s, char* recout) | ||||
|   } | ||||
|   else | ||||
|   { | ||||
|     if (exceeded) | ||||
|       len = l; | ||||
|     strncpy(recout, s, len) ; | ||||
|     for  (i = l - 1; i >= len; i--) recout[i] = ' '; | ||||
|   } | ||||
| @ -1292,19 +1290,24 @@ void TBaseisamfile::indexoff() | ||||
| // @rdesc Ritorna NOERR se e' riuscita ad aprire il file, altrimenti ritorna il numero di errore
 | ||||
| //    generato (vedi <t TIsamerr>).
 | ||||
| int TBaseisamfile::_open( | ||||
|     unsigned int mode) // @parm Indica il modo di apertura del file (default _manulock)
 | ||||
|     unsigned int mode,  // @parm Indica il modo di apertura del file (default _manulock)
 | ||||
|     bool index)         // @parm Indica se aprire con indici o meno  (default TRUE)
 | ||||
| 
 | ||||
| // @comm Il parametro <p mode> puo' assumere i valori:
 | ||||
| //
 | ||||
| // @flag _manulock | Il lock dei record viene fatto manualmente
 | ||||
| // @flag _exclock | Il file viene aperte in modo esclusivo
 | ||||
| // @flag _autolock | Il lock dei record viene fatto in modo automatico
 | ||||
| // @comm Il parametro <p index> puo' assumere i valori:
 | ||||
| //
 | ||||
| // @flag TRUE  | Il file viene aperto con indici
 | ||||
| // @flag FALSE | Il file viene aperto senza indici
 | ||||
|    | ||||
| { | ||||
|   CHECKS(filehnd() == NULL, "File already open ", (const char*)filename()); | ||||
|    | ||||
|   getisfd(_isamfile,num());  | ||||
|   if ((filehnd()->fhnd = DB_open(filehnd()->d->SysName,mode==_excllock)) >= 0) | ||||
|   if ((filehnd()->fhnd = DB_open(filehnd()->d->SysName,mode==_excllock,index)) >= 0) | ||||
|   {                        | ||||
|     TRecnotype n=DB_reccount(filehnd()->fhnd); | ||||
|     TDir d; | ||||
| @ -1398,7 +1401,7 @@ int TBaseisamfile::is_valid() | ||||
|   CHECKS(filehnd() == NULL, "File already open ", (const char*)filename()); | ||||
|   int err = NOERR; | ||||
|   getisfd(_isamfile,num());  | ||||
|   if ((filehnd()->fhnd = DB_open(filehnd()->d->SysName,0)) >= 0) | ||||
|   if ((filehnd()->fhnd = DB_open(filehnd()->d->SysName,0,TRUE)) >= 0) | ||||
|   { | ||||
|     if (DB_tagget(filehnd()->fhnd) == -1) err = _ispatherr; | ||||
|     DB_close(filehnd()->fhnd); | ||||
| @ -1509,7 +1512,7 @@ int TLocalisamfile::open(unsigned int mode) | ||||
|   } | ||||
|   else | ||||
|   { | ||||
|     err = _open(); | ||||
|     err = _open(mode, TRUE); | ||||
|     _was_open = TRUE; | ||||
|   } | ||||
| 
 | ||||
| @ -1689,7 +1692,7 @@ int TIsamtempfile::open( | ||||
|   } | ||||
|   else | ||||
|     filehnd()->d->EOD = eod; | ||||
|   filehnd()->fhnd = DB_open(filehnd()->d->SysName, 0); | ||||
|   filehnd()->fhnd = DB_open(filehnd()->d->SysName, 0, TRUE); | ||||
|   if (filehnd()->fhnd < 0)  | ||||
|     err = get_error(filehnd()->fhnd); | ||||
|   if (err != NOERR) | ||||
| @ -1765,7 +1768,7 @@ int TIsamtempfile::close() | ||||
| ///////////////////////////////////////////////////////////
 | ||||
| // TExternisamfile
 | ||||
| ///////////////////////////////////////////////////////////
 | ||||
| TExternisamfile::TExternisamfile(const char* name, bool exclusive) | ||||
| TExternisamfile::TExternisamfile(const char* name, bool exclusive, bool index) | ||||
| : TLocalisamfile(name)  | ||||
| { | ||||
|   _name = name; | ||||
| @ -1780,7 +1783,7 @@ TExternisamfile::TExternisamfile(const char* name, bool exclusive) | ||||
|       _name.ltrim(1); | ||||
|       _name.format("%s/%s",__ptprf,(const char*)_name); | ||||
|     } | ||||
|   open(exclusive);                              | ||||
|   open(exclusive, index);                              | ||||
| } | ||||
| 
 | ||||
| TExternisamfile::~TExternisamfile() | ||||
| @ -1788,11 +1791,11 @@ TExternisamfile::~TExternisamfile() | ||||
|   close(); | ||||
| } | ||||
| 
 | ||||
| int TExternisamfile::open(bool exclusive) | ||||
| int TExternisamfile::open(bool exclusive, bool index) | ||||
| { | ||||
|   int err=NOERR; | ||||
|    | ||||
|   filehnd()->fhnd = DB_open(_name, exclusive); | ||||
|   filehnd()->fhnd = DB_open(_name, exclusive, index); | ||||
|   if (filehnd()->fhnd < 0)  | ||||
|     err = get_error(filehnd()->fhnd); | ||||
|   if (err != NOERR) | ||||
| @ -2099,7 +2102,7 @@ int TSystemisamfile::update( | ||||
|         err=get_error(err); | ||||
|         return (err); | ||||
|       } | ||||
|       i0->fhnd=DB_open((const char*)tmpfname,0); | ||||
|       i0->fhnd=DB_open((const char*)tmpfname,0, TRUE); | ||||
|       if (i0->fhnd < 0 ) err=get_error(i0->fhnd); | ||||
|       TFilename fname(filename()); | ||||
|       TString s(80); | ||||
| @ -2492,7 +2495,7 @@ int TSystemisamfile::dump( | ||||
|   if (withdeleted) nkey = 0; | ||||
|   int err = ferror(f); | ||||
|    | ||||
|   open(); | ||||
|   open(FALSE, nkey ? TRUE : FALSE); | ||||
|   TString s(512); | ||||
|   bool fixedlen = (fs == '\0'); | ||||
|   int nflds = curr().items(); | ||||
|  | ||||
| @ -339,8 +339,8 @@ protected: | ||||
|    | ||||
|   // @cmember UNUSED
 | ||||
|   void recover(); | ||||
|   // @cmember Apre il file isam di base con lock
 | ||||
|   int _open(unsigned int mode = _manulock); | ||||
|   // @cmember Apre il file isam di base con lock, permettendo di specificare se usare gli indici o no
 | ||||
|   int _open(unsigned int mode = _manulock, bool index = TRUE); | ||||
|   // @cmember Chiude il file isam di base
 | ||||
|   int _close();         | ||||
| 
 | ||||
| @ -564,8 +564,8 @@ public: | ||||
|   // @cmember Aggiorna i flags associati al file
 | ||||
|   int flags(bool updateeod = FALSE); | ||||
|   // @cmember Apre un file di isam con lock (vedi <mf TBaseisamfile::_open>)
 | ||||
|   int open(unsigned int mode = _manulock)  | ||||
|   { return _open(mode);}  | ||||
|   int open(unsigned int mode = _manulock, bool index = TRUE)  | ||||
|   { return _open(mode, index);}  | ||||
|   // @cmember Chiude il file di isam
 | ||||
|   int close()  | ||||
|   { return _close();} | ||||
| @ -734,7 +734,7 @@ class TExternisamfile : public TLocalisamfile | ||||
| // @access Protected Member  
 | ||||
| protected: | ||||
|   // @cmember Apre il file. <p exclusive> indica se aprire il file in modo esclusivo
 | ||||
|   int open(bool exclusive); | ||||
|   int open(bool exclusive, bool index = TRUE); | ||||
|   // @cmember Chiude il file
 | ||||
|   int close();  | ||||
| 
 | ||||
| @ -743,7 +743,8 @@ public: | ||||
|   // @cmember Ritorna il nome del file sotto forma di stringa
 | ||||
|   virtual const char* name() const; | ||||
|   // @cmember Costruttore. <p exclusive> indica se aprire il file in modo esclusivo.
 | ||||
|   TExternisamfile(const char* name, bool exclusive = FALSE); | ||||
|   //                       <p index> indica se aprire il file con indici o meno
 | ||||
|   TExternisamfile(const char* name, bool exclusive = FALSE, bool index = TRUE); | ||||
|   // @cmember Distruttore
 | ||||
|   virtual ~TExternisamfile(); | ||||
| }; | ||||
|  | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user