Re: [Factor-talk] handle-seekable?
This must be a bug. A stream backed by a file is seekable so 0 should be returned as its length. 2016-07-08 1:32 GMT+02:00 John Benediktsson: > Possibly not easy to tell at that point if it is a file or network descriptor > and the worst case is an additional read that returns EOF on an empty file? > >> On Jul 7, 2016, at 4:06 PM, Alexander Ilin wrote: >> >> Hello, John! >> >> TCP/UDP streams are not seekable, so it should return f, and it does. Why >> does it not return 0 for seekable empty (file) streams? >> >> A bigger quote from the documentation: >> >> Word description >> Returns the length of the data supplied by stream, or f if the stream is not >> seekable or has unknown length. >> >> Notes >> Stream seeking is not supported on streams that do not have a known length, >> e.g. TCP/IP streams. >> >> 08.07.2016, 00:42, "John Benediktsson" : >>> For tcp/udp file descriptors, they can return 0 length sometimes and we >>> want to then return `f` so we read to EOF. >>> On Jul 7, 2016, at 2:26 PM, Alexander Ilin wrote: Hello! OK, ignore that last message, I can see now that it works. Another question, though. This one is about io.ports: M: buffered-port stream-length handle>> handle-length [ f ] when-zero ; Why does it never return 0? For instance, what if I open an empty file for reading, I'd expect it to return 0, and "f" only for streams that are not seekable. { 0 } [ "empty.txt" binary [ input-stream get stream-length ] with-file-reader ] unit-test From the documentation on stream-length: Word description Returns the length of the data supplied by stream, or f if the stream is not seekable or has unknown length. Why not return 0 so that I could test that with if-zero? >> >> ---=--- >> Александр >> >> -- >> Attend Shape: An AT Tech Expo July 15-16. Meet us at AT Park in San >> Francisco, CA to explore cutting-edge tech and listen to tech luminaries >> present their vision of the future. This family event has something for >> everyone, including kids. Get more information and register today. >> http://sdm.link/attshape >> ___ >> Factor-talk mailing list >> Factor-talk@lists.sourceforge.net >> https://lists.sourceforge.net/lists/listinfo/factor-talk > > -- > Attend Shape: An AT Tech Expo July 15-16. Meet us at AT Park in San > Francisco, CA to explore cutting-edge tech and listen to tech luminaries > present their vision of the future. This family event has something for > everyone, including kids. Get more information and register today. > http://sdm.link/attshape > ___ > Factor-talk mailing list > Factor-talk@lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/factor-talk -- mvh/best regards Björn Lindqvist -- What NetFlow Analyzer can do for you? Monitors network bandwidth and traffic patterns at an interface-level. Reveals which users, apps, and protocols are consuming the most bandwidth. Provides multi-vendor support for NetFlow, J-Flow, sFlow and other flows. Make informed decisions using capacity planning reports.http://sdm.link/zohodev2dev ___ Factor-talk mailing list Factor-talk@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/factor-talk
Re: [Factor-talk] handle-seekable?
Possibly not easy to tell at that point if it is a file or network descriptor and the worst case is an additional read that returns EOF on an empty file? > On Jul 7, 2016, at 4:06 PM, Alexander Ilinwrote: > > Hello, John! > > TCP/UDP streams are not seekable, so it should return f, and it does. Why > does it not return 0 for seekable empty (file) streams? > > A bigger quote from the documentation: > > Word description > Returns the length of the data supplied by stream, or f if the stream is not > seekable or has unknown length. > > Notes > Stream seeking is not supported on streams that do not have a known length, > e.g. TCP/IP streams. > > 08.07.2016, 00:42, "John Benediktsson" : >> For tcp/udp file descriptors, they can return 0 length sometimes and we want >> to then return `f` so we read to EOF. >> >>> On Jul 7, 2016, at 2:26 PM, Alexander Ilin wrote: >>> >>> Hello! >>> >>> OK, ignore that last message, I can see now that it works. >>> >>> Another question, though. This one is about io.ports: >>> >>> M: buffered-port stream-length >>>handle>> handle-length [ f ] when-zero ; >>> >>> Why does it never return 0? For instance, what if I open an empty file for >>> reading, I'd expect it to return 0, and "f" only for streams that are not >>> seekable. >>> >>> { 0 } >>> [ >>>"empty.txt" binary [ input-stream get stream-length ] with-file-reader >>> ] unit-test >>> >>> From the documentation on stream-length: >>> Word description >>> Returns the length of the data supplied by stream, or f if the stream is >>> not seekable or has unknown length. >>> >>> Why not return 0 so that I could test that with if-zero? > > ---=--- > Александр > > -- > Attend Shape: An AT Tech Expo July 15-16. Meet us at AT Park in San > Francisco, CA to explore cutting-edge tech and listen to tech luminaries > present their vision of the future. This family event has something for > everyone, including kids. Get more information and register today. > http://sdm.link/attshape > ___ > Factor-talk mailing list > Factor-talk@lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/factor-talk -- Attend Shape: An AT Tech Expo July 15-16. Meet us at AT Park in San Francisco, CA to explore cutting-edge tech and listen to tech luminaries present their vision of the future. This family event has something for everyone, including kids. Get more information and register today. http://sdm.link/attshape ___ Factor-talk mailing list Factor-talk@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/factor-talk
Re: [Factor-talk] handle-seekable?
Hello, John! TCP/UDP streams are not seekable, so it should return f, and it does. Why does it not return 0 for seekable empty (file) streams? A bigger quote from the documentation: Word description Returns the length of the data supplied by stream, or f if the stream is not seekable or has unknown length. Notes Stream seeking is not supported on streams that do not have a known length, e.g. TCP/IP streams. 08.07.2016, 00:42, "John Benediktsson": > For tcp/udp file descriptors, they can return 0 length sometimes and we want > to then return `f` so we read to EOF. > >> On Jul 7, 2016, at 2:26 PM, Alexander Ilin wrote: >> >> Hello! >> >> OK, ignore that last message, I can see now that it works. >> >> Another question, though. This one is about io.ports: >> >> M: buffered-port stream-length >> handle>> handle-length [ f ] when-zero ; >> >> Why does it never return 0? For instance, what if I open an empty file for >> reading, I'd expect it to return 0, and "f" only for streams that are not >> seekable. >> >> { 0 } >> [ >> "empty.txt" binary [ input-stream get stream-length ] with-file-reader >> ] unit-test >> >> From the documentation on stream-length: >> Word description >> Returns the length of the data supplied by stream, or f if the stream is >> not seekable or has unknown length. >> >> Why not return 0 so that I could test that with if-zero? ---=--- Александр -- Attend Shape: An AT Tech Expo July 15-16. Meet us at AT Park in San Francisco, CA to explore cutting-edge tech and listen to tech luminaries present their vision of the future. This family event has something for everyone, including kids. Get more information and register today. http://sdm.link/attshape ___ Factor-talk mailing list Factor-talk@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/factor-talk
Re: [Factor-talk] handle-seekable?
Hello, John! TCP/UDP streams are not seekable, so it should return f, and it does. Why does it not return 0 for seekable empty (file) streams? A bigger quote from the documentation: Word description Returns the length of the data supplied by stream, or f if the stream is not seekable or has unknown length. Notes Stream seeking is not supported on streams that do not have a known length, e.g. TCP/IP streams. 08.07.2016, 00:42, "John Benediktsson": > For tcp/udp file descriptors, they can return 0 length sometimes and we want > to then return `f` so we read to EOF. > >> On Jul 7, 2016, at 2:26 PM, Alexander Ilin wrote: >> >> Hello! >> >> OK, ignore that last message, I can see now that it works. >> >> Another question, though. This one is about io.ports: >> >> M: buffered-port stream-length >> handle>> handle-length [ f ] when-zero ; >> >> Why does it never return 0? For instance, what if I open an empty file for >> reading, I'd expect it to return 0, and "f" only for streams that are not >> seekable. >> >> { 0 } >> [ >> "empty.txt" binary [ input-stream get stream-length ] with-file-reader >> ] unit-test >> >> From the documentation on stream-length: >> Word description >> Returns the length of the data supplied by stream, or f if the stream is >> not seekable or has unknown length. >> >> Why not return 0 so that I could test that with if-zero? >> >> 07.07.2016, 23:55, "Alexander Ilin" : >>> Hello! >>> >>> I'm deep in debugging, so just a quick note/question: does the following >>> word work? >>> >>> M: windows can-seek-handle? ( handle -- ? ) >>> handle>> handle>file-size >boolean ; >>> >>> given that handle>file-size is implemented a few lines above as follows >>> (the comment is in the code as well): >>> >>> ! GetFileSizeEx errors with ERROR_INVALID_FUNCTION if handle is not >>> seekable >>> : handle>file-size ( handle -- n/f ) >>> (handle>file-size) [ >>> GetLastError ERROR_INVALID_FUNCTION = >>> [ f ] [ throw-win32-error ] if >>> ] unless* ; >>> >>> ---=--- >>> Александр >>> >>> >>> -- >>> Attend Shape: An AT Tech Expo July 15-16. Meet us at AT Park in San >>> Francisco, CA to explore cutting-edge tech and listen to tech luminaries >>> present their vision of the future. This family event has something for >>> everyone, including kids. Get more information and register today. >>> http://sdm.link/attshape >>> ___ >>> Factor-talk mailing list >>> Factor-talk@lists.sourceforge.net >>> https://lists.sourceforge.net/lists/listinfo/factor-talk >> >> ---=--- >> Александр >> >> >> -- >> Attend Shape: An AT Tech Expo July 15-16. Meet us at AT Park in San >> Francisco, CA to explore cutting-edge tech and listen to tech luminaries >> present their vision of the future. This family event has something for >> everyone, including kids. Get more information and register today. >> http://sdm.link/attshape >> ___ >> Factor-talk mailing list >> Factor-talk@lists.sourceforge.net >> https://lists.sourceforge.net/lists/listinfo/factor-talk > > -- > Attend Shape: An AT Tech Expo July 15-16. Meet us at AT Park in San > Francisco, CA to explore cutting-edge tech and listen to tech luminaries > present their vision of the future. This family event has something for > everyone, including kids. Get more information and register today. > http://sdm.link/attshape > ___ > Factor-talk mailing list > Factor-talk@lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/factor-talk ---=--- Александр -- Attend Shape: An AT Tech Expo July 15-16. Meet us at AT Park in San Francisco, CA to explore cutting-edge tech and listen to tech luminaries present their vision of the future. This family event has something for everyone, including kids. Get more information and register today. http://sdm.link/attshape ___ Factor-talk mailing list Factor-talk@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/factor-talk
Re: [Factor-talk] handle-seekable?
For tcp/udp file descriptors, they can return 0 length sometimes and we want to then return `f` so we read to EOF. > On Jul 7, 2016, at 2:26 PM, Alexander Ilinwrote: > > Hello! > > OK, ignore that last message, I can see now that it works. > > Another question, though. This one is about io.ports: > > M: buffered-port stream-length >handle>> handle-length [ f ] when-zero ; > > Why does it never return 0? For instance, what if I open an empty file for > reading, I'd expect it to return 0, and "f" only for streams that are not > seekable. > > { 0 } > [ >"empty.txt" binary [ input-stream get stream-length ] with-file-reader > ] unit-test > > From the documentation on stream-length: > Word description > Returns the length of the data supplied by stream, or f if the stream is not > seekable or has unknown length. > > Why not return 0 so that I could test that with if-zero? > > 07.07.2016, 23:55, "Alexander Ilin" : >> Hello! >> >> I'm deep in debugging, so just a quick note/question: does the following >> word work? >> >> M: windows can-seek-handle? ( handle -- ? ) >> handle>> handle>file-size >boolean ; >> >> given that handle>file-size is implemented a few lines above as follows >> (the comment is in the code as well): >> >> ! GetFileSizeEx errors with ERROR_INVALID_FUNCTION if handle is not seekable >> : handle>file-size ( handle -- n/f ) >> (handle>file-size) [ >> GetLastError ERROR_INVALID_FUNCTION = >> [ f ] [ throw-win32-error ] if >> ] unless* ; >> >> ---=--- >> Александр >> >> -- >> Attend Shape: An AT Tech Expo July 15-16. Meet us at AT Park in San >> Francisco, CA to explore cutting-edge tech and listen to tech luminaries >> present their vision of the future. This family event has something for >> everyone, including kids. Get more information and register today. >> http://sdm.link/attshape >> ___ >> Factor-talk mailing list >> Factor-talk@lists.sourceforge.net >> https://lists.sourceforge.net/lists/listinfo/factor-talk > > ---=--- > Александр > > -- > Attend Shape: An AT Tech Expo July 15-16. Meet us at AT Park in San > Francisco, CA to explore cutting-edge tech and listen to tech luminaries > present their vision of the future. This family event has something for > everyone, including kids. Get more information and register today. > http://sdm.link/attshape > ___ > Factor-talk mailing list > Factor-talk@lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/factor-talk -- Attend Shape: An AT Tech Expo July 15-16. Meet us at AT Park in San Francisco, CA to explore cutting-edge tech and listen to tech luminaries present their vision of the future. This family event has something for everyone, including kids. Get more information and register today. http://sdm.link/attshape ___ Factor-talk mailing list Factor-talk@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/factor-talk
Re: [Factor-talk] handle-seekable?
Hello! OK, ignore that last message, I can see now that it works. Another question, though. This one is about io.ports: M: buffered-port stream-length handle>> handle-length [ f ] when-zero ; Why does it never return 0? For instance, what if I open an empty file for reading, I'd expect it to return 0, and "f" only for streams that are not seekable. { 0 } [ "empty.txt" binary [ input-stream get stream-length ] with-file-reader ] unit-test From the documentation on stream-length: Word description Returns the length of the data supplied by stream, or f if the stream is not seekable or has unknown length. Why not return 0 so that I could test that with if-zero? 07.07.2016, 23:55, "Alexander Ilin": > Hello! > > I'm deep in debugging, so just a quick note/question: does the following > word work? > > M: windows can-seek-handle? ( handle -- ? ) > handle>> handle>file-size >boolean ; > > given that handle>file-size is implemented a few lines above as follows > (the comment is in the code as well): > > ! GetFileSizeEx errors with ERROR_INVALID_FUNCTION if handle is not seekable > : handle>file-size ( handle -- n/f ) > (handle>file-size) [ > GetLastError ERROR_INVALID_FUNCTION = > [ f ] [ throw-win32-error ] if > ] unless* ; > > ---=--- > Александр > > -- > Attend Shape: An AT Tech Expo July 15-16. Meet us at AT Park in San > Francisco, CA to explore cutting-edge tech and listen to tech luminaries > present their vision of the future. This family event has something for > everyone, including kids. Get more information and register today. > http://sdm.link/attshape > ___ > Factor-talk mailing list > Factor-talk@lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/factor-talk ---=--- Александр -- Attend Shape: An AT Tech Expo July 15-16. Meet us at AT Park in San Francisco, CA to explore cutting-edge tech and listen to tech luminaries present their vision of the future. This family event has something for everyone, including kids. Get more information and register today. http://sdm.link/attshape ___ Factor-talk mailing list Factor-talk@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/factor-talk
[Factor-talk] handle-seekable?
Hello! I'm deep in debugging, so just a quick note/question: does the following word work? M: windows can-seek-handle? ( handle -- ? ) handle>> handle>file-size >boolean ; given that handle>file-size is implemented a few lines above as follows (the comment is in the code as well): ! GetFileSizeEx errors with ERROR_INVALID_FUNCTION if handle is not seekable : handle>file-size ( handle -- n/f ) (handle>file-size) [ GetLastError ERROR_INVALID_FUNCTION = [ f ] [ throw-win32-error ] if ] unless* ; ---=--- Александр -- Attend Shape: An AT Tech Expo July 15-16. Meet us at AT Park in San Francisco, CA to explore cutting-edge tech and listen to tech luminaries present their vision of the future. This family event has something for everyone, including kids. Get more information and register today. http://sdm.link/attshape ___ Factor-talk mailing list Factor-talk@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/factor-talk