[erlang-questions] how: string stream?
Ulf Wiger
ulf@REDACTED
Thu Nov 15 15:08:35 CET 2007
I finally figured out that my use of the ram_file_io_server was
buggy. The function ram_file:open/2 doesn't take a file name
as a first argument, but rather the data that's supposed to
go into the file.
A more correct call would be:
erlhive_ram_file_io_server:start(self(), Str, [read]).
As I had done it, the file was first created with the file name as
its content, which was then (hopefully completely) overwritten by
Str. I had some great fun debugging when I tried this on code that
was shorter than the file name I had invented. (:
BR,
Ulf W
2007/10/31, Ulf Wiger (TN/EAB) <ulf.wiger@REDACTED>:
> Bengt Kleberg wrote:
> > greetings,
> >
> > there are at least two string streams that i know of. Ulf Wiger has one
> > and I have one (string_io). his should be better.
>
> I assume you mean this:
>
> http://erlhive.svn.sourceforge.net/viewvc/erlhive/trunk/lib/erlhive/src/erlhive_ram_file_io_server.erl?revision=57&view=markup
>
> used in this fasion:
>
> http://erlhive.svn.sourceforge.net/viewvc/erlhive/trunk/lib/erlhive/src/erlhive_rewrite.erl?revision=64&view=markup
>
> 121 parse_string(Str, Fname) ->
> 122 {ok, Fd} = open_ram_file(Fname),
> 123 file:write(Fd, Str),
> 124 file:position(Fd, 0),
> 125 case epp_dodger:parse(Fd) of
> 126 {ok, Tree} ->
> 127 close_ram_file(Fd),
> 128 Tree;
> 129 Error ->
> 130 close_ram_file(Fd),
> 131 erlang:error(Error)
> 132 end.
> 133
> 134
> 135 open_ram_file(Fname) ->
> 136 erlhive_ram_file_io_server:start(self(), Fname, [read,write]).
> 137
> 138 close_ram_file(Fd) ->
> 139 file:close(Fd).
>
> It's not exactly a string stream, though.
>
> BR,
> Ulf W
> _______________________________________________
> erlang-questions mailing list
> erlang-questions@REDACTED
> http://www.erlang.org/mailman/listinfo/erlang-questions
>
More information about the erlang-questions
mailing list