aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--stat-help.pd196
-rw-r--r--stat.c25
-rw-r--r--uname.c13
-rw-r--r--usbhid.c4
4 files changed, 129 insertions, 109 deletions
diff --git a/stat-help.pd b/stat-help.pd
index 5607db6..a0d6df2 100644
--- a/stat-help.pd
+++ b/stat-help.pd
@@ -1,98 +1,98 @@
-#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 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 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 405 gid->group_name;
-#X symbolatom 270 434 0 0 0 3 group_name - -;
-#X obj 163 183 symbol;
-#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 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 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 - -;
-#X text 26 223 last access;
-#X floatatom 158 192 6 0 0 3 days - -;
-#X floatatom 205 192 6 0 0 3 seconds - -;
-#X text 144 220 last modification;
-#X floatatom 305 194 6 0 0 3 days - -;
-#X floatatom 352 194 6 0 0 3 seconds - -;
-#X text 290 222 last status change;
-#X obj 49 137 unpack float float float float float float;
-#X connect 0 0 10 0;
-#X connect 10 0 1 0;
-#X connect 10 1 2 0;
-#X connect 10 2 4 0;
-#X connect 10 3 5 0;
-#X connect 10 4 7 0;
-#X connect 10 5 8 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;
+#N canvas 291 47 646 526 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 175 route error;
+#X symbolatom 163 213 0 0 0 0 error - -;
+#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 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 117 146 <-- set filename by cold inlet or object argument;
+#X obj 270 405 gid->group_name;
+#X symbolatom 270 434 0 0 0 3 group_name - -;
+#X obj 163 194 symbol;
+#X floatatom 98 365 0 0 0 3 hard_links - -;
+#X symbolatom 174 434 0 0 0 3 username - -;
+#X obj 174 405 uid->username;
+#X obj 81 147 stat;
+#X obj 9 203 list;
+#X obj 9 223 list split 9;
+#X obj 9 285 unpack symbol float float float float float float float
+float;
+#N canvas 0 22 470 320 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 - -;
+#X text 26 223 last access;
+#X floatatom 158 192 6 0 0 3 days - -;
+#X floatatom 205 192 6 0 0 3 seconds - -;
+#X text 144 220 last modification;
+#X floatatom 305 194 6 0 0 3 days - -;
+#X floatatom 352 194 6 0 0 3 seconds - -;
+#X text 290 222 last status change;
+#X obj 49 137 unpack float float float float float float;
+#X connect 0 0 10 0;
+#X connect 10 0 1 0;
+#X connect 10 1 2 0;
+#X connect 10 2 4 0;
+#X connect 10 3 5 0;
+#X connect 10 4 7 0;
+#X connect 10 5 8 0;
+#X restore 48 253 pd time stamps;
+#X msg 132 118 symbol /usr/bin/gcc;
+#X text 139 251 <-- open this to see the timestamps;
+#X obj 84 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 191 <-- 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 398 218 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 8d51443..c40eb27 100644
--- a/stat.c
+++ b/stat.c
@@ -36,9 +36,9 @@
#include <string.h>
#include <sys/types.h>
#include <sys/stat.h>
-#include <sys/errno.h>
+#include <errno.h>
-static char *version = "$Revision: 1.3 $";
+static char *version = "$Revision: 1.4 $";
t_int stat_instance_count;
@@ -50,7 +50,11 @@ t_int stat_instance_count;
*/
static t_class *stat_class;
+#ifdef _WIN32
+typedef struct _stat_win {
+#else
typedef struct _stat {
+#endif /* _WIN32 */
t_object x_obj;
t_symbol *x_filename;
/* output */
@@ -125,11 +129,13 @@ static void stat_output_error(t_stat *x)
x->x_filename->s_name);
SETSYMBOL(output_atoms, gensym("io_error"));
break;
+#ifndef _WIN32
case ELOOP:
error("[stat]: A loop exists in symbolic links in %s",
x->x_filename->s_name);
SETSYMBOL(output_atoms, gensym("symlink_loop"));
break;
+#endif
case ENAMETOOLONG:
error("[stat]: The filename %s is too long",
x->x_filename->s_name);
@@ -144,11 +150,13 @@ static void stat_output_error(t_stat *x)
x->x_filename->s_name);
SETSYMBOL(output_atoms, gensym("not_folder"));
break;
+#ifndef _WIN32
case EOVERFLOW:
error("[stat]: %s caused overflow in stat struct",
x->x_filename->s_name);
SETSYMBOL(output_atoms, gensym("internal_overflow"));
break;
+#endif
case EFAULT:
error("[stat]: fault in stat struct (%s)", x->x_filename->s_name);
SETSYMBOL(output_atoms, gensym("internal_fault"));
@@ -169,11 +177,15 @@ static void stat_output_error(t_stat *x)
static void stat_output(t_stat* x)
{
DEBUG(post("stat_output"););
+#ifdef _WIN32
+ struct _stat stat_buffer;
+#else
struct stat stat_buffer;
+#endif
int result;
#ifdef _WIN32
- result = _stat(x->x_filename, &stat_buffer);
+ result = _stat(x->x_filename->s_name, &stat_buffer);
#else
result = stat(x->x_filename->s_name, &stat_buffer);
#endif /* _WIN32 */
@@ -190,10 +202,15 @@ static void stat_output(t_stat* x)
add_float_to_output(x, (t_float) stat_buffer.st_gid);
add_float_to_output(x, (t_float) stat_buffer.st_rdev);
add_float_to_output(x, (t_float) stat_buffer.st_size);
+#ifdef _WIN32
+ add_float_to_output(x, (t_float) 0);
+ add_float_to_output(x, (t_float) 0);
+#else
add_float_to_output(x, (t_float) stat_buffer.st_blocks);
add_float_to_output(x, (t_float) stat_buffer.st_blksize);
+#endif
/* 86400 seconds == 24 hours == 1 day */
-#ifdef _POSIX_C_SOURCE
+#if defined(_POSIX_C_SOURCE) || defined(_WIN32)
add_float_to_output(x, (t_float) (stat_buffer.st_atime / 86400));
add_float_to_output(x, (t_float) (stat_buffer.st_atime % 86400));
add_float_to_output(x, (t_float) (stat_buffer.st_mtime / 86400));
diff --git a/uname.c b/uname.c
index 52a50b3..09b3854 100644
--- a/uname.c
+++ b/uname.c
@@ -23,18 +23,15 @@
/* */
/* --------------------------------------------------------------------------*/
+/* sadly, there is no uname in Windows, Cygwin has it tho */
+#ifndef _WIN32
+
#include <m_pd.h>
-#ifdef _WIN32
-#define _WIN32_WINNT 0x0400
-#include <windows.h>
-#include <stdio.h>
-#else
#include <sys/utsname.h>
#include <stdlib.h>
-#endif
-static char *version = "$Revision: 1.1 $";
+static char *version = "$Revision: 1.2 $";
t_int uname_instance_count;
@@ -114,3 +111,5 @@ void uname_setup(void)
}
+
+#endif /* NOT _WIN32 */
diff --git a/usbhid.c b/usbhid.c
index c129000..5fc069f 100644
--- a/usbhid.c
+++ b/usbhid.c
@@ -23,6 +23,9 @@
/* */
/* --------------------------------------------------------------------------*/
+/* libhid hasn't been ported to Win32 yet */
+#ifndef _WIN32
+
#include <usb.h>
#include <hid.h>
#include <stdio.h>
@@ -776,3 +779,4 @@ void usbhid_setup(void)
class_addmethod(usbhid_class,(t_method) usbhid_close,gensym("close"),0);
}
+#endif /* NOT _WIN32 */