Changeset 51daf97 in tol
- Timestamp:
- May 10, 2010, 9:53:24 AM (16 years ago)
- Branches:
- 1941-docker-image-to-test, devel, master
- Children:
- b86788c
- Parents:
- dd538db
- File:
-
- 1 edited
-
tol/btol/matrix_type/matgra.cpp (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
tol/btol/matrix_type/matgra.cpp
rdd538db r51daf97 210 210 BInt rows, cols, rows2w, cols2w; 211 211 FILE *fil; 212 213 /* check number of columns */ 214 if(!(fil = fopen(fileName.String(), "rb"))) { 215 BBM_BinWrite(fileName,M); 216 return; 217 } 218 212 BDir dir = fileName; 213 if(!dir.Exist()) 214 { 215 BBM_BinWrite(fileName, M); 216 return; 217 } 218 else if(dir.IsDir()) 219 { 220 Error(I2("Cannot open BBM file ", 221 "No se pudo abrir el fichero BBM ") + 222 fileName+I2(" due to it's a directory"," porque es un directorio")); 223 return; 224 } 225 226 /* open for overwrite */ 227 if(!(fil = fopen(fileName.String(), "r+b"))) { 228 Error(I2("Cannot open (rewrite mode) BBM file ", 229 "No se pudo abrir (modo de sobreescritura) el fichero BBM ") + 230 fileName); 231 return; 232 } 233 fpos_t pos = 0; 234 fsetpos(fil, &pos); 219 235 fread(&rows,sizeof(BInt),1,fil); 220 236 fread(&cols,sizeof(BInt),1,fil); … … 226 242 return; 227 243 } 228 fclose(fil); 229 230 /* open for overwrite */ 231 if(!(fil = fopen(fileName.String(), "r+b"))) { 232 Error(I2("Cannot open (rewrite mode) BBM file ", 233 "No se pudo abrir (modo de sobreescritura) el fichero BBM ") + 234 fileName); 235 return; 236 } 237 238 if(fseek(fil, 0L, SEEK_SET)) { 239 Error(I2("Cannot access BBM file ", "No se pudo acceder al fichero BBM ") + 240 fileName); 241 fclose(fil); 242 return; 243 } 244 pos = 0; 245 fsetpos(fil, &pos); 244 246 rows += rows2w; 245 247 fwrite(&rows, sizeof(BInt), 1, fil); 246 fclose(fil); 247 248 fflush(fil); 249 fclose(fil); 250 fil = NULL; 251 for(int tryNum = 0; !fil && (tryNum < 1000); tryNum++) 252 { 253 fil = fopen(fileName.String(), "ab"); 254 } 248 255 /* open for append */ 249 if(! (fil = fopen(fileName.String(), "ab"))) {256 if(!fil) { 250 257 Error(I2("Cannot open (append mode) BBM file ", 251 258 "No se pudo abrir (modo de insercion) el fichero BBM ") + … … 254 261 } 255 262 fwrite(M.Data().Buffer(), sizeof(BDat), rows2w*cols2w, fil); 263 fflush(fil); 256 264 if(fclose(fil)) 257 265 {
Note: See TracChangeset
for help on using the changeset viewer.
