cvsuser 04/10/08 09:13:30
Modified: . MANIFEST
config/gen/platform/generic stat.c
Added: config/gen/platform/win32 stat.c
Log:
[perl #31897] [PATCH] Win32 stat
Removes the #if defined(WIN32) in generic/stat.c, and adds a separate
implementation in win32/stat.c. The block stats stay implemented as
internal_exception.
Courtesy of Ron Blaschke <[EMAIL PROTECTED]>
Revision Changes Path
1.749 +1 -0 parrot/MANIFEST
Index: MANIFEST
===================================================================
RCS file: /cvs/public/parrot/MANIFEST,v
retrieving revision 1.748
retrieving revision 1.749
diff -u -w -r1.748 -r1.749
--- MANIFEST 8 Oct 2004 07:08:28 -0000 1.748
+++ MANIFEST 8 Oct 2004 16:13:27 -0000 1.749
@@ -241,6 +241,7 @@
config/gen/platform/win32/signal.c []
config/gen/platform/win32/signal.h []
config/gen/platform/win32/stat.h []
+config/gen/platform/win32/stat.c []
config/gen/platform/win32/time.c []
config/init/data.pl []
config/init/headers.pl []
1.1 parrot/config/gen/platform/win32/stat.c
Index: stat.c
===================================================================
/*
* File stat stuff
*/
PMC *
Parrot_stat_file(Parrot_Interp interpreter, STRING *filename)
{
return NULL;
}
PMC *
Parrot_stat_info_pmc(Parrot_Interp interpreter, STRING *filename, INTVAL thing)
{
return NULL;
}
INTVAL
Parrot_stat_info_intval(Parrot_Interp interpreter, STRING *file, INTVAL thing)
{
struct stat statbuf;
char *filename;
INTVAL result = -1;
int status;
/* Get the name of the file as something we can use */
filename = string_to_cstring(interpreter, file);
/* Everything needs the result of stat, so just go do it */
status = stat(filename, &statbuf);
switch (thing) {
case STAT_EXISTS:
result = (status == 0);
break;
case STAT_FILESIZE:
result = statbuf.st_size;
break;
case STAT_ISDIR:
result = S_ISDIR(statbuf.st_mode);
break;
case STAT_ISDEV:
result = S_ISCHR(statbuf.st_mode) || S_ISBLK(statbuf.st_mode);
break;
case STAT_CREATETIME:
result = -1;
break;
case STAT_ACCESSTIME:
result = statbuf.st_atime;
break;
case STAT_MODIFYTIME:
result = statbuf.st_mtime;
break;
case STAT_CHANGETIME:
result = statbuf.st_ctime;
break;
case STAT_BACKUPTIME:
result = -1;
break;
case STAT_UID:
result = statbuf.st_uid;
break;
case STAT_GID:
result = statbuf.st_gid;
break;
case STAT_PLATFORM_DEV:
result = statbuf.st_dev;
break;
case STAT_PLATFORM_INODE:
result = statbuf.st_ino;
break;
case STAT_PLATFORM_MODE:
result = statbuf.st_mode;
break;
case STAT_PLATFORM_NLINKS:
result = statbuf.st_nlink;
break;
case STAT_PLATFORM_DEVTYPE:
result = statbuf.st_rdev;
break;
case STAT_PLATFORM_BLOCKSIZE:
internal_exception(1, "STAT_PLATFORM_BLOCKSIZE not supported");
break;
case STAT_PLATFORM_BLOCKS:
internal_exception(1, "STAT_PLATFORM_BLOCKS not supported");
break;
}
string_cstring_free(filename);
return result;
}
INTVAL
Parrot_fstat_info_intval(Parrot_Interp interpreter, INTVAL file, INTVAL thing)
{
struct stat statbuf;
INTVAL result = -1;
int status;
/* Everything needs the result of stat, so just go do it */
status = fstat(file, &statbuf);
switch (thing) {
case STAT_EXISTS:
result = (status == 0);
break;
case STAT_FILESIZE:
result = statbuf.st_size;
break;
case STAT_ISDIR:
result = S_ISDIR(statbuf.st_mode);
break;
case STAT_ISDEV:
result = S_ISCHR(statbuf.st_mode) || S_ISBLK(statbuf.st_mode);
break;
case STAT_CREATETIME:
result = -1;
break;
case STAT_ACCESSTIME:
result = statbuf.st_atime;
break;
case STAT_MODIFYTIME:
result = statbuf.st_mtime;
break;
case STAT_CHANGETIME:
result = statbuf.st_ctime;
break;
case STAT_BACKUPTIME:
result = -1;
break;
case STAT_UID:
result = statbuf.st_uid;
break;
case STAT_GID:
result = statbuf.st_gid;
break;
case STAT_PLATFORM_DEV:
result = statbuf.st_dev;
break;
case STAT_PLATFORM_INODE:
result = statbuf.st_ino;
break;
case STAT_PLATFORM_MODE:
result = statbuf.st_mode;
break;
case STAT_PLATFORM_NLINKS:
result = statbuf.st_nlink;
break;
case STAT_PLATFORM_DEVTYPE:
result = statbuf.st_rdev;
break;
case STAT_PLATFORM_BLOCKSIZE:
internal_exception(1, "STAT_PLATFORM_BLOCKSIZE not supported");
break;
case STAT_PLATFORM_BLOCKS:
internal_exception(1, "STAT_PLATFORM_BLOCKS not supported");
break;
}
return result;
}
FLOATVAL
Parrot_stat_info_floatval(Parrot_Interp interpreter, STRING *filename, INTVAL thing)
{
return -1;
}
STRING *
Parrot_stat_info_string(Parrot_Interp interpreter, STRING *filename, INTVAL thing)
{
return NULL;
}
1.4 +0 -16 parrot/config/gen/platform/generic/stat.c
Index: stat.c
===================================================================
RCS file: /cvs/public/parrot/config/gen/platform/generic/stat.c,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -w -r1.3 -r1.4
--- stat.c 8 Oct 2004 09:45:03 -0000 1.3
+++ stat.c 8 Oct 2004 16:13:30 -0000 1.4
@@ -78,18 +78,10 @@
result = statbuf.st_rdev;
break;
case STAT_PLATFORM_BLOCKSIZE:
-#if defined(WIN32)
- internal_exception(1, "STAT_PLATFORM_BLOCKSIZE not implemented");
-#else
result = statbuf.st_blksize;
-#endif
break;
case STAT_PLATFORM_BLOCKS:
-#if defined(WIN32)
- internal_exception(1, "STAT_PLATFORM_BLOCKS not implemented");
-#else
result = statbuf.st_blocks;
-#endif
break;
}
@@ -157,18 +149,10 @@
result = statbuf.st_rdev;
break;
case STAT_PLATFORM_BLOCKSIZE:
-#if defined(WIN32)
- internal_exception(1, "STAT_PLATFORM_BLOCKSIZE not implemented");
-#else
result = statbuf.st_blksize;
-#endif
break;
case STAT_PLATFORM_BLOCKS:
-#if defined(WIN32)
- internal_exception(1, "STAT_PLATFORM_BLOCKS not implemented");
-#else
result = statbuf.st_blocks;
-#endif
break;
}