From cef844f0015cec463d43b754da2b3a238d0e4e17 Mon Sep 17 00:00:00 2001 From: Hans-Christoph Steiner Date: Tue, 13 Jun 2006 01:28:48 +0000 Subject: fixed error messages, they now output into Pd space svn path=/trunk/externals/hcs/; revision=5206 --- stat-help.pd | 126 +++++++++++++++++++++++++++++++++-------------------------- stat.c | 22 +++++------ 2 files changed, 81 insertions(+), 67 deletions(-) diff --git a/stat-help.pd b/stat-help.pd index b508018..5607db6 100644 --- a/stat-help.pd +++ b/stat-help.pd @@ -1,37 +1,34 @@ -#N canvas 59 135 710 533 10; -#X msg 114 53 bang; -#X text 156 53 run on current folder; -#X symbolatom 6 490 0 0 0 3 filename - -; -#X floatatom 29 385 0 0 0 3 file_mode - -; -#X floatatom 175 385 0 0 0 3 User_ID - -; -#X floatatom 271 385 0 0 0 3 Group_ID - -; -#X floatatom 338 385 0 0 0 3 Device_ID - -; -#X obj 5 107 print data; +#N canvas 139 93 642 522 10; +#X msg 108 68 bang; +#X text 150 68 run on current folder; +#X symbolatom 6 470 0 0 0 3 filename - -; +#X floatatom 29 365 0 0 0 3 file_mode - -; +#X floatatom 175 365 0 0 0 3 User_ID - -; +#X floatatom 271 365 0 0 0 3 Group_ID - -; +#X floatatom 338 365 0 0 0 3 Device_ID - -; #X obj 163 165 route error; #X symbolatom 163 201 0 0 0 0 error - -; -#X floatatom 419 385 0 0 0 3 File_Size - -; -#X floatatom 480 363 0 0 0 3 Blocks_Allocated - -; -#X floatatom 537 338 0 0 0 3 preferred_block_size - -; -#X obj 79 8 bng 15 250 50 0 empty empty empty 0 -6 0 8 -24198 -1 -1 +#X floatatom 419 386 0 0 0 3 File_Size - -; +#X floatatom 419 353 0 0 0 3 Blocks_Allocated - -; +#X floatatom 419 317 0 0 0 3 preferred_block_size - -; +#X obj 17 36 bng 15 250 50 0 empty empty empty 0 -6 0 8 -24198 -1 -1 ; -#X obj 79 26 openpanel; -#X text 151 16 try it on any file (it doesn't change anything \, just +#X obj 17 63 openpanel; +#X text 46 31 try it on any file (it doesn't change anything \, just reads data from the file system).; #X text 127 146 <-- set filename by cold inlet or object argument; -#X obj 270 425 gid->group_name; -#X symbolatom 270 454 0 0 0 3 group_name - -; +#X obj 270 405 gid->group_name; +#X symbolatom 270 434 0 0 0 3 group_name - -; #X obj 163 183 symbol; -#X msg 127 79 symbol /tmp/this_file_doesn't_exist; -#X text 244 186 errors are reported in Pd space; -#X floatatom 98 385 0 0 0 3 hard_links - -; -#X symbolatom 174 454 0 0 0 3 group_name - -; -#X obj 174 425 uid->username; +#X floatatom 98 365 0 0 0 3 hard_links - -; +#X symbolatom 174 434 0 0 0 3 group_name - -; +#X obj 174 405 uid->username; #X obj 91 147 stat; -#X obj 77 203 list; -#X obj 77 223 list split 9; +#X obj 9 203 list; +#X obj 9 223 list split 9; #X obj 9 282 unpack symbol float float float float float float float float; -#N canvas 0 22 458 308 time 0; +#N canvas 0 22 466 316 time 0; #X obj 136 34 inlet; #X floatatom 19 193 6 0 0 3 days - -; #X floatatom 66 193 6 0 0 3 seconds - -; @@ -50,33 +47,52 @@ float; #X connect 10 3 5 0; #X connect 10 4 7 0; #X connect 10 5 8 0; -#X restore 116 253 pd time stamps; -#X msg 138 103 symbol /usr/bin/gcc; -#X text 226 251 <-- open this to see the timestamps; -#X connect 0 0 25 0; -#X connect 4 0 24 0; -#X connect 5 0 17 0; -#X connect 8 0 19 0; -#X connect 13 0 14 0; -#X connect 14 0 25 0; -#X connect 17 0 18 0; -#X connect 19 0 9 0; -#X connect 20 0 25 0; -#X connect 24 0 23 0; -#X connect 25 0 7 0; -#X connect 25 0 26 0; -#X connect 25 0 28 0; -#X connect 25 1 8 0; -#X connect 26 0 27 0; -#X connect 27 0 28 0; -#X connect 27 1 29 0; -#X connect 28 0 2 0; -#X connect 28 1 3 0; -#X connect 28 2 22 0; -#X connect 28 3 4 0; -#X connect 28 4 5 0; -#X connect 28 5 6 0; -#X connect 28 6 10 0; -#X connect 28 7 11 0; -#X connect 28 8 12 0; -#X connect 30 0 25 0; +#X restore 48 253 pd time stamps; +#X msg 132 118 symbol /usr/bin/gcc; +#X text 158 251 <-- open this to see the timestamps; +#X obj 94 175 bng 15 250 50 0 empty empty empty 0 -6 0 8 -262144 -1 +-1; +#X msg 121 94 symbol /tmp/this_file_doesn't_exist; +#X text 249 181 <-- errors are reported in Pd space and the Pd window +; +#N canvas 0 22 458 308 possible 0; +#X text 47 62 access_denied; +#X text 47 82 io_error; +#X text 47 102 symlink_loop; +#X text 47 122 name_too_long; +#X text 47 142 does_not_exist; +#X text 47 162 not_folder; +#X text 47 182 internal_overflow; +#X text 47 202 internal_fault; +#X text 19 21 Here are the possible errors that [stat] will report +on its right outlet:; +#X text 47 222 invalid; +#X text 47 242 unknown; +#X restore 400 209 pd possible errors; +#X text 8 3 [stat] gets information about files; +#X connect 0 0 22 0; +#X connect 4 0 21 0; +#X connect 5 0 16 0; +#X connect 7 0 18 0; +#X connect 12 0 13 0; +#X connect 13 0 22 0; +#X connect 16 0 17 0; +#X connect 18 0 8 0; +#X connect 21 0 20 0; +#X connect 22 0 23 0; +#X connect 22 0 29 0; +#X connect 22 1 7 0; +#X connect 23 0 24 0; +#X connect 24 0 25 0; +#X connect 24 1 26 0; +#X connect 25 0 2 0; +#X connect 25 1 3 0; +#X connect 25 2 19 0; +#X connect 25 3 4 0; +#X connect 25 4 5 0; +#X connect 25 5 6 0; +#X connect 25 6 9 0; +#X connect 25 7 10 0; +#X connect 25 8 11 0; +#X connect 27 0 22 0; +#X connect 30 0 22 0; diff --git a/stat.c b/stat.c index 54452b1..06d9d15 100644 --- a/stat.c +++ b/stat.c @@ -38,7 +38,7 @@ #include #include -static char *version = "$Revision: 1.1 $"; +static char *version = "$Revision: 1.2 $"; t_int stat_instance_count; @@ -111,24 +111,24 @@ static void reset_output(t_stat *x) * IMPLEMENTATION */ -static void stat_output_error(t_stat *x, int error_number) +static void stat_output_error(t_stat *x) { t_atom output_atoms[2]; - switch(error_number) + switch(errno) { case EACCES: error("[stat]: access denied: %s", x->x_filename->s_name); - SETSYMBOL(output_atoms, gensym("access")); + SETSYMBOL(output_atoms, gensym("access_denied")); break; case EIO: error("[stat]: An error occured while reading %s", x->x_filename->s_name); - SETSYMBOL(output_atoms, gensym("io")); + SETSYMBOL(output_atoms, gensym("io_error")); break; case ELOOP: error("[stat]: A loop exists in symbolic links in %s", x->x_filename->s_name); - SETSYMBOL(output_atoms, gensym("loop")); + SETSYMBOL(output_atoms, gensym("symlink_loop")); break; case ENAMETOOLONG: error("[stat]: The filename %s is too long", @@ -147,11 +147,11 @@ static void stat_output_error(t_stat *x, int error_number) case EOVERFLOW: error("[stat]: %s caused overflow in stat struct", x->x_filename->s_name); - SETSYMBOL(output_atoms, gensym("overflow")); + SETSYMBOL(output_atoms, gensym("internal_overflow")); break; case EFAULT: error("[stat]: fault in stat struct (%s)", x->x_filename->s_name); - SETSYMBOL(output_atoms, gensym("fault")); + SETSYMBOL(output_atoms, gensym("internal_fault")); break; case EINVAL: error("[stat]: invalid argument to stat() (%s)", @@ -159,8 +159,7 @@ static void stat_output_error(t_stat *x, int error_number) SETSYMBOL(output_atoms, gensym("invalid")); break; default: - error("[stat]: unknown error %d: %s", - error_number, x->x_filename->s_name); + error("[stat]: unknown error %d: %s", errno, x->x_filename->s_name); SETSYMBOL(output_atoms, gensym("unknown")); } SETSYMBOL(output_atoms + 2, x->x_filename); @@ -180,12 +179,11 @@ static void stat_output(t_stat* x) #endif /* _WIN32 */ if(result != 0) { - stat_output_error(x, result); + stat_output_error(x); } else { reset_output(x); - post(""); add_float_to_output(x, (t_float) stat_buffer.st_mode); add_float_to_output(x, (t_float) stat_buffer.st_nlink); add_float_to_output(x, (t_float) stat_buffer.st_uid); -- cgit v1.2.1