1# This file tests the tclWinFCmd.c file.
2#
3# This file contains a collection of tests for one or more of the Tcl
4# built-in commands.  Sourcing this file into Tcl runs the tests and
5# generates output for errors.  No output means no errors were found.
6#
7# Copyright © 1996-1997 Sun Microsystems, Inc.
8# Copyright © 1998-1999 Scriptics Corporation.
9#
10# See the file "license.terms" for information on usage and redistribution
11# of this file, and for a DISCLAIMER OF ALL WARRANTIES.
12
13if {"::tcltest" ni [namespace children]} {
14    package require tcltest 2.5
15    namespace import -force ::tcltest::*
16}
17
18::tcltest::loadTestedCommands
19catch [list package require -exact tcl::test [info patchlevel]]
20
21# Initialise the test constraints
22
23testConstraint testvolumetype [llength [info commands testvolumetype]]
24testConstraint testfile       [llength [info commands testfile]]
25testConstraint testchmod      [llength [info commands testchmod]]
26testConstraint cdrom 0
27testConstraint exdev 0
28testConstraint longFileNames 0
29# Some things fail under all Continuous Integration systems for subtle reasons
30# such as CI often running with elevated privileges in a container.
31testConstraint notInCIenv     [expr {![info exists ::env(CI)]}]
32testConstraint knownMsvcBug   [expr {![info exists ::env(CI_BUILD_WITH_MSVC)]}]
33
34proc createfile {file {string a}} {
35    set f [open $file w]
36    puts -nonewline $f $string
37    close $f
38    return $string
39}
40
41proc contents {file} {
42    set f [open $file r]
43    set r [read $f]
44    close $f
45    set r
46}
47
48proc cleanup {args} {
49    foreach p ". $args" {
50	set x ""
51	catch {
52	    set x [glob -directory $p tf* td*]
53	}
54	if {$x != ""} {
55	    catch {file delete -force -- {*}$x}
56	}
57    }
58}
59
60# find a CD-ROM so we can test read-only filesystems.
61
62proc findfile {dir} {
63    foreach p [glob -nocomplain -type f -directory $dir *] {
64	return $p
65    }
66    foreach p [glob -nocomplain -type d -directory $dir *] {
67	set f [findfile $p]
68	if {$f ne ""} {
69	    return $f
70	}
71    }
72    return ""
73}
74
75if {[testConstraint testvolumetype]} {
76    foreach p {d e f g h i j k l m n o p q r s t u v w x y z} {
77        if {![catch {testvolumetype ${p}:} result] && $result in {CDFS UDF}} {
78            set cdrom ${p}:
79	    set cdfile [findfile $cdrom]
80	    testConstraint cdrom 1
81	    break
82        }
83    }
84}
85
86# NB: filename is chosen to be short but unlikely to clash with other apps
87if {[file exists c:/] && [file exists d:/]} {
88    catch {file delete d:/TclTmpF.1}
89    catch {file delete d:/TclTmpD.1}
90    catch {file delete c:/TclTmpC.1}
91    if {![catch {createfile d:/TclTmpF.1 {}}] && [file isfile d:/TclTmpF.1]
92	&& ![catch {file mkdir d:/TclTmpD.1}] && [file isdirectory d:/TclTmpD.1]
93	&& ![catch {file mkdir c:/TclTmpC.1}] && [file isdirectory c:/TclTmpC.1]
94    } {
95	file delete d:/TclTmpF.1 d:/TclTmpD.1 c:/TclTmpC.1
96	testConstraint exdev 1
97    }
98}
99
100file delete -force -- td1
101if {![catch {open td1 w} testfile]} {
102    close $testfile
103    testConstraint longFileNames 1
104    file delete -force -- td1
105}
106
107# A really long file name
108# length of longname is 1216 chars, which should be greater than any static
109# buffer or allowable filename.
110
111set longname "abcdefghihjllmnopqrstuvwxyz01234567890"
112append longname $longname
113append longname $longname
114append longname $longname
115append longname $longname
116append longname $longname
117
118# Uses the "testfile" command instead of the "file" command.  The "file"
119# command provides several layers of sanity checks on the arguments and
120# it can be difficult to actually forward "insane" arguments to the
121# low-level posix emulation layer.
122
123test winFCmd-1.1 {TclpRenameFile: errno: EACCES} -body {
124    testfile mv $cdfile $cdrom/dummy~~.fil
125} -constraints {win cdrom testfile} -returnCodes error -result EACCES
126test winFCmd-1.2 {TclpRenameFile: errno: EEXIST} -setup {
127    cleanup
128} -constraints {win testfile notInCIenv} -body {
129    file mkdir td1/td2/td3
130    file mkdir td2
131    testfile mv td2 td1/td2
132} -returnCodes error -result EEXIST
133test winFCmd-1.3 {TclpRenameFile: errno: EINVAL} -setup {
134    cleanup
135} -constraints {win testfile notInCIenv} -body {
136    testfile mv / td1
137} -returnCodes error -result EINVAL
138test winFCmd-1.4 {TclpRenameFile: errno: EINVAL} -setup {
139    cleanup
140} -constraints {win testfile notInCIenv} -body {
141    file mkdir td1
142    testfile mv td1 td1/td2
143} -returnCodes error -result EINVAL
144test winFCmd-1.5 {TclpRenameFile: errno: EISDIR} -setup {
145    cleanup
146} -constraints {win testfile notInCIenv} -body {
147    file mkdir td1
148    createfile tf1
149    testfile mv tf1 td1
150} -returnCodes error -result EISDIR
151test winFCmd-1.6 {TclpRenameFile: errno: ENOENT} -setup {
152    cleanup
153} -constraints {win testfile} -body {
154    testfile mv tf1 tf2
155} -returnCodes error -result ENOENT
156test winFCmd-1.7 {TclpRenameFile: errno: ENOENT} -setup {
157    cleanup
158} -constraints {win testfile} -body {
159    testfile mv "" tf2
160} -returnCodes error -result ENOENT
161test winFCmd-1.8 {TclpRenameFile: errno: ENOENT} -setup {
162    cleanup
163} -constraints {win testfile} -body {
164    createfile tf1
165    testfile mv tf1 ""
166} -returnCodes error -result ENOENT
167test winFCmd-1.9 {TclpRenameFile: errno: ENOTDIR} -setup {
168    cleanup
169} -constraints {win testfile} -body {
170    file mkdir td1
171    createfile tf1
172    testfile mv td1 tf1
173} -returnCodes error -result ENOTDIR
174test winFCmd-1.10 {TclpRenameFile: errno: EXDEV} -setup {
175    file delete -force d:/TclTmpD.1
176} -constraints {win exdev testfile} -body {
177    file mkdir c:/TclTmpC.1
178    testfile mv c:/TclTmpC.1 d:/TclTmpD.1
179} -cleanup {
180    file delete -force c:/TclTmpC.1
181} -returnCodes error -result EXDEV
182test winFCmd-1.11 {TclpRenameFile: errno: EACCES} -setup {
183    cleanup
184} -constraints {win testfile} -body {
185    set fd [open tf1 w]
186    testfile mv tf1 tf2
187} -cleanup {
188    catch {close $fd}
189} -returnCodes error -result EACCES
190test winFCmd-1.12 {TclpRenameFile: errno: EACCES} -setup {
191    cleanup
192} -constraints {win testfile} -body {
193    createfile tf1
194    set fd [open tf2 w]
195    testfile mv tf1 tf2
196} -cleanup {
197    catch {close $fd}
198} -returnCodes error -result EACCES
199test winFCmd-1.15 {TclpRenameFile: errno: EEXIST} -setup {
200    cleanup
201} -constraints {win testfile} -body {
202    createfile tf1
203    testfile mv tf1 nul
204} -returnCodes error -result EEXIST
205test winFCmd-1.16 {TclpRenameFile: MoveFile() != FALSE} -setup {
206    cleanup
207} -constraints {win testfile} -body {
208    createfile tf1 tf1
209    testfile mv tf1 tf2
210    list [file exists tf1] [contents tf2]
211} -result {0 tf1}
212test winFCmd-1.17 {TclpRenameFile: MoveFile() == FALSE} -setup {
213    cleanup
214} -constraints {win testfile} -body {
215    testfile mv tf1 tf2
216} -returnCodes error -result ENOENT
217test winFCmd-1.18 {TclpRenameFile: srcAttr == -1} -setup {
218    cleanup
219} -constraints {win testfile} -body {
220    testfile mv tf1 tf2
221} -returnCodes error -result ENOENT
222test winFCmd-1.20 {TclpRenameFile: src is dir} -setup {
223    cleanup
224} -constraints {win testfile} -body {
225    file delete /tf1
226    testfile mv [pwd] /tf1
227} -returnCodes error -result EACCES
228test winFCmd-1.21 {TclpRenameFile: long src} -setup {
229    cleanup
230} -constraints {win testfile} -body {
231    testfile mv $longname tf1
232} -returnCodes error -result ENAMETOOLONG
233test winFCmd-1.22 {TclpRenameFile: long dst} -setup {
234    cleanup
235} -constraints {win testfile} -body {
236    createfile tf1
237    testfile mv tf1 $longname
238} -returnCodes error -result ENAMETOOLONG
239test winFCmd-1.23 {TclpRenameFile: move dir into self} -setup {
240    cleanup
241} -constraints {win testfile notInCIenv} -body {
242    file mkdir td1
243    testfile mv [pwd]/td1 td1/td2
244} -returnCodes error -result EINVAL
245test winFCmd-1.24 {TclpRenameFile: move a root dir} -setup {
246    cleanup
247} -constraints {win testfile} -body {
248    testfile mv / c:/
249} -returnCodes error -result EINVAL
250test winFCmd-1.25 {TclpRenameFile: cross file systems} -setup {
251    cleanup
252} -constraints {win cdrom testfile} -body {
253    file mkdir td1
254    testfile mv td1 $cdrom/td1
255} -returnCodes error -result EXDEV
256test winFCmd-1.26 {TclpRenameFile: readonly fs} -setup {
257    cleanup
258} -constraints {win cdrom testfile} -body {
259    testfile mv $cdfile $cdrom/dummy~~.fil
260} -returnCodes error -result EACCES
261test winFCmd-1.27 {TclpRenameFile: open file} -setup {
262    cleanup
263} -constraints {win testfile} -body {
264    set fd [open tf1 w]
265    testfile mv tf1 tf2
266} -cleanup {
267    catch {close $fd}
268} -returnCodes error -result EACCES
269test winFCmd-1.28 {TclpRenameFile: errno == EEXIST} -setup {
270    cleanup
271} -constraints {win testfile} -body {
272    createfile tf1
273    createfile tf2
274    testfile mv tf1 tf2
275    list [file exists tf1] [file exists tf2]
276} -result {0 1}
277test winFCmd-1.29 {TclpRenameFile: src is dir} -setup {
278    cleanup
279} -constraints {win testfile} -body {
280    file mkdir td1
281    createfile tf1
282    testfile mv td1 tf1
283} -returnCodes error -result ENOTDIR
284test winFCmd-1.30 {TclpRenameFile: dst is dir} -setup {
285    cleanup
286} -constraints {win testfile notInCIenv} -body {
287    file mkdir td1
288    file mkdir td2/td2
289    testfile mv td1 td2
290} -returnCodes error -result EEXIST
291test winFCmd-1.31 {TclpRenameFile: TclpRemoveDirectory fails} -setup {
292    cleanup
293} -constraints {win testfile notInCIenv} -body {
294    file mkdir td1
295    file mkdir td2/td2
296    testfile mv td1 td2
297} -returnCodes error -result EEXIST
298test winFCmd-1.32 {TclpRenameFile: TclpRemoveDirectory succeeds} -setup {
299    cleanup
300} -constraints {win testfile notInCIenv} -body {
301    file mkdir td1/td2
302    file mkdir td2
303    testfile mv td1 td2
304    list [file exists td1] [file exists td2] [file exists td2/td2]
305} -result {0 1 1}
306test winFCmd-1.33 {TclpRenameFile: After removing dst dir, MoveFile fails} \
307	-constraints {win exdev testfile testchmod} -body {
308    file mkdir d:/TclTmpD.1
309    testchmod 0 d:/TclTmpD.1
310    file mkdir c:/TclTmpC.1
311    catch {testfile mv c:/TclTmpC.1 d:/TclTmpD.1} msg
312    list $msg [file writable d:/TclTmpD.1]
313} -cleanup {
314    catch {testchmod 0o666 d:/TclTmpD.1}
315    file delete d:/TclTmpD.1
316    file delete -force c:/TclTmpC.1
317} -result {EXDEV 0}
318test winFCmd-1.34 {TclpRenameFile: src is dir, dst is not} -setup {
319    cleanup
320} -constraints {win testfile} -body {
321    file mkdir td1
322    createfile tf1
323    testfile mv td1 tf1
324} -cleanup {
325    cleanup
326} -returnCodes error -result ENOTDIR
327test winFCmd-1.35 {TclpRenameFile: src is not dir, dst is} -setup {
328    cleanup
329} -constraints {win testfile notInCIenv} -body {
330    file mkdir td1
331    createfile tf1
332    testfile mv tf1 td1
333} -cleanup {
334    cleanup
335} -returnCodes error -result EISDIR
336test winFCmd-1.36 {TclpRenameFile: src and dst not dir} -setup {
337    cleanup
338} -constraints {win testfile} -body {
339    createfile tf1 tf1
340    createfile tf2 tf2
341    testfile mv tf1 tf2
342    contents tf2
343} -cleanup {
344    cleanup
345} -result {tf1}
346test winFCmd-1.37 {TclpRenameFile: need to restore temp file} {win emptyTest} {
347    # Can't figure out how to cause this.
348    # Need a file that can't be copied.
349} {}
350
351# If the native filesystem produces 0 for inodes numbers there is no point
352# doing the following test.
353testConstraint winNonZeroInodes [eval {
354    file stat [info nameofexecutable] statExe
355    expr {$statExe(ino) != 0}
356}]
357
358proc MakeFiles {dirname} {
359    set inodes {}
360    set ndx -1
361    while {1} {
362        # upped to 50K for 64bit Server 2008
363        if {$ndx > 50000} {
364            return -code error "limit reached without finding a collistion."
365        }
366        set filename [file join $dirname Test[incr ndx]]
367        set f [open $filename w]
368        close $f
369        file stat $filename stat
370        if {[set n [lsearch -exact -integer $inodes $stat(ino)]] >= 0} {
371            return [list [file join $dirname Test$n] $filename]
372        }
373        lappend inodes $stat(ino)
374        unset stat
375    }
376}
377
378test winFCmd-1.38 {TclpRenameFile: check rename of conflicting inodes} -setup {
379    cleanup
380} -constraints {win winNonZeroInodes knownMsvcBug notInCIenv} -body {
381    file mkdir td1
382    foreach {a b} [MakeFiles td1] break
383    file rename -force $a $b
384    file exists $a
385} -cleanup {
386    cleanup
387} -result {0}
388
389
390test winFCmd-2.1 {TclpCopyFile: errno: EACCES} -setup {
391    cleanup
392} -constraints {win cdrom testfile} -body {
393    testfile cp $cdfile $cdrom/dummy~~.fil
394} -returnCodes error -result EACCES
395test winFCmd-2.2 {TclpCopyFile: errno: EISDIR} -setup {
396    cleanup
397} -constraints {win testfile} -body {
398    file mkdir td1
399    testfile cp td1 tf1
400} -cleanup {
401    cleanup
402} -returnCodes error -result EISDIR
403test winFCmd-2.3 {TclpCopyFile: errno: EISDIR} -setup {
404    cleanup
405} -constraints {win testfile} -body {
406    createfile tf1
407    file mkdir td1
408    testfile cp tf1 td1
409} -cleanup {
410    cleanup
411} -returnCodes error -result EISDIR
412test winFCmd-2.4 {TclpCopyFile: errno: ENOENT} -setup {
413    cleanup
414} -constraints {win testfile} -body {
415    testfile cp tf1 tf2
416} -returnCodes error -result ENOENT
417test winFCmd-2.5 {TclpCopyFile: errno: ENOENT} -setup {
418    cleanup
419} -constraints {win testfile} -body {
420    testfile cp "" tf2
421} -returnCodes error -result ENOENT
422test winFCmd-2.6 {TclpCopyFile: errno: ENOENT} -setup {
423    cleanup
424} -constraints {win testfile} -body {
425    createfile tf1
426    testfile cp tf1 ""
427} -cleanup {
428    cleanup
429} -returnCodes error -result ENOENT
430test winFCmd-2.10 {TclpCopyFile: CopyFile succeeds} -setup {
431    cleanup
432} -constraints {win testfile} -body {
433    createfile tf1 tf1
434    testfile cp tf1 tf2
435    list [contents tf1] [contents tf2]
436} -cleanup {
437    cleanup
438} -result {tf1 tf1}
439test winFCmd-2.11 {TclpCopyFile: CopyFile succeeds} -setup {
440    cleanup
441} -constraints {win testfile} -body {
442    createfile tf1 tf1
443    createfile tf2 tf2
444    testfile cp tf1 tf2
445    list [contents tf1] [contents tf2]
446} -cleanup {
447    cleanup
448} -result {tf1 tf1}
449test winFCmd-2.12 {TclpCopyFile: CopyFile succeeds} -setup {
450    cleanup
451} -constraints {win testfile} -body {
452    createfile tf1 tf1
453    testchmod 0 tf1
454    testfile cp tf1 tf2
455    list [contents tf2] [file writable tf2]
456} -cleanup {
457    catch {testchmod 0o666 tf1}
458    cleanup
459} -result {tf1 0}
460test winFCmd-2.13 {TclpCopyFile: CopyFile fails} -setup {
461    cleanup
462} -constraints {win testfile} -body {
463    createfile tf1
464    file mkdir td1
465    testfile cp tf1 td1
466} -cleanup {
467    cleanup
468} -returnCodes error -result EISDIR
469test winFCmd-2.14 {TclpCopyFile: errno == EACCES} -setup {
470    cleanup
471} -constraints {win testfile} -body {
472    file mkdir td1
473    testfile cp td1 tf1
474} -cleanup {
475    cleanup
476} -returnCodes error -result EISDIR
477test winFCmd-2.15 {TclpCopyFile: src is directory} -setup {
478    cleanup
479} -constraints {win testfile} -body {
480    file mkdir td1
481    testfile cp td1 tf1
482} -cleanup {
483    cleanup
484} -returnCodes error -result EISDIR
485test winFCmd-2.16 {TclpCopyFile: dst is directory} -setup {
486    cleanup
487} -constraints {win testfile} -body {
488    createfile tf1
489    file mkdir td1
490    testfile cp tf1 td1
491} -cleanup {
492    cleanup
493} -returnCodes error -result EISDIR
494test winFCmd-2.17 {TclpCopyFile: dst is readonly} -setup {
495    cleanup
496} -constraints {win testfile testchmod} -body {
497    createfile tf1 tf1
498    createfile tf2 tf2
499    testchmod 0 tf2
500    testfile cp tf1 tf2
501    list [file writable tf2] [contents tf2]
502} -cleanup {
503    catch {testchmod 0o666 tf2}
504    cleanup
505} -result {1 tf1}
506
507test winFCmd-3.1 {TclpDeleteFile: errno: EACCES} -body {
508    testfile rm $cdfile $cdrom/dummy~~.fil
509} -constraints {win cdrom testfile} -returnCodes error -result EACCES
510test winFCmd-3.2 {TclpDeleteFile: errno: EISDIR} -setup {
511    cleanup
512} -constraints {win testfile} -body {
513    file mkdir td1
514    testfile rm td1
515} -cleanup {
516    cleanup
517} -returnCodes error -result EISDIR
518test winFCmd-3.3 {TclpDeleteFile: errno: ENOENT} -setup {
519    cleanup
520} -constraints {win testfile} -body {
521    testfile rm tf1
522} -returnCodes error -result ENOENT
523test winFCmd-3.4 {TclpDeleteFile: errno: ENOENT} -setup {
524    cleanup
525} -constraints {win testfile} -body {
526    testfile rm ""
527} -returnCodes error -result ENOENT
528test winFCmd-3.5 {TclpDeleteFile: errno: EACCES} -setup {
529    cleanup
530} -constraints {win testfile} -body {
531    set fd [open tf1 w]
532    testfile rm tf1
533} -cleanup {
534    close $fd
535    cleanup
536} -returnCodes error -result EACCES
537test winFCmd-3.6 {TclpDeleteFile: errno: EACCES} -setup {
538    cleanup
539} -constraints {win testfile} -body {
540    testfile rm nul
541} -returnCodes error -result EACCES
542test winFCmd-3.7 {TclpDeleteFile: DeleteFile succeeds} -setup {
543    cleanup
544} -constraints {win testfile} -body {
545    createfile tf1
546    testfile rm tf1
547    file exists tf1
548} -result {0}
549test winFCmd-3.8 {TclpDeleteFile: DeleteFile fails} -setup {
550    cleanup
551} -constraints {win testfile} -body {
552    file mkdir td1
553    testfile rm td1
554} -cleanup {
555    cleanup
556} -returnCodes error -result EISDIR
557test winFCmd-3.9 {TclpDeleteFile: errno == EACCES} -setup {
558    cleanup
559} -constraints {win testfile} -body {
560    set fd [open tf1 w]
561    testfile rm tf1
562} -cleanup {
563    close $fd
564} -returnCodes error -result EACCES
565test winFCmd-3.10 {TclpDeleteFile: path is readonly} -setup {
566    cleanup
567} -constraints {win testfile testchmod} -body {
568    createfile tf1
569    testchmod 0 tf1
570    testfile rm tf1
571    file exists tf1
572} -result {0}
573test winFCmd-3.11 {TclpDeleteFile: still can't remove path} -setup {
574    cleanup
575} -constraints {win testfile testchmod} -body {
576    set fd [open tf1 w]
577    testchmod 0 tf1
578    testfile rm tf1
579} -cleanup {
580    close $fd
581    catch {testchmod 0o666 tf1}
582    cleanup
583} -returnCodes error -result EACCES
584
585test winFCmd-4.1 {TclpCreateDirectory: errno: EACCES} -body {
586    testfile mkdir $cdrom/dummy~~.dir
587} -constraints {win cdrom testfile} -returnCodes error -result EACCES
588test winFCmd-4.3 {TclpCreateDirectory: errno: EEXIST} -setup {
589    cleanup
590} -constraints {win testfile} -body {
591    file mkdir td1
592    testfile mkdir td1
593} -cleanup {
594    cleanup
595} -returnCodes error -result EEXIST
596test winFCmd-4.4 {TclpCreateDirectory: errno: ENOENT} -setup {
597    cleanup
598} -constraints {win testfile} -body {
599    testfile mkdir td1/td2
600} -returnCodes error -result ENOENT
601test winFCmd-4.5 {TclpCreateDirectory: CreateDirectory succeeds} -setup {
602    cleanup
603} -constraints {win testfile} -body {
604    testfile mkdir td1
605    file type td1
606} -cleanup cleanup -result directory
607
608test winFCmd-5.1 {TclpCopyDirectory: calls TraverseWinTree} -setup {
609    cleanup
610} -constraints {win testfile} -body {
611    file mkdir td1
612    testfile cpdir td1 td2
613    list [file type td1] [file type td2]
614} -cleanup {
615    cleanup
616} -result {directory directory}
617
618test winFCmd-6.1 {TclpRemoveDirectory: errno: EACCES} -setup {
619    cleanup
620} -constraints {win testfile testchmod knownMsvcBug notInCIenv} -body {
621    file mkdir td1
622    testchmod 0 td1
623    testfile rmdir td1
624    file exists td1
625} -returnCodes error -cleanup {
626    catch {testchmod 0o666 td1}
627    cleanup
628} -result {td1 EACCES}
629# This next test has a very hokey way of matching...
630test winFCmd-6.2 {TclpRemoveDirectory: errno: EEXIST} -setup {
631    cleanup
632} -constraints {win testfile} -body {
633    file mkdir td1/td2
634    list [catch {testfile rmdir td1} msg] [file tail $msg]
635} -result {1 {td1 EEXIST}}
636test winFCmd-6.3 {TclpRemoveDirectory: errno: EACCES} {win emptyTest} {
637    # can't test this w/o removing everything on your hard disk first!
638    # testfile rmdir /
639} {}
640# This next test has a very hokey way of matching...
641test winFCmd-6.4 {TclpRemoveDirectory: errno: ENOENT} -setup {
642    cleanup
643} -constraints {win testfile} -body {
644    list [catch {testfile rmdir td1} msg] [file tail $msg]
645} -result {1 {td1 ENOENT}}
646test winFCmd-6.5 {TclpRemoveDirectory: errno: ENOENT} -setup {
647    cleanup
648} -constraints {win testfile} -body {
649    testfile rmdir ""
650} -returnCodes error -result ENOENT
651# This next test has a very hokey way of matching...
652test winFCmd-6.6 {TclpRemoveDirectory: errno: ENOTDIR} -setup {
653    cleanup
654} -constraints {win testfile} -body {
655    createfile tf1
656    list [catch {testfile rmdir tf1} msg] [file tail $msg]
657} -result {1 {tf1 ENOTDIR}}
658test winFCmd-6.7 {TclpRemoveDirectory: RemoveDirectory succeeds} -setup {
659    cleanup
660} -constraints {win testfile} -body {
661    file mkdir td1
662    testfile rmdir td1
663    file exists td1
664} -result {0}
665# This next test has a very hokey way of matching...
666test winFCmd-6.8 {TclpRemoveDirectory: RemoveDirectory fails} -setup {
667    cleanup
668} -constraints {win testfile} -body {
669    createfile tf1
670    list [catch {testfile rmdir tf1} msg] [file tail $msg]
671} -result {1 {tf1 ENOTDIR}}
672test winFCmd-6.9 {TclpRemoveDirectory: errno == EACCES} -setup {
673    cleanup
674} -constraints {win testfile testchmod knownMsvcBug notInCIenv} -body {
675    file mkdir td1
676    testchmod 0 td1
677    testfile rmdir td1
678    file exists td1
679} -returnCodes error -cleanup {
680    catch {testchmod 0o666 td1}
681    cleanup
682} -result {td1 EACCES}
683test winFCmd-6.11 {TclpRemoveDirectory: attr == -1} -setup {
684    cleanup
685} -constraints {win testfile notInCIenv} -body {
686    testfile rmdir /
687    # WinXP returns EEXIST, WinNT seems to return EACCES.  No policy
688    # decision has been made as to which is correct.
689} -returnCodes error -match regexp -result {^/ E(ACCES|EXIST)$}
690test winFCmd-6.13 {TclpRemoveDirectory: write-protected} -setup {
691    cleanup
692} -constraints {win testfile testchmod knownMsvcBug notInCIenv} -body {
693    file mkdir td1
694    testchmod 0 td1
695    testfile rmdir td1
696    file exists td1
697} -cleanup {
698    catch {testchmod 0o666 td1}
699    cleanup
700} -returnCodes error -result {td1 EACCES}
701# This next test has a very hokey way of matching...
702test winFCmd-6.15 {TclpRemoveDirectory: !recursive} -setup {
703    cleanup
704} -constraints {win testfile} -body {
705    file mkdir td1/td2
706    list [catch {testfile rmdir td1} msg] [file tail $msg]
707} -result {1 {td1 EEXIST}}
708test winFCmd-6.16 {TclpRemoveDirectory: recursive, but errno != EEXIST} -setup {
709    cleanup
710} -constraints {win testfile} -body {
711    createfile tf1
712    testfile rmdir -force tf1
713} -returnCodes error -result {tf1 ENOTDIR}
714test winFCmd-6.17 {TclpRemoveDirectory: calls TraverseWinTree} -setup {
715    cleanup
716} -constraints {win testfile} -body {
717    file mkdir td1/td2
718    testfile rmdir -force td1
719    file exists td1
720} -result {0}
721
722test winFCmd-7.1 {TraverseWinTree: targetPtr == NULL} -setup {
723    cleanup
724} -constraints {win testfile} -body {
725    file mkdir td1/td2/td3
726    testfile rmdir -force td1
727    file exists td1
728} -result {0}
729test winFCmd-7.2 {TraverseWinTree: targetPtr != NULL} -setup {
730    cleanup
731} -constraints {win testfile} -body {
732    file mkdir td1/td2/td3
733    testfile cpdir td1 td2
734    list [file exists td1] [file exists td2]
735} -cleanup {
736    cleanup
737} -result {1 1}
738test winFCmd-7.3 {TraverseWinTree: sourceAttr == -1} -setup {
739    cleanup
740} -constraints {win testfile} -body {
741    testfile cpdir td1 td2
742} -returnCodes error -result {td1 ENOENT}
743test winFCmd-7.4 {TraverseWinTree: source isn't directory} -setup {
744    cleanup
745} -constraints {win testfile} -body {
746    file mkdir td1
747    createfile td1/tf1 tf1
748    testfile cpdir td1 td2
749    contents td2/tf1
750} -cleanup {
751    cleanup
752} -result {tf1}
753test winFCmd-7.5 {TraverseWinTree: call TraversalCopy: DOTREE_F} -setup {
754    cleanup
755} -constraints {win testfile} -body {
756    file mkdir td1
757    createfile td1/tf1 tf1
758    testfile cpdir td1 td2
759    contents td2/tf1
760} -cleanup {
761    cleanup
762} -result {tf1}
763test winFCmd-7.6 {TraverseWinTree: call TraversalDelete: DOTREE_F} -setup {
764    cleanup
765} -constraints {win testfile} -body {
766    file mkdir td1
767    createfile td1/tf1 tf1
768    testfile rmdir -force td1
769    file exists td1
770} -result {0}
771test winFCmd-7.7 {TraverseWinTree: append \ to source if necessary} -setup {
772    cleanup
773} -constraints {win testfile} -body {
774    file mkdir td1
775    createfile td1/tf1 tf1
776    testfile cpdir td1 td2
777    contents td2/tf1
778} -cleanup {
779    cleanup
780} -result {tf1}
781test winFCmd-7.9 {TraverseWinTree: append \ to source if necessary} -body {
782    testfile rmdir $cdrom/
783} -constraints {win cdrom testfile} -returnCodes error -match glob \
784    -result {* EACCES}
785test winFCmd-7.10 {TraverseWinTree: can't read directory: handle == INVALID} \
786	{win emptyTest} {
787    # can't make it happen
788} {}
789test winFCmd-7.11 {TraverseWinTree: call TraversalCopy: DOTREE_PRED} -setup {
790    cleanup
791} -constraints {win testfile testchmod} -body {
792    file mkdir td1
793    createfile td1/tf1 tf1
794    testchmod 0 td1
795    testfile cpdir td1 td2
796    list [file exists td2] [file writable td2]
797} -cleanup {
798    catch {testchmod 0o666 td1}
799    cleanup
800} -result {1 1}
801test winFCmd-7.12 {TraverseWinTree: call TraversalDelete: DOTREE_PRED} -setup {
802    cleanup
803} -constraints {win testfile} -body {
804    file mkdir td1
805    createfile td1/tf1 tf1
806    testfile rmdir -force td1
807    file exists td1
808} -result {0}
809test winFCmd-7.13 {TraverseWinTree: append \ to target if necessary} -setup {
810    cleanup
811} -constraints {win testfile} -body {
812    file mkdir td1
813    createfile td1/tf1 tf1
814    testfile cpdir td1 td2
815    contents td2/tf1
816} -cleanup {
817    cleanup
818} -result {tf1}
819test winFCmd-7.15 {TraverseWinTree: append \ to target if necessary} -setup {
820    cleanup
821} -constraints {win testfile} -body {
822    file mkdir td1
823    testfile cpdir td1 /
824} -cleanup {
825    cleanup
826    # Windows7 returns EEXIST, XP returns EACCES
827} -returnCodes error -match regexp -result {^/ E(ACCES|EXIST)$}
828test winFCmd-7.16 {TraverseWinTree: recurse on files: no files} -setup {
829    cleanup
830} -constraints {win testfile} -body {
831    file mkdir td1
832    testfile cpdir td1 td2
833} -cleanup {
834    cleanup
835} -result {}
836test winFCmd-7.17 {TraverseWinTree: recurse on files: one file} -setup {
837    cleanup
838} -constraints {win testfile} -body {
839    file mkdir td1
840    createfile td1/td2
841    testfile cpdir td1 td2
842    glob td2/*
843} -cleanup {
844    cleanup
845} -result {td2/td2}
846test winFCmd-7.18 {TraverseWinTree: recurse on files: several files and dir} -setup {
847    cleanup
848} -constraints {win testfile} -body {
849    file mkdir td1
850    createfile td1/tf1
851    createfile td1/tf2
852    file mkdir td1/td2/td3
853    createfile td1/tf3
854    createfile td1/tf4
855    testfile cpdir td1 td2
856    lsort [glob td2/*]
857} -cleanup {
858    cleanup
859} -result {td2/td2 td2/tf1 td2/tf2 td2/tf3 td2/tf4}
860test winFCmd-7.19 {TraverseWinTree: call TraversalCopy: DOTREE_POSTD} -setup {
861    cleanup
862} -constraints {win testfile testchmod} -body {
863    file mkdir td1
864    createfile td1/tf1 tf1
865    testchmod 0 td1
866    testfile cpdir td1 td2
867    list [file exists td2] [file writable td2]
868} -cleanup {
869    catch {testchmod 0o666 td1}
870    cleanup
871} -result {1 1}
872test winFCmd-7.20 {TraverseWinTree: call TraversalDelete: DOTREE_POSTD} -setup {
873    cleanup
874} -constraints {win testfile} -body {
875    file mkdir td1
876    createfile td1/tf1 tf1
877    testfile rmdir -force td1
878    file exists td1
879} -result {0}
880test winFCmd-7.21 {TraverseWinTree: fill errorPtr} -setup {
881    cleanup
882} -constraints {win testfile} -body {
883    testfile cpdir td1 td2
884} -returnCodes error -result {td1 ENOENT}
885
886test winFCmd-8.1 {TraversalCopy: DOTREE_F} -setup {
887    cleanup
888} -constraints {win testfile} -body {
889    file mkdir td1
890    testfile cpdir td1 td1
891} -returnCodes error -result {td1 EEXIST}
892test winFCmd-8.2 {TraversalCopy: DOTREE_PRED} -setup {
893    cleanup
894} -constraints {win testfile testchmod} -body {
895    file mkdir td1/td2
896    testchmod 0 td1
897    testfile cpdir td1 td2
898    list [file writable td1] [file writable td1/td2]
899} -cleanup {
900    catch {testchmod 0o666 td1}
901    cleanup
902} -result {0 1}
903test winFCmd-8.3 {TraversalCopy: DOTREE_POSTD} -setup {
904    cleanup
905} -constraints {win testfile} -body {
906    file mkdir td1
907    testfile cpdir td1 td2
908} -cleanup {
909    cleanup
910} -result {}
911
912test winFCmd-9.1 {TraversalDelete: DOTREE_F} -setup {
913    cleanup
914} -constraints {win testfile} -body {
915    file mkdir td1
916    createfile td1/tf1
917    testfile rmdir -force td1
918} -result {}
919test winFCmd-9.3 {TraversalDelete: DOTREE_PRED} -setup {
920    cleanup
921} -constraints {win testfile testchmod knownMsvcBug notInCIenv} -body {
922    file mkdir td1/td2
923    testchmod 0 td1
924    testfile rmdir -force td1
925    file exists td1
926} -cleanup {
927    catch {testchmod 0o666 td1}
928    cleanup
929} -returnCodes error -result {td1 EACCES}
930test winFCmd-9.4 {TraversalDelete: DOTREE_POSTD} -setup {
931    cleanup
932} -constraints {win testfile} -body {
933    file mkdir td1/td1/td3/td4/td5
934    testfile rmdir -force td1
935} -result {}
936
937test winFCmd-10.1 {AttributesPosixError - get} -constraints {win} -setup {
938    cleanup
939} -body {
940    file attributes td1 -archive
941} -returnCodes error -result {could not read "td1": no such file or directory}
942test winFCmd-10.2 {AttributesPosixError - set} -constraints {win} -setup {
943    cleanup
944} -body {
945    file attributes td1 -archive 0
946} -returnCodes error -result {could not read "td1": no such file or directory}
947
948test winFCmd-11.1 {GetWinFileAttributes} -constraints {win} -setup {
949    cleanup
950} -body {
951    createfile td1 {}
952    file attributes td1 -archive
953} -cleanup {
954    cleanup
955} -result 1
956test winFCmd-11.2 {GetWinFileAttributes} -constraints {win} -setup {
957    cleanup
958} -body {
959    createfile td1 {}
960    file attributes td1 -readonly
961} -cleanup {
962    cleanup
963} -result 0
964test winFCmd-11.3 {GetWinFileAttributes} -constraints {win} -setup {
965    cleanup
966} -body {
967    createfile td1 {}
968    file attributes td1 -hidden
969} -cleanup {
970    cleanup
971} -result 0
972test winFCmd-11.4 {GetWinFileAttributes} -constraints {win} -setup {
973    cleanup
974} -body {
975    createfile td1 {}
976    file attributes td1 -system
977} -cleanup {
978    cleanup
979} -result 0
980test winFCmd-11.5 {GetWinFileAttributes} -constraints {win} -setup {
981    set old [pwd]
982} -body {
983    # Attr of relative paths that resolve to root was failing don't care about
984    # answer, just that test runs.
985    cd c:/
986    file attr c:
987    file attr c:.
988    file attr .
989} -cleanup {
990    cd $old
991} -match glob -result *
992test winFCmd-11.6 {GetWinFileAttributes} -constraints {win} -body {
993    file attr c:/ -hidden
994} -result {0}
995
996test winFCmd-12.1 {ConvertFileNameFormat} -constraints {win} -setup {
997    cleanup
998} -body {
999    createfile td1 {}
1000    string tolower [file attributes td1 -longname]
1001} -cleanup {
1002    cleanup
1003} -result {td1}
1004test winFCmd-12.2 {ConvertFileNameFormat} -constraints {win} -setup {
1005    cleanup
1006} -body {
1007    file mkdir td1
1008    createfile td1/td1 {}
1009    string tolower [file attributes td1/td1 -longname]
1010} -cleanup {
1011    cleanup
1012} -result {td1/td1}
1013test winFCmd-12.3 {ConvertFileNameFormat} -constraints {win} -setup {
1014    cleanup
1015} -body {
1016    file mkdir td1
1017    file mkdir td1/td2
1018    createfile td1/td3 {}
1019    string tolower [file attributes td1/td2/../td3 -longname]
1020} -cleanup {
1021    cleanup
1022} -result {td1/td2/../td3}
1023test winFCmd-12.4 {ConvertFileNameFormat} -constraints {win} -setup {
1024    cleanup
1025} -body {
1026    createfile td1 {}
1027    string tolower [file attributes ./td1 -longname]
1028} -cleanup {
1029    cleanup
1030} -result {./td1}
1031test winFCmd-12.5 {ConvertFileNameFormat: absolute path} -body {
1032    list [file attributes / -longname] [file attributes \\ -longname]
1033} -constraints {win} -result {/ /}
1034test winFCmd-12.6 {ConvertFileNameFormat: absolute path with drive (in temp folder)} -setup {
1035    catch {file delete -force -- $::env(TEMP)/td1}
1036} -constraints {win} -body {
1037    createfile $::env(TEMP)/td1 {}
1038    string equal [string tolower [file attributes $::env(TEMP)/td1 -longname]] \
1039	    [string tolower [file normalize $::env(TEMP)]/td1]
1040} -cleanup {
1041    file delete -force -- $::env(TEMP)/td1
1042} -result 1
1043test winFCmd-12.7 {ConvertFileNameFormat} -body {
1044    string tolower [file attributes //bisque/tcl/ws -longname]
1045} -constraints {nonPortable win} -result {//bisque/tcl/ws}
1046test winFCmd-12.8 {ConvertFileNameFormat} -setup {
1047    cleanup
1048} -constraints {win longFileNames} -body {
1049    createfile td1 {}
1050    string tolower [file attributes td1 -longname]
1051} -cleanup {
1052    cleanup
1053} -result {td1}
1054test winFCmd-12.10 {ConvertFileNameFormat} -setup {
1055    cleanup
1056} -constraints {longFileNames win} -body {
1057    createfile td1td1td1 {}
1058    file attributes td1td1td1 -shortname
1059} -cleanup {
1060    cleanup
1061} -match glob -result *
1062test winFCmd-12.11 {ConvertFileNameFormat} -setup {
1063    cleanup
1064} -constraints {longFileNames win} -body {
1065    createfile td1 {}
1066    string tolower [file attributes td1 -shortname]
1067} -cleanup {
1068    cleanup
1069} -result {td1}
1070
1071test winFCmd-13.1 {GetWinFileLongName} -constraints {win} -setup {
1072    cleanup
1073} -body {
1074    createfile td1 {}
1075    string tolower [file attributes td1 -longname]
1076} -cleanup {
1077    cleanup
1078} -result td1
1079
1080test winFCmd-14.1 {GetWinFileShortName} -constraints {win} -setup {
1081    cleanup
1082} -body {
1083    createfile td1 {}
1084    string tolower [file attributes td1 -shortname]
1085} -cleanup {
1086    cleanup
1087} -result td1
1088
1089test winFCmd-15.1 {SetWinFileAttributes} -constraints {win} -setup {
1090    cleanup
1091} -body {
1092    file attributes td1 -archive 0
1093} -returnCodes error -result {could not read "td1": no such file or directory}
1094test winFCmd-15.2 {SetWinFileAttributes - archive} -constraints {win} -setup {
1095    cleanup
1096} -body {
1097    createfile td1 {}
1098    list [file attributes td1 -archive 1] [file attributes td1 -archive]
1099} -cleanup {
1100    cleanup
1101} -result {{} 1}
1102test winFCmd-15.3 {SetWinFileAttributes - archive} -constraints {win notInCIenv} -setup {
1103    cleanup
1104} -body {
1105    createfile td1 {}
1106    list [file attributes td1 -archive 0] [file attributes td1 -archive]
1107} -cleanup {
1108    cleanup
1109} -result {{} 0}
1110test winFCmd-15.4 {SetWinFileAttributes - hidden} -constraints {win notInCIenv} -setup {
1111    cleanup
1112} -body {
1113    createfile td1 {}
1114    list [file attributes td1 -hidden 1] [file attributes td1 -hidden] \
1115	[file attributes td1 -hidden 0]
1116} -cleanup {
1117    cleanup
1118} -result {{} 1 {}}
1119test winFCmd-15.5 {SetWinFileAttributes - hidden} -constraints {win} -setup {
1120    cleanup
1121} -body {
1122    createfile td1 {}
1123    list [file attributes td1 -hidden 0] [file attributes td1 -hidden]
1124} -cleanup {
1125    cleanup
1126} -result {{} 0}
1127test winFCmd-15.6 {SetWinFileAttributes - readonly} -setup {
1128    cleanup
1129} -constraints {win} -body {
1130    createfile td1 {}
1131    list [file attributes td1 -readonly 1] [file attributes td1 -readonly]
1132} -cleanup {
1133    cleanup
1134} -result {{} 1}
1135test winFCmd-15.7 {SetWinFileAttributes - readonly} -setup {
1136    cleanup
1137} -constraints {win} -body {
1138    createfile td1 {}
1139    list [file attributes td1 -readonly 0] [file attributes td1 -readonly]
1140} -cleanup {
1141    cleanup
1142} -result {{} 0}
1143test winFCmd-15.8 {SetWinFileAttributes - system} -constraints {win notInCIenv} -setup {
1144    cleanup
1145} -body {
1146    createfile td1 {}
1147    list [file attributes td1 -system 1] [file attributes td1 -system]
1148} -cleanup {
1149    cleanup
1150} -result {{} 1}
1151test winFCmd-15.9 {SetWinFileAttributes - system} -constraints {win} -setup {
1152    cleanup
1153} -body {
1154    createfile td1 {}
1155    list [file attributes td1 -system 0] [file attributes td1 -system]
1156} -cleanup {
1157    cleanup
1158} -result {{} 0}
1159test winFCmd-15.10 {SetWinFileAttributes - failing} -setup {
1160    cleanup
1161} -constraints {win cdrom} -body {
1162    file attributes $cdfile -archive 1
1163} -returnCodes error -match glob -result *
1164
1165test winFCmd-16.1 {Windows file normalization} -constraints {win} -body {
1166    list [file normalize c:/] [file normalize C:/]
1167} -result {C:/ C:/}
1168test winFCmd-16.2 {Windows file normalization} -constraints {win} -body {
1169    createfile td1... {}
1170    file tail [file normalize td1]
1171} -cleanup {
1172    file delete td1...
1173} -result {td1}
1174set pwd [pwd]
1175set d [string index $pwd 0]
1176test winFCmd-16.3 {Windows file normalization} -constraints {win} -body {
1177    file norm ${d}:foo
1178} -result [file join $pwd foo]
1179test winFCmd-16.4 {Windows file normalization} -constraints {win} -body {
1180    file norm [string tolower ${d}]:foo
1181} -result [file join $pwd foo]
1182test winFCmd-16.5 {Windows file normalization} -constraints {win} -body {
1183    file norm ${d}:foo/bar
1184} -result [file join $pwd foo/bar]
1185test winFCmd-16.6 {Windows file normalization} -constraints {win} -body {
1186    file norm ${d}:foo\\bar
1187} -result [file join $pwd foo/bar]
1188test winFCmd-16.7 {Windows file normalization} -constraints {win} -body {
1189    file norm /bar
1190} -result "${d}:/bar"
1191test winFCmd-16.8 {Windows file normalization} -constraints {win} -body {
1192    file norm ///bar
1193} -result "${d}:/bar"
1194test winFCmd-16.9 {Windows file normalization} -constraints {win} -body {
1195    file norm /bar/foo
1196} -result "${d}:/bar/foo"
1197if {$d eq "C"} { set dd "D" } else { set dd "C" }
1198test winFCmd-16.10 {Windows file normalization} -constraints {win} -body {
1199    file norm ${dd}:foo
1200} -result "${dd}:/foo"
1201test winFCmd-16.11 {Windows file normalization} -body {
1202    cd ${d}:
1203    cd $cdrom
1204    cd ${d}:
1205    cd $cdrom
1206    # Must not crash
1207    set result "no crash"
1208} -constraints {win cdrom} -cleanup {
1209    cd $pwd
1210} -result {no crash}
1211test winFCmd-16.12 {Windows file normalization - no crash} \
1212  -constraints win -setup {
1213    set oldhome ""
1214    catch {set oldhome $::env(HOME)}
1215} -body {
1216    set expectedResult [file normalize ${d}:]
1217    set ::env(HOME) ${d}:
1218    cd
1219    # At one point this led to an infinite recursion in Tcl
1220    set result [pwd]; # <- Must not crash
1221    set result "no crash"
1222} -cleanup {
1223    set ::env(HOME) $oldhome
1224    cd $pwd
1225} -result {no crash}
1226test winFCmd-16.13 {Windows file normalization - absolute HOME} -setup {
1227    set oldhome ""
1228    catch {set oldhome $::env(HOME)}
1229} -constraints win -body {
1230    # Test 'cd' normalization when HOME is absolute
1231    set ::env(HOME) ${d}:/
1232    cd
1233    pwd
1234} -cleanup {
1235    set ::env(HOME) $oldhome
1236    cd $pwd
1237} -result [file normalize ${d}:/]
1238test winFCmd-16.14 {Windows file normalization - relative HOME} -setup {
1239    set oldhome ""
1240    catch {set oldhome $::env(HOME)}
1241} -constraints win -body {
1242    # Test 'cd' normalization when HOME is relative
1243    set ::env(HOME) ${d}:
1244    cd
1245    pwd
1246} -cleanup {
1247    set ::env(HOME) $oldhome
1248    cd $pwd
1249} -result $pwd
1250
1251test winFCmd-17.1 {Windows bad permissions cd} -constraints win -body {
1252    set d {}
1253    foreach dd {c:/ d:/ e:/} {
1254	eval lappend d [glob -nocomplain \
1255	  -types hidden -dir $dd "System Volume Information"]
1256    }
1257    # Old versions of Tcl gave a misleading error that the
1258    # directory in question didn't exist.
1259    if {[llength $d] && [catch {cd [lindex $d 0]} err]} {
1260	regsub ".*: " $err "" err
1261	set err
1262    } else {
1263        set err "permission denied"
1264    }
1265} -cleanup {
1266    cd $pwd
1267} -result "permission denied"
1268
1269cd $pwd
1270unset d dd pwd
1271
1272test winFCmd-18.1 {Windows reserved path names} -constraints win -body {
1273    file pathtype com1
1274} -result "absolute"
1275test winFCmd-18.1.2 {Windows reserved path names} -constraints win -body {
1276    file pathtype com4
1277} -result "absolute"
1278test winFCmd-18.1.3 {Windows reserved path names} -constraints win -body {
1279    file pathtype com9
1280} -result "absolute"
1281test winFCmd-18.1.4 {Windows reserved path names} -constraints win -body {
1282    file pathtype lpt3
1283} -result "absolute"
1284test winFCmd-18.1.5 {Windows reserved path names} -constraints win -body {
1285    file pathtype lpt9
1286} -result "absolute"
1287test winFCmd-18.1.6 {Windows reserved path names} -constraints win -body {
1288    file pathtype nul
1289} -result "absolute"
1290test winFCmd-18.1.7 {Windows reserved path names} -constraints win -body {
1291    file pathtype null
1292} -result "relative"
1293test winFCmd-18.2 {Windows reserved path names} -constraints win -body {
1294    file pathtype com1:
1295} -result "absolute"
1296test winFCmd-18.3 {Windows reserved path names} -constraints win -body {
1297    file pathtype COM1
1298} -result "absolute"
1299test winFCmd-18.4 {Windows reserved path names} -constraints win -body {
1300    file pathtype CoM1:
1301} -result "absolute"
1302test winFCmd-18.5 {Windows reserved path names} -constraints win -body {
1303    file normalize com1:
1304} -result COM1
1305test winFCmd-18.6 {Windows reserved path names} -constraints win -body {
1306    file normalize COM1:
1307} -result COM1
1308test winFCmd-18.7 {Windows reserved path names} -constraints win -body {
1309    file normalize cOm1
1310} -result COM1
1311test winFCmd-18.8 {Windows reserved path names} -constraints win -body {
1312    file normalize cOm1:
1313} -result COM1
1314
1315test winFCmd-19.1 {Windows extended path names} -constraints win -body {
1316    file normalize //?/c:/windows/win.ini
1317} -result //?/c:/windows/win.ini
1318test winFCmd-19.2 {Windows extended path names} -constraints win -body {
1319    file normalize //?/c:/windows/../windows/win.ini
1320} -result //?/c:/windows/win.ini
1321test winFCmd-19.3 {Windows extended path names} -constraints win -setup {
1322    set tmpfile [file join $::env(TEMP) tcl[string repeat x 20].tmp]
1323    set tmpfile [file normalize $tmpfile]
1324} -body {
1325    list [catch {
1326        set f [open $tmpfile [list WRONLY CREAT]]
1327        close $f
1328    } res] $res
1329} -cleanup {
1330    catch {file delete $tmpfile}
1331} -result [list 0 {}]
1332test winFCmd-19.4 {Windows extended path names} -constraints win -setup {
1333    set tmpfile [file join $::env(TEMP) tcl[string repeat x 20].tmp]
1334    set tmpfile //?/[file normalize $tmpfile]
1335} -body {
1336    list [catch {
1337        set f [open $tmpfile [list WRONLY CREAT]]
1338        close $f
1339    } res] $res
1340} -cleanup {
1341    catch {file delete $tmpfile}
1342} -result [list 0 {}]
1343test winFCmd-19.5 {Windows extended path names} -constraints win -setup {
1344    set tmpfile [file join $::env(TEMP) tcl[string repeat x 248].tmp]
1345    set tmpfile [file normalize $tmpfile]
1346} -body {
1347    list [catch {
1348        set f [open $tmpfile [list WRONLY CREAT]]
1349        close $f
1350    } res] $res
1351} -cleanup {
1352    catch {file delete $tmpfile}
1353} -result [list 0 {}]
1354test winFCmd-19.6 {Windows extended path names} -constraints win -setup {
1355    set tmpfile [file join $::env(TEMP) tcl[string repeat x 248].tmp]
1356    set tmpfile //?/[file normalize $tmpfile]
1357} -body {
1358    list [catch {
1359        set f [open $tmpfile [list WRONLY CREAT]]
1360        close $f
1361    } res] $res
1362} -cleanup {
1363    catch {file delete $tmpfile}
1364} -result [list 0 {}]
1365test winFCmd-19.7 {Windows extended path names} -constraints win -setup {
1366    set tmpfile [file join $::env(TEMP) "tcl[pid].tmp "]
1367    set tmpfile [file normalize $tmpfile]
1368} -body {
1369    list [catch {
1370        set f [open $tmpfile [list WRONLY CREAT]]
1371        close $f
1372    } res] $res [glob -directory $::env(TEMP) -tails tcl[pid].*]
1373} -cleanup {
1374    catch {file delete $tmpfile}
1375} -result [list 0 {} [list tcl[pid].tmp]]
1376test winFCmd-19.8 {Windows extended path names} -constraints win -setup {
1377    set tmpfile [file join $::env(TEMP) "tcl[pid].tmp "]
1378    set tmpfile //?/[file normalize $tmpfile]
1379} -body {
1380    list [catch {
1381        set f [open $tmpfile [list WRONLY CREAT]]
1382        close $f
1383    } res] $res [glob -directory $::env(TEMP) -tails tcl[pid].*]
1384} -cleanup {
1385    catch {file delete $tmpfile}
1386} -result [list 0 {} [list "tcl[pid].tmp "]]
1387
1388test winFCmd-19.9 {Windows devices path names} -constraints win -body {
1389    file normalize //./com1
1390} -result //./com1
1391
1392
1393# This block of code used to occur after the "return" call, so I'm
1394# commenting it out and assuming that this code is still under construction.
1395#foreach source {tef ted tnf tnd "" nul com1} {
1396#    foreach chmodsrc {000 755} {
1397#        foreach dest "tfn tfe tdn tdempty tdfull td1/td2 $p $p/td1 {} nul" {
1398#	    foreach chmoddst {000 755} {
1399#		puts hi
1400#		cleanup
1401#		file delete -force ted tef
1402#		file mkdir ted
1403#		createfile tef
1404#		createfile tfe
1405#		file mkdir tdempty
1406#		file mkdir tdfull/td1/td2
1407#
1408#		catch {testchmod $chmodsrc $source}
1409#		catch {testchmod $chmoddst $dest}
1410#
1411#		if [catch {file rename $source $dest} msg] {
1412#		    puts "file rename $source ($chmodsrc) $dest ($chmoddst)"
1413#		    puts $msg
1414#		}
1415#	    }
1416#	}
1417#    }
1418#}
1419
1420# cleanup
1421cleanup
1422::tcltest::cleanupTests
1423return
1424
1425# Local Variables:
1426# mode: tcl
1427# End:
1428