Skip out to lunch on files ?
[1/7] from: andy:flyingcat at: 3-Oct-2002 12:15
Hi: Is it my imagination, or is skip (both as a command and as a refinement) completely out to lunch when used on files ? I was trying to use rebol to stream a file across a network; and the two obvious methods didn't seem to work. The presense or absence of the binary and direct refinements doesn't seem to make a difference. file: open/binary/skip %testfile.mpg 1000 print to-string copy/part file 100 Always gives me the first 100 bytes of the file. There doesn't seem to be a difference in using read, either, ie data: read/binary/skip/part %testfile.mpg 1000 100 Always gives me the first 100 bytes of data --- Using SKIP as a command didn't work all that much better. (the example in the new FAQ basically hangs, using up 100% of the CPU) This is on both 188.8.131.52.2 and 184.108.40.206.2. If this is known, is there a good work around ? Andy
[2/7] from: gscottjones:mchsi at: 3-Oct-2002 12:02
Hi, Andy, From: "Andy Finkel"
> Is it my imagination, or is skip (both as a command and > as a refinement) completely out to lunch when used on files ?
In the context of a refinement, it has been known to flake out, especially in regard to also using /direct. You will find differences of opinions on the best work-around, but for getting an unbuffered binary file, the way that I use works as follows: port: open/direct/binary %//rebol/view/nyc.jpg copy/part p 100 ;throws away the first 100 bytes contents: copy p ;get rest of file close port The skip-as-a-refinement-bug has likely been reported to feedback, but one more time wouldn't hurt. :-) ...
> Using SKIP as a command didn't work all that much better. (the example > in the new FAQ basically hangs, using up 100% of the CPU)
Now that I've not seen before. In what way were you using it? Here is one way: data: [1 2 3 4] ; yields == [1 2 3 4] data: skip data 2 ; yields == [3 4] data ; yields == [3 4] data: head data ; yields == [1 2 3 4] Please feel free to ask further clarification, especially if someone else doesn't also answer. Now, stop "skipping" your work, and get back to it! :-) --Scott Jones
[3/7] from: greggirwin:mindspring at: 3-Oct-2002 11:00
Hi Andy, << Is it my imagination, or is skip (both as a command and as a refinement) completely out to lunch when used on files ? >> Still broken AFAIK. I keep hoping they'll fix that one. --Gregg
[4/7] from: g:santilli:tiscalinet:it at: 3-Oct-2002 20:10
Hi Andy, On Thursday, October 3, 2002, 6:15:51 PM, you wrote: AF> If this is known, is there a good work around ? It is a known bug (it actually never worked for me...), and I think it has been reported several times too. (Anyway, please report it to feedback again; maybe this way it gets better attention. :) We're all waiting for a fix... To work around, you need to do something like: port: open/direct %file ; skip 1000 bytes copy/part port 1000 ; etc. The drawback is that you're actually reading from the file (which is of course MUCH slower than just skipping...). Regards, Gabriele. -- Gabriele Santilli <[g--santilli--tiscalinet--it]> -- REBOL Programmer Amigan -- AGI L'Aquila -- REB: http://web.tiscali.it/rebol/index.r
[5/7] from: andy:flyingcat at: 3-Oct-2002 13:55
> You will find differences of opinions on the best work-around, but for > getting an unbuffered binary file, the way that I use works
<<quoted lines omitted: 3>>> contents: copy p ;get rest of file > close port
Thanks. Unfortunately, I'm trying to stream large files across the network; the time to throw away the first 4 megs of the file would really slow things down. I guess I can prototype the streaming protocol in C and just control it from Rebol.
> The skip-as-a-refinement-bug has likely been reported to > feedback, but one > more time wouldn't hurt. > :-)
Already did :-)
> ... > > Using SKIP as a command didn't work all that much better.
<<quoted lines omitted: 10>>> someone else > doesn't also answer.
The FAQ example shows using a command sequence like file: open/binary/direct %myfile.txt skip file 2000 Which just hangs on the skip command. Andy
[6/7] from: gscottjones:mchsi at: 3-Oct-2002 14:18
From: "Andy Finkel" ...
> The FAQ example shows using a command sequence like > > file: open/binary/direct %myfile.txt > skip file 2000
Hi, Andy, My apologies. I was not catching on that you meant in reference to file handling. I guess I should have figured that out from the context. :-) By the way, if you are using network reads, Petr K. figured out that the following works. Don't ask _me_ why. It seems to be the only exception to the rule about /skip refinement bug. Curious. It may be a solution to your problem, depending. port: open/direct/binary/no-wait/skip http://www.rebol.com/graphics/kits.jpg 100 ;skips 100 bytes The thread that outlined some of the issues can be found (watch for line break): http://www.escribe.com/internet/rebol/index.html?by=OneThread&t=%5BREBOL%5D% 20tired of broken downloads%3F Good luck. --Scott Jones
[7/7] from: petr::krenzelok::trz::cz at: 3-Oct-2002 22:53
G. Scott Jones wrote:
>From: "Andy Finkel" >...
<<quoted lines omitted: 14>>>port: open/direct/binary/no-wait/skip http://www.rebol.com/graphics/kits.jpg >100 ;skips 100 bytes
I think it works as it has nothing in common with rebol, no? :-) You just contact web-server and it (e.g. Apache) does it for you. The problem is with local files. IIRC Carl told me on IOS some two months ago that the issues is being looked into. Has anyone tried with /base already? ble: open/direct %huhu.txt insert ble "12345678" close ble ble: open/direct/skip %huhu.txt 5 insert ble "ABC" close ble print read %huhu.txt ==ABC45678 Hmm, so I tried ... apparently still not fixed ... wasn't that bug reported two or so years ago? ;-) -pekr-
- Quoted lines have been omitted from some messages.
View the message alone to see the lines that have been omitted