src/sgp/FileMan.cc
/** Convert file descriptor to HWFile.
 * Raise runtime_error if not possible. */
Convert file descriptor to HWFile.
Raise runtime_error if not possible.
Convert file descriptor to HWFile . Raise runtime_error if not possible .
SGPFile* FileMan::getSGPFileFromFD(int fd, const char *filename, const char *fmode)
{
	if (fd < 0)
	{
		char buf[128];
		snprintf(buf, sizeof(buf), "Opening file '%s' failed", filename);
		throw std::runtime_error(buf);
	}
	FILE* const f = fdopen(fd, fmode);
	if (!f)
	{
		char buf[128];
		snprintf(buf, sizeof(buf), "Opening file '%s' failed", filename);
		throw std::runtime_error(buf);
	}
	SGPFile *file = MALLOCZ(SGPFile);
	file->flags  = SGPFILE_REAL;
	file->u.file = f;
	return file;
}
SGPFile * FileMan :: getSGPFileFromFD ( int fd , const char * filename , const char * fmode ) { if ( fd < 0 ) { char buf [ 128 ] ; snprintf ( buf , sizeof ( buf ) , " " , filename ) ; throw std :: runtime_error ( buf ) ; } FILE * const f = fdopen ( fd , fmode ) ; if ( ! f ) { char buf [ 128 ] ; snprintf ( buf , sizeof ( buf ) , " " , filename ) ; throw std :: runtime_error ( buf ) ; } SGPFile * file = MALLOCZ ( SGPFile ) ; file -> flags = SGPFILE_REAL ; file -> u . file = f ; return file ; }
Convert file descriptor to HWFile.
Convert file descriptor to HWFile .