--- Vladimir Lipsky <[EMAIL PROTECTED]> wrote:
> From: "Goplat" <[EMAIL PROTECTED]>
>
> > flags_to_win32 sets fdwShareMode to FILE_SHARE_DELETE, which is not
> > supported in win98
>
> A fix for that should be windows version specific and needs support of the
> config subsystem.
If you did that, a version compiled on NT wouldn't work on 9x. I'd say most
9x users don't compile perl themself, they just download a binary from
ActiveState (who use NT)...
If you really need FILE_SHARE_DELETE that badly, the check would have to be
done at runtime. I don't think it's all that necessary though... in fact perl
5 only uses FILE_SHARE_READ, and that only if the file's not opened for write/append.
__________________________________
Do you Yahoo!?
Yahoo! Finance: Get your refund fast by filing online.
http://taxes.yahoo.com/filing.html
--- io_win32.c~ Wed Feb 4 07:46:48 2004
+++ io_win32.c Tue Feb 17 08:21:16 2004
@@ -84,6 +84,20 @@
flags_to_win32(INTVAL flags, DWORD * fdwAccess,
DWORD * fdwShareMode, DWORD * fdwCreate)
{
+ static DWORD dwDefaultShareMode;
+ if (!dwDefaultShareMode) {
+ OSVERSIONINFO osvi;
+ osvi.dwOSVersionInfoSize = sizeof(osvi);
+ GetVersionEx(&osvi);
+ if (osvi.dwPlatformId == VER_PLATFORM_WIN32_WINDOWS) {
+ dwDefaultShareMode = FILE_SHARE_READ | FILE_SHARE_WRITE;
+ }
+ else {
+ dwDefaultShareMode =
+ FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE;
+ }
+ }
+
if ((flags & (PIO_F_WRITE | PIO_F_READ)) == (PIO_F_WRITE | PIO_F_READ)) {
*fdwAccess = GENERIC_WRITE | GENERIC_READ;
if (flags & PIO_F_TRUNC)
@@ -103,7 +117,7 @@
*fdwCreate = OPEN_EXISTING;
}
- *fdwShareMode = FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE;
+ *fdwShareMode = dwDefaultShareMode;
if (flags & PIO_F_APPEND) {
/* dealt with specially in _write and _puts */
}
--- io.t~ Mon Feb 9 01:10:46 2004
+++ io.t Mon Feb 16 11:00:26 2004
@@ -11,6 +11,7 @@
my $content = @_ ? shift : "This is a test\n";
open(FILE, ">$name") or die "Failed to create $name";
+ binmode FILE;
print FILE $content;
close(FILE);
@@ -69,7 +70,7 @@
the_test(struct Parrot_Interp *interpreter,
opcode_t *cur_op, opcode_t *start)
{
- ParrotIO *io;
+ PMC *io;
char *p;
io = PIO_STDOUT(interpreter);
@@ -100,15 +101,15 @@
the_test(struct Parrot_Interp *interpreter,
opcode_t *cur_op, opcode_t *start)
{
- ParrotIO *io;
+ PMC *io;
char buf[1024];
- UINTVAL len;
+ INTVAL len;
io = PIO_open(interpreter, NULL, "temp.file", "<");
len = PIO_read(interpreter, io, buf, sizeof(buf)-1);
PIO_close(interpreter, io);
- buf[len] = '\0';
+ buf[len < 0 ? 0 : len] = '\0';
PIO_printf(interpreter, "%s", buf);
io = PIO_open(interpreter, NULL, "temp.file", "<");
@@ -117,8 +118,8 @@
do {
len = PIO_read(interpreter, io, buf, 3);
- buf[len] = '\0';
- /* dont write trailing spaces */
+ buf[len < 0 ? 0 : len] = '\0';
+ /* don't write trailing spaces */
PIO_printf(interpreter, "%d: %s\n", len, len ? buf : "EOF");
} while (len > 0);
@@ -142,7 +143,7 @@
the_test(struct Parrot_Interp *interpreter,
opcode_t *cur_op, opcode_t *start)
{
- ParrotIO *io;
+ PMC *io;
io = PIO_open(interpreter, NULL, "temp.file", ">>");
PIO_write(interpreter, io, "Parrot flies.\n", 14);
@@ -166,8 +167,8 @@
the_test(struct Parrot_Interp *interpreter,
opcode_t *cur_op, opcode_t *start)
{
- ParrotIO *io;
- size_t len;
+ PMC *io;
+ INTVAL len;
char buf[1024];
io = PIO_open(interpreter, NULL, "temp.file", "<");
@@ -175,7 +176,7 @@
do {
len = PIO_read(interpreter, io, buf, sizeof(buf)-1);
- buf[len] = '\0';
+ buf[len < 0 ? 0 : len] = '\0';
PIO_printf(interpreter, "%d: %s", len, len ? buf : "EOF");
} while (len > 0);