Posted to tcl by lm at Thu Oct 18 22:50:20 GMT 2007view raw

  1. FILE
  2. fopen(string path, string mode)
  3. {
  4. FILE f;
  5. int v = 0;
  6.  
  7. /* new mode, v, means be verbose w/ errors */
  8. if (mode =~ /v/) {
  9. mode =~ s/v//;
  10. v = 1;
  11. }
  12. if (catch("set f [open {${path}} ${mode}]", &err)) {
  13. stdio_lasterr = err;
  14. if (v) fprintf(stderr, "fopen(%s, %s) = %s\n", path, mode, err);
  15. return (0);
  16. } else {
  17. return (f);
  18. }
  19. }
  20.