diff options
author | Siri Hansen <[email protected]> | 2013-02-12 20:00:09 +0100 |
---|---|---|
committer | Siri Hansen <[email protected]> | 2013-05-14 17:01:54 +0200 |
commit | a89ed3d94f3966d07a061fe540a87db15357e4d2 (patch) | |
tree | 2f2f40afbb6a7f4030b0eca9dcc08b71c5bfc2b2 /lib/sasl/examples | |
parent | 45b6ff14ff5a644517ca029fafdae8a63700cd93 (diff) | |
download | otp-a89ed3d94f3966d07a061fe540a87db15357e4d2.tar.gz otp-a89ed3d94f3966d07a061fe540a87db15357e4d2.tar.bz2 otp-a89ed3d94f3966d07a061fe540a87db15357e4d2.zip |
[sasl] Update example/target_system.erl to handle unicode
This example module can now create and install a release in a
directory which contains unicode characters. The erlang node must be
started with the +fnu* switch for this work.
Diffstat (limited to 'lib/sasl/examples')
-rw-r--r-- | lib/sasl/examples/src/target_system.erl | 35 |
1 files changed, 18 insertions, 17 deletions
diff --git a/lib/sasl/examples/src/target_system.erl b/lib/sasl/examples/src/target_system.erl index ffc0fcf443..fb9e9aaaaf 100644 --- a/lib/sasl/examples/src/target_system.erl +++ b/lib/sasl/examples/src/target_system.erl @@ -1,7 +1,7 @@ %% %% %CopyrightBegin% %% -%% Copyright Ericsson AB 2011. All Rights Reserved. +%% Copyright Ericsson AB 2011-2013. All Rights Reserved. %% %% The contents of this file are subject to the Erlang Public License, %% Version 1.1, (the "License"); you may not use this file except in @@ -34,9 +34,9 @@ create(RelFileName,SystoolsOpts) -> Dir = filename:dirname(RelFileName), PlainRelFileName = filename:join(Dir,"plain"), PlainRelFile = PlainRelFileName ++ ".rel", - io:fwrite("Reading file: ~p ...~n", [RelFile]), + io:fwrite("Reading file: ~tp ...~n", [RelFile]), {ok, [RelSpec]} = file:consult(RelFile), - io:fwrite("Creating file: ~p from ~p ...~n", + io:fwrite("Creating file: ~tp from ~tp ...~n", [PlainRelFile, RelFile]), {release, {RelName, RelVsn}, @@ -57,41 +57,41 @@ create(RelFileName,SystoolsOpts) -> io:fwrite(Fd, "~p.~n", [PlainRelSpec]), file:close(Fd), - io:fwrite("Making \"~s.script\" and \"~s.boot\" files ...~n", + io:fwrite("Making \"~ts.script\" and \"~ts.boot\" files ...~n", [PlainRelFileName,PlainRelFileName]), make_script(PlainRelFileName,SystoolsOpts), - io:fwrite("Making \"~s.script\" and \"~s.boot\" files ...~n", + io:fwrite("Making \"~ts.script\" and \"~ts.boot\" files ...~n", [RelFileName, RelFileName]), make_script(RelFileName,SystoolsOpts), TarFileName = filename:join(Dir,RelFileName ++ ".tar.gz"), - io:fwrite("Creating tar file ~p ...~n", [TarFileName]), + io:fwrite("Creating tar file ~tp ...~n", [TarFileName]), make_tar(RelFileName,SystoolsOpts), TmpDir = filename:join(Dir,"tmp"), - io:fwrite("Creating directory ~p ...~n",[TmpDir]), + io:fwrite("Creating directory ~tp ...~n",[TmpDir]), file:make_dir(TmpDir), - io:fwrite("Extracting ~p into directory ~p ...~n", [TarFileName,TmpDir]), + io:fwrite("Extracting ~tp into directory ~tp ...~n", [TarFileName,TmpDir]), extract_tar(TarFileName, TmpDir), TmpBinDir = filename:join([TmpDir, "bin"]), ErtsBinDir = filename:join([TmpDir, "erts-" ++ ErtsVsn, "bin"]), - io:fwrite("Deleting \"erl\" and \"start\" in directory ~p ...~n", + io:fwrite("Deleting \"erl\" and \"start\" in directory ~tp ...~n", [ErtsBinDir]), file:delete(filename:join([ErtsBinDir, "erl"])), file:delete(filename:join([ErtsBinDir, "start"])), - io:fwrite("Creating temporary directory ~p ...~n", [TmpBinDir]), + io:fwrite("Creating temporary directory ~tp ...~n", [TmpBinDir]), file:make_dir(TmpBinDir), - io:fwrite("Copying file \"~s.boot\" to ~p ...~n", + io:fwrite("Copying file \"~ts.boot\" to ~tp ...~n", [PlainRelFileName, filename:join([TmpBinDir, "start.boot"])]), copy_file(PlainRelFileName++".boot",filename:join([TmpBinDir, "start.boot"])), io:fwrite("Copying files \"epmd\", \"run_erl\" and \"to_erl\" from \n" - "~p to ~p ...~n", + "~tp to ~tp ...~n", [ErtsBinDir, TmpBinDir]), copy_file(filename:join([ErtsBinDir, "epmd"]), filename:join([TmpBinDir, "epmd"]), [preserve]), @@ -101,11 +101,11 @@ create(RelFileName,SystoolsOpts) -> filename:join([TmpBinDir, "to_erl"]), [preserve]), StartErlDataFile = filename:join([TmpDir, "releases", "start_erl.data"]), - io:fwrite("Creating ~p ...~n", [StartErlDataFile]), + io:fwrite("Creating ~tp ...~n", [StartErlDataFile]), StartErlData = io_lib:fwrite("~s ~s~n", [ErtsVsn, RelVsn]), write_file(StartErlDataFile, StartErlData), - io:fwrite("Recreating tar file ~p from contents in directory ~p ...~n", + io:fwrite("Recreating tar file ~tp from contents in directory ~tp ...~n", [TarFileName,TmpDir]), {ok, Tar} = erl_tar:open(TarFileName, [write, compressed]), %% {ok, Cwd} = file:get_cwd(), @@ -117,14 +117,14 @@ create(RelFileName,SystoolsOpts) -> erl_tar:add(Tar, filename:join(TmpDir,"lib"), "lib", []), erl_tar:close(Tar), %% file:set_cwd(Cwd), - io:fwrite("Removing directory ~p ...~n",[TmpDir]), + io:fwrite("Removing directory ~tp ...~n",[TmpDir]), remove_dir_tree(TmpDir), ok. install(RelFileName, RootDir) -> TarFile = RelFileName ++ ".tar.gz", - io:fwrite("Extracting ~p ...~n", [TarFile]), + io:fwrite("Extracting ~tp ...~n", [TarFile]), extract_tar(TarFile, RootDir), StartErlDataFile = filename:join([RootDir, "releases", "start_erl.data"]), {ok, StartErlData} = read_txt_file(StartErlDataFile), @@ -235,8 +235,9 @@ copy_file(Src, Dest, Opts) -> end. write_file(FName, Conts) -> + Enc = file:native_name_encoding(), {ok, Fd} = file:open(FName, [write]), - file:write(Fd, Conts), + file:write(Fd, unicode:characters_to_binary(Conts,Enc,Enc)), file:close(Fd). read_txt_file(File) -> |