buffer.Clear();
while (!IsEnd() && (ccount < rsize)) {
- fread(&c, sizeof(char),1, myStream);
+ ccount += fread(&c, sizeof(char),1, myStream);
buffer += c;
- ccount++;
}
}
Standard_Boolean header = Standard_False;
for(;;) {
ligne[0] = '\0';
- fgets(ligne,200,lefic);
- if (feof(lefic)) break;
+ if (fgets(ligne,200,lefic) == NULL
+ || feof(lefic) != 0)
+ {
+ break;
+ }
if (ligne[0] == '\0') continue;
// D abord ligne initiale ?
if (!header)
char ligne[100];
if (!lefic) std::cout << theprompt.ToCString();
ligne[0] = '\0';
- fgets(ligne,100,fic);
- if (feof(fic)) break;
+ if (fgets(ligne,100,fic) == NULL
+ || feof(fic) != 0)
+ {
+ break;
+ }
if (ligne[0] == '\0') continue;
// On interprete cette commande
TCollection_AsciiString command(ligne);
ligne[0] = '\0';
if(modefnes)
- fgets(ligne,99,lefic); /*for kept compatibility with fnes*/
+ {
+ if (fgets(ligne,99,lefic) == NULL) /*for kept compatibility with fnes*/
+ return 0;
+ }
else
{
/* PTV: 21.03.2002 it is neccessary for files that have only `\r` but no `\n`
{
}
- fgets(&ligne[1],80,lefic);
+ if (fgets(&ligne[1],80,lefic) == NULL)
+ return 0;
}
if (*numsec == 0 && ligne[72] != 'S' && ligne[79] == ' ')
ligne[0] = '\0';
if(modefnes)
- fgets(ligne,99,lefic);/*for kept compatibility with fnes*/
+ {
+ if (fgets(ligne,99,lefic) == NULL) /*for kept compatibility with fnes*/
+ return 0;
+ }
else
{
while ( fgets ( ligne, 2, lefic ) && ( ligne[0] == '\r' || ligne[0] == '\n' ) )
{
}
- fgets(&ligne[1],80,lefic);
+ if (fgets(&ligne[1],80,lefic) == NULL)
+ return 0;
}
}
else
sprintf(buffer,"lpr -P%s %s",PrinterName.ToCString(),aBuffer.ToCString());
- system(buffer);
+ if (system(buffer) != 0)
+ Standard_ProgramError::Raise("OSD_File::Print : No output device was available, or an error occurred");
}
}
-void OSD_Process::Spawn (const TCollection_AsciiString& cmd,
+Standard_Integer OSD_Process::Spawn (const TCollection_AsciiString& cmd,
const Standard_Boolean /*ShowWindow*/)
{
- system(cmd.ToCString());
+ return system(cmd.ToCString());
}
} // end constructor
-void OSD_Process :: Spawn ( const TCollection_AsciiString& cmd ,
+
+Standard_Integer OSD_Process::Spawn (const TCollection_AsciiString& cmd,
const Standard_Boolean ShowWindow /* = Standard_True */) {
STARTUPINFO si;
PROCESS_INFORMATION pi;
+ DWORD aRes = 0;
ZeroMemory ( &si, sizeof ( STARTUPINFO ) );
if (!CreateProcess (
NULL, (char *)cmd.ToCString (), NULL, NULL, TRUE, CREATE_NEW_CONSOLE, NULL, NULL, &si, &pi
)
- )
+ ) {
_osd_wnt_set_error ( myError, OSD_WProcess );
-
+ aRes = myError.Error();
+ }
else {
CloseHandle ( pi.hThread );
WaitForSingleObject ( pi.hProcess, INFINITE );
-
+ GetExitCodeProcess (pi.hProcess, &aRes);
CloseHandle ( pi.hProcess );
} // end else
+ return aRes;
} // end OSD_Process :: Spawn
void OSD_Process :: TerminalType ( TCollection_AsciiString& Name ) {
//! Issues a shell command
//! ShowWindow : flag to allow show/hide of the window ( only used on WNT )
- Standard_EXPORT void Spawn (const TCollection_AsciiString& cmd, const Standard_Boolean ShowWindow = Standard_True);
+ Standard_EXPORT Standard_Integer Spawn (const TCollection_AsciiString& cmd, const Standard_Boolean ShowWindow = Standard_True);
//! Returns the terminal used (vt100, vt200 ,sun-cmd ...)
Standard_EXPORT void TerminalType (TCollection_AsciiString& Name);
gp_XYZ aN (Atof(x), Atof(y), Atof(z));
// skip the keywords "outer loop"
- fscanf(file,"%*s %*s");
+ if (fscanf(file,"%*s %*s") < 0)
+ break;
// reading vertex
if (3 != fscanf(file,"%*s %80s %80s %80s\n", x, y, z))
ReadMesh->AddTriangle (i1, i2, i3, aN.X(), aN.Y(), aN.Z());
// skip the keywords "endloop"
- fscanf(file,"%*s");
+ if (fscanf(file,"%*s") < 0)
+ break;
// skip the keywords "endfacet"
- fscanf(file,"%*s");
+ if (fscanf(file,"%*s") < 0)
+ break;
// update progress only per 1k triangles
if (++iTri % IND_THRESHOLD == 0)