Re: glib outstanding stuff



On Wed, Oct 04, 2000 at 11:26:41PM -0400, Havoc Pennington wrote:
> > 	Oh, yeah, forgot about that case.  I have a load_file_fd()
> > function that handles those cases, and dynamic buffering is used.  I
> > still think that the overhead of stdio is not needed.
> 
> What is the trigger for the fallback? 
> 
> I'm not sure I want to write:
>  if is_fifo() || is_proc() || is_socket():
>    blah;
> 
> since we could omit a case on some platform. Is there another
> (portable) way to tell (does stat return a size of 0 here?)

	I don't dynamically type it.  I basically assume what kind of
file I'm going to have, and run the proper one on it.  This isn't
perfect, of course.  Even load_file_fd() will fail if the file is something
that never sends EOF.
	If you wanted to test, I'd say you already have the struct stat,
why not just check S_ISREG() or so.  If S_ISREG() && stat_buf.size > 0,
use the slurp method, otherwise the dynamically buffered one.  Note that
this still isn't perfect in the FIFO case, as I've seen the
open()/fstat() bit hang on a FIFO, and if you stat() then open() you of
course race.


Joel

-- 

"Always give your best, never get discouraged, never be petty; always
 remember, others may hate you.  Those who hate you don't win unless
 you hate them.  And then you destroy yourself."
	- Richard M. Nixon

			http://www.jlbec.org/
			jlbec evilplan org




[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]