From: Mark M. <mie...@gm...> - 2013-05-28 16:44:05
|
On Tue, May 28, 2013 at 8:42 AM, Mike Cowlishaw <mf...@sp...> wrote: > ** > > I also am a little nervous about the fix, which is the main reason I > asked. I'm going to commit it for now. > > No possibility to cause an error/NotReady to be raised (as for an invalid > name)? > There is / was no easy way that I saw. In the first tests I did, prior to trying to write, the stream state is unknown. Then when you try to actually write to the (truncated) file name, the stream will be in an error state. name = 'C:\' || 'bogus'~copies(200) --fsObj = .Stream~new(copies('x', 999)) fsObj = .Stream~new(name) say 'Stream state:' fsObj~state say 'Name: ' fsObj~qualify fsObj~lineout("Help") say 'Stream state:' fsObj~state C:\work.ooRexx>qtest.rex Stream state: UNKNOWN Name: C:\bogusbogusbogusbogusbogusbogusbogusbogusbogusbogusbogusbogusbogusbogusbogusbogusbogusbogusbogus bogusbogusbogusbogusbogusbogusbogusbogusbogusbogusbogusbogusbogusbogusbogusbogusbogusbogusbogusbogusbogusbogusbo gusbogusbogusbogusbogusbogusbogusbogusbogusbogusb Stream state: ERROR C:\work.ooRexx> But, it is possible to construct a too long string whose truncated name will be valid. name = 'C:\work.ooRexx\' || 'bogus'~copies(200) --fsObj = .Stream~new(copies('x', 999)) fsObj = .Stream~new(name) say 'Stream state:' fsObj~state say 'Name: ' fsObj~qualify fsObj~lineout("Help") say 'Stream state:' fsObj~state C:\work.ooRexx>qtest.rex Stream state: UNKNOWN Name: C:\work.ooRexx\bogusbogusbogusbogusbogusbogusbogusbogusbogusbogusbogusbogusbogusbogusbogusbogusbog usbogusbogusbogusbogusbogusbogusbogusbogusbogusbogusbogusbogusbogusbogusbogusbogusbogusbogusbogusbogusbogusbogus bogusbogusbogusbogusbogusbogusbogusbogusbogusbogu Stream state: READY C:\work.ooRexx> A problem is that the method currently doesn't return a value: void SysFileSystem::qualifyStreamName() and is invoked from a number of different places where the code is not expecting a return. So there would need to be some significant rewriting for a better fix. Where qualifyStreamName is called from StreamNative, the rewrite is pretty simple and the stream can be put in the error state when the name too long is detected. But, where qualifyStreamName is called from the builtin qualify function, the fix is not so apparent to me. There is no stream to put in an error state that I see. How do we signal an error there? Should we signal an error? The truncated name may or may not be a valid file name, but in all cases the returned truncated value is the longest possible file name on Windows. -- Mark Miesfeld |