1
-module(file_name_SUITE).
5
%% Copyright Ericsson AB 1996-2011. All Rights Reserved.
7
%% The contents of this file are subject to the Erlang Public License,
8
%% Version 1.1, (the "License"); you may not use this file except in
9
%% compliance with the License. You should have received a copy of the
10
%% Erlang Public License along with this software. If not, it can be
11
%% retrieved online at http://www.erlang.org/.
13
%% Software distributed under the License is distributed on an "AS IS"
14
%% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
15
%% the License for the specific language governing rights and limitations
21
-include_lib("test_server/include/test_server.hrl").
22
-include_lib("kernel/include/file.hrl").
25
%% File operations that take filenames as parameters (* not prim_file operation) (** a drive):
45
%% File operations that opens/uses separate driver port (not connected to file)
61
%% Operations that use ?FD_DRV in prim_file
67
%% Operations that return a filename/path
73
-export([all/0,groups/0,suite/0,
74
init_per_suite/1,end_per_suite/1,
75
init_per_group/2,end_per_group/2,
76
init_per_testcase/2, end_per_testcase/2]).
77
-export([normal/1,icky/1,very_icky/1,normalize/1]).
80
init_per_testcase(_Func, Config) ->
81
Dog = test_server:timetrap(test_server:seconds(60)),
82
[{watchdog,Dog}|Config].
84
end_per_testcase(_Func, Config) ->
85
Dog = ?config(watchdog, Config),
86
test_server:timetrap_cancel(Dog).
88
suite() -> [{ct_hooks,[ts_install_cth]}].
91
[normal, icky, very_icky, normalize].
96
init_per_suite(Config) ->
99
end_per_suite(_Config) ->
102
init_per_group(_GroupName, Config) ->
105
end_per_group(_GroupName, Config) ->
111
["Check that filename normalization works"];
112
normalize(Config) when is_list(Config) ->
113
random:seed({1290,431421,830412}),
115
?line UniMode = file:native_name_encoding() =/= latin1,
118
throw(need_unicode_mode);
122
?line Pairs = [rand_comp_decomp(200) || _ <- lists:seq(1,1000)],
125
?line [ true = (A =:= prim_file:internal_native2name(B)) ||
130
?line [ true = (A =:= prim_file:internal_normalize_utf8(B)) ||
134
throw:need_unicode_mode ->
135
io:format("Sorry, can only run in unicode mode.~n"),
136
{skipped,"VM needs to be started in Unicode filename mode"}
142
"Check file operations on normal file names regardless of unicode mode";
143
normal(Config) when is_list(Config) ->
144
{ok,Dir} = file:get_cwd(),
146
Priv = ?config(priv_dir, Config),
148
put(file_module,prim_file),
149
ok = check_normal(prim_file),
150
put(file_module,file),
151
ok = check_normal(file)
160
"Check file operations on normal file names regardless of unicode mode";
161
icky(Config) when is_list(Config) ->
162
case hopeless_darwin() of
164
{skipped,"This version of darwin does not support icky names at all."};
166
{ok,Dir} = file:get_cwd(),
168
Priv = ?config(priv_dir, Config),
170
put(file_module,prim_file),
171
ok = check_icky(prim_file),
172
put(file_module,file),
173
ok = check_icky(file)
181
"Check file operations on normal file names regardless of unicode mode";
182
very_icky(Config) when is_list(Config) ->
183
case hopeless_darwin() of
185
{skipped,"This version of darwin does not support icky names at all."};
187
{ok,Dir} = file:get_cwd(),
189
Priv = ?config(priv_dir, Config),
191
put(file_module,prim_file),
192
case check_very_icky(prim_file) of
194
{skipped,"VM needs to be started in Unicode filename mode"};
196
put(file_module,file),
197
ok = check_very_icky(file)
206
{ok,Dir} = Mod:get_cwd(),
208
?line make_normal_dir(Mod),
209
?line {ok, L0} = Mod:list_dir("."),
210
?line L1 = lists:sort(L0),
212
?line L1 = lists:sort(list(normal_dir())),
213
?line {ok,D2} = Mod:get_cwd(),
214
?line true = is_list(D2),
215
?line case Mod:altname("fil1") of
218
{ok,LLL} when is_list(LLL) ->
221
?line [ true = is_list(El) || El <- L1],
222
?line Syms = [ {S,Targ,list_to_binary(get_data(Targ,normal_dir()))}
223
|| {T,S,Targ} <- normal_dir(), T =:= symlink ],
224
?line [ {ok, Cont} = Mod:read_file(SymL) || {SymL,_,Cont} <- Syms ],
225
?line [ {ok, Targ} = fixlink(Mod:read_link(SymL)) || {SymL,Targ,_} <- Syms ],
226
?line chk_cre_dir(Mod,[{directory,"temp_dir",normal_dir()}]),
227
?line {ok,BeginAt} = Mod:get_cwd(),
228
?line true = is_list(BeginAt),
229
?line {error,enoent} = Mod:set_cwd("tmp_dir"),
230
?line ok = Mod:set_cwd("temp_dir"),
231
?line {ok, NowAt} = Mod:get_cwd(),
232
?line true = BeginAt =/= NowAt,
233
?line ok = Mod:set_cwd(".."),
234
?line {ok,BeginAt} = Mod:get_cwd(),
235
?line rm_r(Mod,"temp_dir"),
236
?line true = is_list(Dir),
237
?line [ true = is_list(FN) || FN <- L0 ],
240
?line ok = Mod:make_link("fil1","nisse"),
241
?line {ok, <<"fil1">>} = Mod:read_file("nisse"),
242
?line {ok, #file_info{type = regular}} = Mod:read_link_info("nisse"),
243
?line ok = Mod:delete("nisse"),
244
?line {ok, <<"fil1">>} = Mod:read_file("fil1"),
245
?line {error,enoent} = Mod:read_file("nisse"),
246
?line {error,enoent} = Mod:read_link_info("nisse");
251
?line {ok, FD} = Mod:open(Name,[read]),
252
?line {ok, Content} = Mod:read(FD,1024),
253
?line ok = file:close(FD)
254
end || {regular,Name,Content} <- normal_dir() ],
256
?line {ok, FD} = Mod:open(Name,[read,binary]),
257
?line BC = list_to_binary(Content),
258
?line {ok, BC} = Mod:read(FD,1024),
259
?line ok = file:close(FD)
260
end || {regular,Name,Content} <- normal_dir() ],
261
?line Mod:rename("fil1","tmp_fil1"),
262
?line {ok, <<"fil1">>} = Mod:read_file("tmp_fil1"),
263
?line {error,enoent} = Mod:read_file("fil1"),
264
?line Mod:rename("tmp_fil1","fil1"),
265
?line {ok, <<"fil1">>} = Mod:read_file("fil1"),
266
?line {error,enoent} = Mod:read_file("tmp_fil1"),
267
?line {ok,FI} = Mod:read_file_info("fil1"),
268
?line NewMode = FI#file_info.mode band (bnot 8#333),
269
?line NewMode2 = NewMode bor 8#222,
270
?line true = NewMode2 =/= NewMode,
271
?line ok = Mod:write_file_info("fil1",FI#file_info{mode = NewMode}),
272
?line {ok,#file_info{mode = NewMode}} = Mod:read_file_info("fil1"),
273
?line ok = Mod:write_file_info("fil1",FI#file_info{mode = NewMode2}),
274
?line {ok,#file_info{mode = NewMode2}} = Mod:read_file_info("fil1"),
277
case Mod:read_file_info("fil1") of
279
NewModeI = FII#file_info.mode bor 8#777,
280
Mod:write_file_info("fil1",FII#file_info{mode = NewModeI});
285
io:format("Wd now: ~s~n",[Dir])
289
{ok,Dir} = Mod:get_cwd(),
291
?line true=(length("���") =:= 3),
292
?line UniMode = file:native_name_encoding() =/= latin1,
293
?line make_icky_dir(Mod),
294
?line {ok, L0} = Mod:list_dir("."),
295
?line L1 = lists:sort(L0),
296
io:format("~p ~p~n",[L1,list(icky_dir())]),
297
?line L1 = lists:sort(convlist(list(icky_dir()))),
298
?line {ok,D2} = Mod:get_cwd(),
299
?line true = is_list(D2),
300
%% Altname only on windows, and there are no non native filenames there
301
%% ?line case Mod:altname("fil1") of
302
%% {error,enotsup} ->
304
%% {ok,LLL} when is_list(LLL) ->
307
?line [ true = ((is_list(El) or (UniMode and is_binary(El)))) || El <- L1],
308
?line Syms = [ {S,conv(Targ),list_to_binary(get_data(Targ,icky_dir()))}
309
|| {T,S,Targ} <- icky_dir(), T =:= symlink ],
310
?line [ {ok, Cont} = Mod:read_file(SymL) || {SymL,_,Cont} <- Syms ],
311
?line [ {ok, Targ} = fixlink(Mod:read_link(SymL)) || {SymL,Targ,_} <- Syms ],
312
?line chk_cre_dir(Mod,[{directory,"���_dir",icky_dir()}]),
313
?line {ok,BeginAt} = Mod:get_cwd(),
314
?line true = is_list(BeginAt),
315
?line {error,enoent} = Mod:set_cwd("��_dir"),
316
?line ok = Mod:set_cwd("���_dir"),
317
?line {ok, NowAt} = Mod:get_cwd(),
318
?line true = is_list(NowAt),
319
?line true = BeginAt =/= NowAt,
320
?line ok = Mod:set_cwd(".."),
321
?line {ok,BeginAt} = Mod:get_cwd(),
322
?line rm_r2(Mod,"���_dir"),
323
{OS,TYPE} = os:type(),
324
% Check that treat_icky really converts to the same as the OS
327
?line chk_cre_dir(Mod,[{directory,"���_dir",[]}]),
328
?line ok = Mod:set_cwd("���_dir"),
329
?line ok = Mod:write_file(<<"���">>,<<"hello">>),
330
?line Treated = treat_icky(<<"���">>),
331
?line {ok,[Treated]} = Mod:list_dir("."),
332
?line ok = Mod:delete(<<"���">>),
333
?line {ok,[]} = Mod:list_dir("."),
334
?line ok = Mod:set_cwd(".."),
335
?line rm_r2(Mod,"���_dir");
340
?line chk_cre_dir(Mod,[{directory,treat_icky(<<"���_dir">>),icky_dir()}]),
342
UniMode and (OS =/= win32) ->
343
?line {error,enoent} = Mod:set_cwd("���_dir");
347
?line ok = Mod:set_cwd(treat_icky(<<"���_dir">>)),
348
?line {ok, NowAt2} = Mod:get_cwd(),
349
io:format("~p~n",[NowAt2]),
350
% Cannot create raw unicode-breaking filenames on windows or macos
351
?line true = ((((not UniMode) or (OS =:= win32) or (TYPE=:=darwin)) and is_list(NowAt2)) orelse ((UniMode) and is_binary(NowAt2))),
352
?line true = BeginAt =/= NowAt2,
353
?line ok = Mod:set_cwd(".."),
354
?line {ok,BeginAt} = Mod:get_cwd(),
355
?line rm_r2(Mod,conv(treat_icky(<<"���_dir">>))),
358
?line ok = Mod:make_link("fil1","nisse�"),
359
?line {ok, <<"fil1">>} = Mod:read_file("nisse�"),
360
?line {ok, #file_info{type = regular}} = Mod:read_link_info("nisse�"),
361
?line ok = Mod:delete("nisse�"),
362
?line ok = Mod:make_link("fil1",treat_icky(<<"nisse�">>)),
363
?line {ok, <<"fil1">>} = Mod:read_file(treat_icky(<<"nisse�">>)),
364
?line {ok, #file_info{type = regular}} = Mod:read_link_info(treat_icky(<<"nisse�">>)),
365
?line ok = Mod:delete(treat_icky(<<"nisse�">>)),
366
?line {ok, <<"fil1">>} = Mod:read_file("fil1"),
367
?line {error,enoent} = Mod:read_file("nisse�"),
368
?line {error,enoent} = Mod:read_link_info("nisse�"),
369
?line {error,enoent} = Mod:read_file(treat_icky(<<"nisse�">>)),
370
?line {error,enoent} = Mod:read_link_info(treat_icky(<<"nisse�">>));
375
?line {ok, FD} = Mod:open(Name,[read]),
376
?line {ok, Content} = Mod:read(FD,1024),
377
?line ok = file:close(FD)
378
end || {regular,Name,Content} <- icky_dir() ],
380
?line {ok, FD} = Mod:open(Name,[read,binary]),
381
?line BC = list_to_binary([Content]),
382
?line {ok, BC} = Mod:read(FD,1024),
383
?line ok = file:close(FD)
384
end || {regular,Name,Content} <- icky_dir() ],
385
?line Mod:rename("���2","���_fil1"),
386
?line {ok, <<"���2">>} = Mod:read_file("���_fil1"),
387
?line {error,enoent} = Mod:read_file("���2"),
388
?line Mod:rename("���_fil1","���2"),
389
?line {ok, <<"���2">>} = Mod:read_file("���2"),
390
?line {error,enoent} = Mod:read_file("���_fil1"),
392
?line Mod:rename("���2",treat_icky(<<"���_fil1">>)),
393
?line {ok, <<"���2">>} = Mod:read_file(treat_icky(<<"���_fil1">>)),
395
UniMode and (OS =/= win32) ->
396
{error,enoent} = Mod:read_file("���_fil1");
400
?line {error,enoent} = Mod:read_file("���2"),
401
?line Mod:rename(treat_icky(<<"���_fil1">>),"���2"),
402
?line {ok, <<"���2">>} = Mod:read_file("���2"),
403
?line {error,enoent} = Mod:read_file("���_fil1"),
404
?line {error,enoent} = Mod:read_file(treat_icky(<<"���_fil1">>)),
406
?line {ok,FI} = Mod:read_file_info("���2"),
407
?line NewMode = FI#file_info.mode band (bnot 8#333),
408
?line NewMode2 = NewMode bor 8#222,
409
?line true = NewMode2 =/= NewMode,
410
?line ok = Mod:write_file_info("���2",FI#file_info{mode = NewMode}),
411
?line {ok,#file_info{mode = NewMode}} = Mod:read_file_info("���2"),
412
?line ok = Mod:write_file_info("���2",FI#file_info{mode = NewMode2}),
413
?line {ok,#file_info{mode = NewMode2}} = Mod:read_file_info("���2"),
415
?line {ok,FII} = Mod:read_file_info(treat_icky(<<"���5">>)),
416
?line true = NewMode2 =/= NewMode,
417
?line ok = Mod:write_file_info(treat_icky(<<"���5">>),FII#file_info{mode = NewMode}),
418
?line {ok,#file_info{mode = NewMode}} = Mod:read_file_info(treat_icky(<<"���5">>)),
419
?line ok = Mod:write_file_info(<<"���5">>,FII#file_info{mode = NewMode2}),
420
?line {ok,#file_info{mode = NewMode2}} = Mod:read_file_info(treat_icky(<<"���5">>)),
424
io:format("Wd now: ~s~n",[Dir])
427
check_very_icky(Mod) ->
428
{ok,Dir} = Mod:get_cwd(),
430
?line true=(length("���") =:= 3),
431
?line UniMode = file:native_name_encoding() =/= latin1,
434
throw(need_unicode_mode);
438
?line make_very_icky_dir(Mod),
439
?line {ok, L0} = Mod:list_dir("."),
440
?line L1 = lists:sort(L0),
441
?line L1 = lists:sort(convlist(list(very_icky_dir()))),
442
?line {ok,D2} = Mod:get_cwd(),
443
?line true = is_list(D2),
444
?line [ true = ((is_list(El) or is_binary(El))) || El <- L1],
445
?line Syms = [ {S,conv(Targ),list_to_binary(get_data(Targ,very_icky_dir()))}
446
|| {T,S,Targ} <- very_icky_dir(), T =:= symlink ],
447
?line [ {ok, Cont} = Mod:read_file(SymL) || {SymL,_,Cont} <- Syms ],
448
?line [ {ok, Targ} = fixlink(Mod:read_link(SymL)) || {SymL,Targ,_} <- Syms ],
449
?line chk_cre_dir(Mod,[{directory,[1088,1079,1091]++"_dir",very_icky_dir()}]),
450
?line {ok,BeginAt} = Mod:get_cwd(),
451
?line true = is_list(BeginAt),
452
?line {error,enoent} = Mod:set_cwd("��_dir"),
453
?line ok = Mod:set_cwd([1088,1079,1091]++"_dir"),
454
?line {ok, NowAt} = Mod:get_cwd(),
455
?line true = is_list(NowAt),
456
?line true = BeginAt =/= NowAt,
457
?line ok = Mod:set_cwd(".."),
458
?line {ok,BeginAt} = Mod:get_cwd(),
459
?line rm_r2(Mod,[1088,1079,1091]++"_dir"),
463
?line ok = Mod:make_link("fil1","nisse"++[1088,1079,1091]),
464
?line {ok, <<"fil1">>} =
465
Mod:read_file("nisse"++[1088,1079,1091]),
466
?line {ok, #file_info{type = regular}} =
467
Mod:read_link_info("nisse"++[1088,1079,1091]),
468
?line ok = Mod:delete("nisse"++[1088,1079,1091]),
469
?line ok = Mod:make_link("fil1",<<"nisse�">>),
470
?line {ok, <<"fil1">>} = Mod:read_file(<<"nisse�">>),
471
?line {ok, #file_info{type = regular}} =
472
Mod:read_link_info(<<"nisse�">>),
473
?line ok = Mod:delete(<<"nisse�">>),
474
?line {ok, <<"fil1">>} = Mod:read_file("fil1"),
475
?line {error,enoent} = Mod:read_file("nisse"++[1088,1079,1091]),
476
?line {error,enoent} = Mod:read_link_info("nisse"++[1088,1079,1091]),
477
?line {error,enoent} = Mod:read_file(<<"nisse�">>),
478
?line {error,enoent} = Mod:read_link_info(<<"nisse�">>);
483
?line {ok, FD} = Mod:open(Name,[read]),
484
?line {ok, Content} = Mod:read(FD,1024),
485
?line ok = file:close(FD)
486
end || {regular,Name,Content} <- very_icky_dir() ],
488
?line {ok, FD} = Mod:open(Name,[read,binary]),
489
?line BC = list_to_binary([Content]),
490
?line {ok, BC} = Mod:read(FD,1024),
491
?line ok = file:close(FD)
492
end || {regular,Name,Content} <- very_icky_dir() ],
493
?line Mod:rename([956,965,963,954,959,49],
494
[956,965,963,954,959]++"_fil1"),
495
?line {ok, <<"���2">>} = Mod:read_file([956,965,963,954,959]++"_fil1"),
496
?line {error,enoent} = Mod:read_file([956,965,963,954,959,49]),
497
?line Mod:rename([956,965,963,954,959]++"_fil1",[956,965,963,954,959,49]),
498
?line {ok, <<"���2">>} = Mod:read_file([956,965,963,954,959,49]),
499
?line {error,enoent} = Mod:read_file([956,965,963,954,959]++"_fil1"),
501
?line {ok,FI} = Mod:read_file_info([956,965,963,954,959,49]),
502
?line NewMode = FI#file_info.mode band (bnot 8#333),
503
?line NewMode2 = NewMode bor 8#222,
504
?line true = NewMode2 =/= NewMode,
505
?line ok = Mod:write_file_info([956,965,963,954,959,49],
506
FI#file_info{mode = NewMode}),
507
?line {ok,#file_info{mode = NewMode}} =
508
Mod:read_file_info([956,965,963,954,959,49]),
509
?line ok = Mod:write_file_info([956,965,963,954,959,49],
510
FI#file_info{mode = NewMode2}),
511
?line {ok,#file_info{mode = NewMode2}} =
512
Mod:read_file_info([956,965,963,954,959,49]),
513
?line NumOK0 = case has_links() of
517
?line NumNOK0 = case has_links() of
521
?line {NumOK,NumNOK} = case is_binary(treat_icky(<<"foo">>)) of
527
?line {NumOK,NumNOK} = filelib:fold_files(".",".*",true,fun(_F,{N,M}) when is_list(_F) -> io:format("~ts~n",[_F]),{N+1,M}; (_F,{N,M}) -> io:format("~p~n",[_F]),{N,M+1} end,{0,0}),
528
?line ok = filelib:fold_files(".",[1076,1089,1072,124,46,42],true,fun(_F,_) -> ok end,false),
529
?line SF3 = unicode:characters_to_binary("���subfil3",
530
file:native_name_encoding()),
531
?line SF2 = case treat_icky(<<"���subfil2">>) of
532
LF2 when is_list(LF2) ->
533
unicode:characters_to_binary(LF2,
534
file:native_name_encoding());
538
?line Sorted = lists:sort([SF3,SF2]),
539
?line Sorted = lists:sort(filelib:wildcard("*",<<"���subdir2">>)),
542
throw:need_unicode_mode ->
543
io:format("Sorry, can only run in unicode mode.~n"),
547
io:format("Wd now: ~s~n",[Dir])
556
case Mod:read_link_info(Dir) of
557
{ok, #file_info{type = directory}} ->
558
{ok, Content} = Mod:list_dir(Dir),
559
[ rm_rf(Mod,filename:join(Dir,C)) || C <- Content ],
562
{ok, #file_info{}} ->
569
%erlang:display({rm_r,Dir}),
570
case Mod:read_link_info(Dir) of
571
{ok, #file_info{type = directory}} ->
572
{ok,#file_info{type = directory}} = Mod:read_file_info(Dir),
573
{ok, Content} = Mod:list_dir(Dir),
574
[ true = is_list(Part) || Part <- Content ],
575
[ true = is_list(filename:join(Dir,Part)) || Part <- Content ],
576
[ rm_r(Mod,filename:join(Dir,C)) || C <- Content ],
577
ok = Mod:del_dir(Dir),
579
{ok, #file_info{type = regular}} ->
580
{ok,#file_info{type = regular}} = Mod:read_file_info(Dir),
581
ok = Mod:delete(Dir);
582
{ok, #file_info{type = symlink}} ->
585
%% For icky test, allow binaries sometimes
587
%erlang:display({rm_r2,Dir}),
588
case Mod:read_link_info(Dir) of
589
{ok, #file_info{type = directory}} ->
590
{ok,#file_info{type = directory}} = Mod:read_file_info(Dir),
591
{ok, Content} = Mod:list_dir(Dir),
592
UniMode = file:native_name_encoding() =/= latin1,
593
[ true = (is_list(Part) orelse UniMode) || Part <- Content ],
594
[ true = (is_list(filename:join(Dir,Part)) orelse UniMode) || Part <- Content ],
595
[ rm_r2(Mod,filename:join(Dir,C)) || C <- Content ],
596
ok = Mod:del_dir(Dir),
598
{ok, #file_info{type = regular}} ->
599
{ok,#file_info{type = regular}} = Mod:read_file_info(Dir),
600
ok = Mod:delete(Dir);
601
{ok, #file_info{type = symlink}} ->
606
chk_cre_dir(Mod,[{regular,Name,Content}|T]) ->
607
%io:format("~p~n",[Name]),
608
ok = Mod:write_file(Name,Content),
610
chk_cre_dir(Mod,[{link,Name,Target}|T]) ->
611
ok = Mod:make_link(Target,Name),
613
chk_cre_dir(Mod,[{symlink,Name,Target}|T]) ->
614
ok = Mod:make_symlink(Target,Name),
616
chk_cre_dir(Mod,[{directory,Name,Content}|T]) ->
617
ok = Mod:make_dir(Name),
618
%io:format("Content = ~p~n",[Content]),
619
Content2 = [{Ty,filename:join(Name,N),case Ty of link -> filename:join(Name,C); _ -> C end} || {Ty,N,C} <- Content ],
620
%io:format("Content2 = ~p~n",[Content2]),
621
chk_cre_dir(Mod,Content2),
628
{N,NN,_} when (N > 5) andalso (NN >= 1) ->
637
make_normal_dir(Mod) ->
638
rm_rf(Mod,"normal_dir"),
639
Mod:make_dir("normal_dir"),
640
Mod:set_cwd("normal_dir"),
641
Mod:write_file("fil1","fil1"),
642
Mod:write_file("fil2","fil2"),
645
Mod:make_link("fil2","fil3"),
646
Mod:make_symlink("fil2","fil4");
650
Mod:make_dir("subdir"),
651
Mod:write_file(filename:join("subdir","subfil1"),"subfil1"),
655
[{regular,"fil1","fil1"},
656
{regular,"fil2","fil2"}] ++
659
[{regular,"fil3","fil2"},
660
{symlink,"fil4","fil2"}];
664
[{directory,"subdir",
665
[{regular,"subfil1","subfil1"}]}].
667
make_icky_dir(Mod) ->
668
rm_rf(Mod,"icky_dir"),
670
chk_cre_dir(Mod,[{directory,"icky_dir",linkify([],Icky)}]),
671
Mod:set_cwd("icky_dir"),
674
linkify(_Passed,[]) ->
676
linkify(Passed,[{regular,Name,Content}|T]) ->
677
Regulars = [ {N,C} || {regular,N,C} <- Passed, N =/= Name ],
678
case lists:keysearch(Content,2,Regulars) of
679
{value, {Linkto, Content}} ->
680
[{link,Name,Linkto} | linkify(Passed,T)];
682
[{regular,Name,Content} | linkify([{regular,Name,Content}|Passed],T)]
684
linkify(Passed,[{directory, Name, Content}|T]) ->
685
[{directory,Name, linkify(Content,Content)}|linkify(Passed,T)];
686
linkify(Passed,[H|T]) ->
687
[H|linkify([H|Passed],T)].
690
case {os:type(),os:version()} of
691
{{unix,darwin},{Major,_,_}} when Major < 9 ->
698
[{regular,"fil1","fil1"},
699
{regular,"���2","���2"}] ++
702
[{regular,"���3","���2"},
703
{symlink,"���4","���2"}];
707
[{regular,treat_icky(<<"���5">>),"���5"}] ++
710
[{symlink,treat_icky(<<"���6">>),treat_icky(<<"���5">>)}];
714
[{directory,treat_icky(<<"���subdir2">>),
715
[{regular,treat_icky(<<"���subfil2">>),"���subfil12"},
716
{regular,"���subfil3","���subfil13"}]},
717
{directory,"���subdir",
718
[{regular,"���subfil1","���subfil1"}]}].
720
make_very_icky_dir(Mod) ->
721
rm_rf(Mod,"very_icky_dir"),
722
Icky=very_icky_dir(),
723
chk_cre_dir(Mod,[{directory,"very_icky_dir",linkify([],Icky)}]),
724
Mod:set_cwd("very_icky_dir"),
728
[{regular,"fil1","fil1"},
729
{regular,[956,965,963,954,959,49],"���2"}] ++
732
[{regular,[956,965,963,954,959,50],"���2"},
733
{symlink,[956,965,963,954,959,51],[956,965,963,954,959,49]}];
737
[{regular,treat_icky(<<"���5">>),"���5"}] ++
740
[{symlink,treat_icky(<<"���6">>),treat_icky(<<"���5">>)}];
744
[{directory,treat_icky(<<"���subdir2">>),
745
[{regular,treat_icky(<<"���subfil2">>),"���subfil12"},
746
{regular,"���subfil3","���subfil13"}]},
747
{directory,[956,965,963,954,959]++"subdir1",
748
[{regular,[956,965,963,954,959]++"subfil1","���subfil1"}]}].
750
%% Some OS'es simply do not allow non UTF8 filenames
754
binary_to_list(procentify(Bin));
761
% Handle windows having absolute soft link targets.
762
fixlink({ok,Link}) ->
765
{ok,filename:basename(Link)};
774
procentify(<<X:8,Rst/binary>>) when X > 127 ->
776
Y = list_to_binary([$%
777
| io_lib:format("~2.16B",[X])]),
778
<<Y/binary,T/binary>>;
779
procentify(<<X:8,Rst/binary>>) ->
786
list([{_,Name,_} | T]) ->
791
case lists:keysearch(FN,2,List) of
792
{value,{regular,FN,C}} ->
794
{value,{symlink,FN,NewFN}} ->
795
get_data(NewFN,List);
802
convlist(file:native_name_encoding(),L).
803
convlist(latin1,[Bin|T]) when is_binary(Bin) ->
804
%erlang:display('Convert...'),
805
[binary_to_list(Bin)| convlist(latin1,T)];
806
convlist(Any,[H|T]) ->
812
NoUniMode = file:native_name_encoding() =:= latin1,
814
NoUniMode, is_binary(L) ->
821
rand_comp_decomp(Max) ->
822
N = random:uniform(Max),
823
L = [ rand_decomp() || _ <- lists:seq(1,N) ],
824
LC = [ A || {A,_} <- L],
825
LD = lists:flatten([B || {_,B} <- L]),
826
LB = unicode:characters_to_binary(LD,unicode,utf8),
832
element(random:uniform(SZ),BT).
853
{7873,[101,770,768]},
854
{7891,[111,770,768]},
857
{7701,[101,772,768]},
858
{7761,[111,772,768]},
863
{8146,[953,776,768]},
864
{8162,[965,776,768]},
865
{8074,[913,837,787,768]},
866
{8090,[919,837,787,768]},
867
{8106,[937,837,787,768]},
868
{8066,[945,837,787,768]},
869
{8082,[951,837,787,768]},
870
{8098,[969,837,787,768]},
871
{7946,[913,787,768]},
872
{7962,[917,787,768]},
873
{7978,[919,787,768]},
874
{7994,[921,787,768]},
875
{8010,[927,787,768]},
876
{8042,[937,787,768]},
877
{7938,[945,787,768]},
878
{7954,[949,787,768]},
879
{7970,[951,787,768]},
880
{7986,[953,787,768]},
881
{8002,[959,787,768]},
882
{8018,[965,787,768]},
883
{8034,[969,787,768]},
884
{8075,[913,837,788,768]},
885
{8091,[919,837,788,768]},
886
{8107,[937,837,788,768]},
887
{8067,[945,837,788,768]},
888
{8083,[951,837,788,768]},
889
{8099,[969,837,788,768]},
890
{7947,[913,788,768]},
891
{7963,[917,788,768]},
892
{7979,[919,788,768]},
893
{7995,[921,788,768]},
894
{8011,[927,788,768]},
895
{8027,[933,788,768]},
896
{8043,[937,788,768]},
897
{7939,[945,788,768]},
898
{7955,[949,788,768]},
899
{7971,[951,788,768]},
900
{7987,[953,788,768]},
901
{8003,[959,788,768]},
902
{8019,[965,788,768]},
903
{8035,[969,788,768]},
906
{7901,[111,795,768]},
907
{7915,[117,795,768]},
908
{8114,[945,837,768]},
909
{8130,[951,837,768]},
910
{8178,[969,837,768]},
970
{7871,[101,770,769]},
971
{7889,[111,770,769]},
974
{7757,[111,771,769]},
975
{7801,[117,771,769]},
978
{7703,[101,772,769]},
979
{7763,[111,772,769]},
984
{7727,[105,776,769]},
986
{8147,[953,776,769]},
987
{8163,[965,776,769]},
990
{8076,[913,837,787,769]},
991
{8092,[919,837,787,769]},
992
{8108,[937,837,787,769]},
993
{8068,[945,837,787,769]},
994
{8084,[951,837,787,769]},
995
{8100,[969,837,787,769]},
996
{7948,[913,787,769]},
997
{7964,[917,787,769]},
998
{7980,[919,787,769]},
999
{7996,[921,787,769]},
1000
{8012,[927,787,769]},
1001
{8044,[937,787,769]},
1002
{7940,[945,787,769]},
1003
{7956,[949,787,769]},
1004
{7972,[951,787,769]},
1005
{7988,[953,787,769]},
1006
{8004,[959,787,769]},
1007
{8020,[965,787,769]},
1008
{8036,[969,787,769]},
1009
{8077,[913,837,788,769]},
1010
{8093,[919,837,788,769]},
1011
{8109,[937,837,788,769]},
1012
{8069,[945,837,788,769]},
1013
{8085,[951,837,788,769]},
1014
{8101,[969,837,788,769]},
1015
{7949,[913,788,769]},
1016
{7965,[917,788,769]},
1017
{7981,[919,788,769]},
1018
{7997,[921,788,769]},
1019
{8013,[927,788,769]},
1020
{8029,[933,788,769]},
1021
{8045,[937,788,769]},
1022
{7941,[945,788,769]},
1023
{7957,[949,788,769]},
1024
{7973,[951,788,769]},
1025
{7989,[953,788,769]},
1026
{8005,[959,788,769]},
1027
{8021,[965,788,769]},
1028
{8037,[969,788,769]},
1029
{7898,[79,795,769]},
1030
{7912,[85,795,769]},
1031
{7899,[111,795,769]},
1032
{7913,[117,795,769]},
1033
{7688,[67,807,769]},
1034
{7689,[99,807,769]},
1035
{8116,[945,837,769]},
1036
{8132,[951,837,769]},
1037
{8180,[959,837,769]},
1084
{7852,[65,803,770]},
1085
{7878,[69,803,770]},
1086
{7896,[79,803,770]},
1087
{7853,[97,803,770]},
1088
{7879,[101,803,770]},
1089
{7897,[111,803,770]},
1106
{7850,[65,770,771]},
1107
{7876,[69,770,771]},
1108
{7894,[79,770,771]},
1109
{7851,[97,770,771]},
1110
{7877,[101,770,771]},
1111
{7895,[111,770,771]},
1112
{7860,[65,774,771]},
1113
{7861,[97,774,771]},
1114
{7904,[79,795,771]},
1115
{7918,[85,795,771]},
1116
{7905,[111,795,771]},
1117
{7919,[117,795,771]},
1137
{470,[117,776,772]},
1138
{7736,[76,803,772]},
1139
{7772,[82,803,772]},
1140
{7737,[108,803,772]},
1141
{7773,[114,803,772]},
1143
{493,[111,808,772]},
1166
{7862,[65,803,774]},
1167
{7863,[97,803,774]},
1168
{7708,[69,807,774]},
1169
{7709,[101,807,774]},
1222
{7780,[83,769,775]},
1223
{7781,[115,769,775]},
1225
{7782,[83,780,775]},
1226
{7783,[115,780,775]},
1227
{7784,[83,803,775]},
1228
{7785,[115,803,775]},
1252
{7758,[79,771,776]},
1253
{7759,[111,771,776]},
1254
{7802,[85,772,776]},
1255
{7803,[117,772,776]},
1293
{7848,[65,770,777]},
1294
{7874,[69,770,777]},
1295
{7892,[79,770,777]},
1296
{7849,[97,770,777]},
1297
{7875,[101,770,777]},
1298
{7893,[111,770,777]},
1299
{7858,[65,774,777]},
1300
{7859,[97,774,777]},
1301
{7902,[79,795,777]},
1302
{7916,[85,795,777]},
1303
{7903,[111,795,777]},
1304
{7917,[117,795,777]},
1351
{474,[117,776,780]},
1353
{912,[953,776,781]},
1354
{944,[965,776,781]},
1396
{8072,[913,837,787]},
1397
{8088,[919,837,787]},
1398
{8104,[937,837,787]},
1399
{8064,[945,837,787]},
1400
{8080,[951,837,787]},
1401
{8096,[969,837,787]},
1416
{8073,[913,837,788]},
1417
{8089,[919,837,788]},
1418
{8105,[937,837,788]},
1419
{8065,[945,837,788]},
1420
{8081,[951,837,788]},
1421
{8097,[969,837,788]},
1480
{7906,[79,795,803]},
1481
{7920,[85,795,803]},
1482
{7907,[111,795,803]},
1483
{7921,[117,795,803]},
1556
{8151,[953,776,834]},
1557
{8167,[965,776,834]},
1558
{8078,[913,837,787,834]},
1559
{8094,[919,837,787,834]},
1560
{8110,[937,837,787,834]},
1561
{8070,[945,837,787,834]},
1562
{8086,[951,837,787,834]},
1563
{8102,[969,837,787,834]},
1564
{7950,[913,787,834]},
1565
{7982,[919,787,834]},
1566
{7998,[921,787,834]},
1567
{8046,[937,787,834]},
1568
{7942,[945,787,834]},
1569
{7974,[951,787,834]},
1570
{7990,[953,787,834]},
1571
{8022,[965,787,834]},
1572
{8038,[969,787,834]},
1573
{8079,[913,837,788,834]},
1574
{8095,[919,837,788,834]},
1575
{8111,[937,837,788,834]},
1576
{8071,[945,837,788,834]},
1577
{8087,[951,837,788,834]},
1578
{8103,[969,837,788,834]},
1579
{7951,[913,788,834]},
1580
{7983,[919,788,834]},
1581
{7999,[921,788,834]},
1582
{8031,[933,788,834]},
1583
{8047,[937,788,834]},
1584
{7943,[945,788,834]},
1585
{7975,[951,788,834]},
1586
{7991,[953,788,834]},
1587
{8023,[965,788,834]},
1588
{8039,[969,788,834]},
1589
{8119,[945,837,834]},
1590
{8135,[951,837,834]},
1591
{8183,[969,837,834]},
1605
{64302,[1488,1463]},
1606
{64287,[1522,1463]},
1607
{64303,[1488,1464]},
1608
{64331,[1493,1465]},
1609
{64304,[1488,1468]},
1610
{64305,[1489,1468]},
1611
{64306,[1490,1468]},
1612
{64307,[1491,1468]},
1613
{64308,[1492,1468]},
1614
{64309,[1493,1468]},
1615
{64310,[1494,1468]},
1616
{64312,[1496,1468]},
1617
{64313,[1497,1468]},
1618
{64314,[1498,1468]},
1619
{64315,[1499,1468]},
1620
{64316,[1500,1468]},
1621
{64318,[1502,1468]},
1622
{64320,[1504,1468]},
1623
{64321,[1505,1468]},
1624
{64323,[1507,1468]},
1625
{64324,[1508,1468]},
1626
{64326,[1510,1468]},
1627
{64327,[1511,1468]},
1628
{64328,[1512,1468]},
1629
{64329,[1513,1468]},
1630
{64330,[1514,1468]},
1631
{64332,[1489,1471]},
1632
{64333,[1499,1471]},
1633
{64334,[1508,1471]},
1634
{64300,[1513,1468,1473]},
1635
{64298,[1513,1473]},
1636
{64301,[1513,1468,1474]},
1637
{64299,[1513,1474]},
1673
{3275,[3270,3266,3285]},
1683
{3959,[4018,3968,3953]},
1684
{3961,[4019,3968,3953]},
1699
{12436,[12358,12441]},
1700
{12364,[12363,12441]},
1701
{12366,[12365,12441]},
1702
{12368,[12367,12441]},
1703
{12370,[12369,12441]},
1704
{12372,[12371,12441]},
1705
{12374,[12373,12441]},
1706
{12376,[12375,12441]},
1707
{12378,[12377,12441]},
1708
{12380,[12379,12441]},
1709
{12382,[12381,12441]},
1710
{12384,[12383,12441]},
1711
{12386,[12385,12441]},
1712
{12389,[12388,12441]},
1713
{12391,[12390,12441]},
1714
{12393,[12392,12441]},
1715
{12400,[12399,12441]},
1716
{12403,[12402,12441]},
1717
{12406,[12405,12441]},
1718
{12409,[12408,12441]},
1719
{12412,[12411,12441]},
1720
{12446,[12445,12441]},
1721
{12532,[12454,12441]},
1722
{12460,[12459,12441]},
1723
{12462,[12461,12441]},
1724
{12464,[12463,12441]},
1725
{12466,[12465,12441]},
1726
{12468,[12467,12441]},
1727
{12470,[12469,12441]},
1728
{12472,[12471,12441]},
1729
{12474,[12473,12441]},
1730
{12476,[12475,12441]},
1731
{12478,[12477,12441]},
1732
{12480,[12479,12441]},
1733
{12482,[12481,12441]},
1734
{12485,[12484,12441]},
1735
{12487,[12486,12441]},
1736
{12489,[12488,12441]},
1737
{12496,[12495,12441]},
1738
{12499,[12498,12441]},
1739
{12502,[12501,12441]},
1740
{12505,[12504,12441]},
1741
{12508,[12507,12441]},
1742
{12535,[12527,12441]},
1743
{12536,[12528,12441]},
1744
{12537,[12529,12441]},
1745
{12538,[12530,12441]},
1746
{12542,[12541,12441]},
1747
{12401,[12399,12442]},
1748
{12404,[12402,12442]},
1749
{12407,[12405,12442]},
1750
{12410,[12408,12442]},
1751
{12413,[12411,12442]},
1752
{12497,[12495,12442]},
1753
{12500,[12498,12442]},
1754
{12503,[12501,12442]},
1755
{12506,[12504,12442]},
1756
{12509,[12507,12442]}}.