os/persistentdata/persistentstorage/sqlite3api/TEST/TCL/tcldistribution/tests/winFCmd.test
author sl@SLION-WIN7.fritz.box
Fri, 15 Jun 2012 03:10:57 +0200
changeset 0 bde4ae8d615e
permissions -rw-r--r--
First public contribution.
sl@0
     1
# This file tests the tclWinFCmd.c file.
sl@0
     2
#
sl@0
     3
# This file contains a collection of tests for one or more of the Tcl
sl@0
     4
# built-in commands.  Sourcing this file into Tcl runs the tests and
sl@0
     5
# generates output for errors.  No output means no errors were found.
sl@0
     6
#
sl@0
     7
# Copyright (c) 1996-1997 Sun Microsystems, Inc.
sl@0
     8
# Copyright (c) 1998-1999 by Scriptics Corporation.
sl@0
     9
#
sl@0
    10
# See the file "license.terms" for information on usage and redistribution
sl@0
    11
# of this file, and for a DISCLAIMER OF ALL WARRANTIES.
sl@0
    12
#
sl@0
    13
# RCS: @(#) $Id: winFCmd.test,v 1.20.2.9 2006/03/19 22:47:30 vincentdarley Exp $
sl@0
    14
#
sl@0
    15
sl@0
    16
if {[lsearch [namespace children] ::tcltest] == -1} {
sl@0
    17
    package require tcltest
sl@0
    18
    namespace import -force ::tcltest::*
sl@0
    19
}
sl@0
    20
sl@0
    21
proc createfile {file {string a}} {
sl@0
    22
    set f [open $file w]
sl@0
    23
    puts -nonewline $f $string
sl@0
    24
    close $f
sl@0
    25
    return $string
sl@0
    26
}
sl@0
    27
sl@0
    28
proc contents {file} {
sl@0
    29
    set f [open $file r]
sl@0
    30
    set r [read $f]
sl@0
    31
    close $f
sl@0
    32
    set r
sl@0
    33
}
sl@0
    34
sl@0
    35
proc cleanup {args} {
sl@0
    36
    foreach p ". $args" {
sl@0
    37
	set x ""
sl@0
    38
	catch {
sl@0
    39
	    set x [glob -directory $p tf* td*]
sl@0
    40
	}
sl@0
    41
	if {$x != ""} {
sl@0
    42
	    catch {eval file delete -force -- $x}
sl@0
    43
	}
sl@0
    44
    }
sl@0
    45
}
sl@0
    46
sl@0
    47
if {[string equal $tcl_platform(platform) "windows"]} {
sl@0
    48
    if {[string equal $tcl_platform(os) "Windows NT"] \
sl@0
    49
      && [string equal [string index $tcl_platform(osVersion) 0] "5"]} {
sl@0
    50
	tcltest::testConstraint win2000orXP 1
sl@0
    51
	tcltest::testConstraint winOlderThan2000 0
sl@0
    52
    } else {
sl@0
    53
	tcltest::testConstraint win2000orXP 0
sl@0
    54
	tcltest::testConstraint winOlderThan2000 1
sl@0
    55
    }
sl@0
    56
} else {
sl@0
    57
    tcltest::testConstraint win2000orXP 0
sl@0
    58
    tcltest::testConstraint winOlderThan2000 0
sl@0
    59
}
sl@0
    60
sl@0
    61
set ::tcltest::testConstraints(cdrom) 0
sl@0
    62
set ::tcltest::testConstraints(exdev) 0
sl@0
    63
sl@0
    64
# find a CD-ROM so we can test read-only filesystems.
sl@0
    65
sl@0
    66
set cdrom {}
sl@0
    67
if { [info commands ::testvolumetype] ne {} } {
sl@0
    68
    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} {
sl@0
    69
        if { ! [catch { testvolumetype ${p}: } result] && $result eq {CDFS} } {
sl@0
    70
	    set cdrom ${p}:
sl@0
    71
	}
sl@0
    72
    }
sl@0
    73
}
sl@0
    74
sl@0
    75
proc findfile {dir} {
sl@0
    76
    foreach p [glob $dir/*] {
sl@0
    77
        if {[file type $p] == "file"} {
sl@0
    78
	    return $p
sl@0
    79
	}
sl@0
    80
    }
sl@0
    81
    foreach p [glob $dir/*] {
sl@0
    82
        if {[file type $p] == "directory"} {
sl@0
    83
	    set f [findfile $p]
sl@0
    84
	    if {$f != ""} {
sl@0
    85
	        return $f
sl@0
    86
	    }
sl@0
    87
	}
sl@0
    88
    }
sl@0
    89
    return ""
sl@0
    90
}
sl@0
    91
sl@0
    92
if {$cdrom != ""} {
sl@0
    93
    set ::tcltest::testConstraints(cdrom) 1
sl@0
    94
    set cdfile [findfile $cdrom]
sl@0
    95
}
sl@0
    96
sl@0
    97
if {[file exists c:/] && [file exists d:/]} {
sl@0
    98
    catch {file delete d:/tf1}
sl@0
    99
    if {[catch {close [open d:/tf1 w]}] == 0} {
sl@0
   100
	file delete d:/tf1
sl@0
   101
	set ::tcltest::testConstraints(exdev) 1
sl@0
   102
    }
sl@0
   103
}
sl@0
   104
sl@0
   105
file delete -force -- td1
sl@0
   106
set foo [catch {open td1 w} testfile]
sl@0
   107
if {$foo} {
sl@0
   108
    set ::tcltest::testConstraints(longFileNames) 0
sl@0
   109
} else {
sl@0
   110
    close $testfile
sl@0
   111
    set ::tcltest::testConstraints(longFileNames) 1
sl@0
   112
    file delete -force -- td1
sl@0
   113
}
sl@0
   114
sl@0
   115
# A really long file name
sl@0
   116
# length of longname is 1216 chars, which should be greater than any static
sl@0
   117
# buffer or allowable filename.
sl@0
   118
sl@0
   119
set longname "abcdefghihjllmnopqrstuvwxyz01234567890"
sl@0
   120
append longname $longname
sl@0
   121
append longname $longname
sl@0
   122
append longname $longname
sl@0
   123
append longname $longname
sl@0
   124
append longname $longname
sl@0
   125
sl@0
   126
# Uses the "testfile" command instead of the "file" command.  The "file"
sl@0
   127
# command provides several layers of sanity checks on the arguments and
sl@0
   128
# it can be difficult to actually forward "insane" arguments to the
sl@0
   129
# low-level posix emulation layer.
sl@0
   130
sl@0
   131
test winFCmd-1.1 {TclpRenameFile: errno: EACCES} {pcOnly cdrom} {
sl@0
   132
    list [catch {testfile mv $cdfile $cdrom/dummy~~.fil} msg] $msg
sl@0
   133
} {1 EACCES}
sl@0
   134
test winFCmd-1.2 {TclpRenameFile: errno: EEXIST} {pcOnly} {
sl@0
   135
    cleanup
sl@0
   136
    file mkdir td1/td2/td3
sl@0
   137
    file mkdir td2
sl@0
   138
    list [catch {testfile mv td2 td1/td2} msg] $msg
sl@0
   139
} {1 EEXIST} 
sl@0
   140
test winFCmd-1.3 {TclpRenameFile: errno: EINVAL} {pcOnly} {
sl@0
   141
    cleanup
sl@0
   142
    list [catch {testfile mv / td1} msg] $msg
sl@0
   143
} {1 EINVAL}
sl@0
   144
test winFCmd-1.4 {TclpRenameFile: errno: EINVAL} {pcOnly} {
sl@0
   145
    cleanup
sl@0
   146
    file mkdir td1
sl@0
   147
    list [catch {testfile mv td1 td1/td2} msg] $msg
sl@0
   148
} {1 EINVAL}
sl@0
   149
test winFCmd-1.5 {TclpRenameFile: errno: EISDIR} {pcOnly} {
sl@0
   150
    cleanup
sl@0
   151
    file mkdir td1
sl@0
   152
    createfile tf1
sl@0
   153
    list [catch {testfile mv tf1 td1} msg] $msg
sl@0
   154
} {1 EISDIR}
sl@0
   155
test winFCmd-1.6 {TclpRenameFile: errno: ENOENT} {pcOnly} {
sl@0
   156
    cleanup
sl@0
   157
    list [catch {testfile mv tf1 tf2} msg] $msg
sl@0
   158
} {1 ENOENT}
sl@0
   159
test winFCmd-1.7 {TclpRenameFile: errno: ENOENT} {pcOnly} {
sl@0
   160
    cleanup
sl@0
   161
    list [catch {testfile mv "" tf2} msg] $msg
sl@0
   162
} {1 ENOENT}
sl@0
   163
test winFCmd-1.8 {TclpRenameFile: errno: ENOENT} {pcOnly} {
sl@0
   164
    cleanup
sl@0
   165
    createfile tf1
sl@0
   166
    list [catch {testfile mv tf1 ""} msg] $msg
sl@0
   167
} {1 ENOENT}
sl@0
   168
test winFCmd-1.9 {TclpRenameFile: errno: ENOTDIR} {pcOnly} {
sl@0
   169
    cleanup
sl@0
   170
    file mkdir td1
sl@0
   171
    createfile tf1
sl@0
   172
    list [catch {testfile mv td1 tf1} msg] $msg
sl@0
   173
} {1 ENOTDIR}
sl@0
   174
test winFCmd-1.10 {TclpRenameFile: errno: EXDEV} {pcOnly exdev} {
sl@0
   175
    file delete -force d:/tf1
sl@0
   176
    file mkdir c:/tf1
sl@0
   177
    set msg [list [catch {testfile mv c:/tf1 d:/tf1} msg] $msg]
sl@0
   178
    file delete -force c:/tf1
sl@0
   179
    set msg
sl@0
   180
} {1 EXDEV}
sl@0
   181
test winFCmd-1.11 {TclpRenameFile: errno: EACCES} {pcOnly} {
sl@0
   182
    cleanup
sl@0
   183
    set fd [open tf1 w]
sl@0
   184
    set msg [list [catch {testfile mv tf1 tf2} msg] $msg]
sl@0
   185
    close $fd
sl@0
   186
    set msg
sl@0
   187
} {1 EACCES}
sl@0
   188
test winFCmd-1.12 {TclpRenameFile: errno: EACCES} {pcOnly} {
sl@0
   189
    cleanup
sl@0
   190
    createfile tf1
sl@0
   191
    set fd [open tf2 w]
sl@0
   192
    set msg [list [catch {testfile mv tf1 tf2} msg] $msg]
sl@0
   193
    close $fd
sl@0
   194
    set msg
sl@0
   195
} {1 EACCES}
sl@0
   196
test winFCmd-1.13 {TclpRenameFile: errno: EACCES} {pcOnly win2000orXP} {
sl@0
   197
    cleanup
sl@0
   198
    list [catch {testfile mv nul tf1} msg] $msg
sl@0
   199
} {1 EINVAL}
sl@0
   200
test winFCmd-1.13.1 {TclpRenameFile: errno: EACCES} {pcOnly winOlderThan2000} {
sl@0
   201
    cleanup
sl@0
   202
    list [catch {testfile mv nul tf1} msg] $msg
sl@0
   203
} {1 EACCES}
sl@0
   204
test winFCmd-1.14 {TclpRenameFile: errno: EACCES} {pcOnly 95} {
sl@0
   205
    cleanup
sl@0
   206
    createfile tf1
sl@0
   207
    list [catch {testfile mv tf1 nul} msg] $msg
sl@0
   208
} {1 EACCES}
sl@0
   209
test winFCmd-1.15 {TclpRenameFile: errno: EEXIST} {pcOnly nt} {
sl@0
   210
    cleanup
sl@0
   211
    createfile tf1
sl@0
   212
    list [catch {testfile mv tf1 nul} msg] $msg
sl@0
   213
} {1 EEXIST}
sl@0
   214
test winFCmd-1.16 {TclpRenameFile: MoveFile() != FALSE} {pcOnly} {
sl@0
   215
    cleanup
sl@0
   216
    createfile tf1 tf1
sl@0
   217
    testfile mv tf1 tf2
sl@0
   218
    list [file exists tf1] [contents tf2]
sl@0
   219
} {0 tf1}
sl@0
   220
test winFCmd-1.17 {TclpRenameFile: MoveFile() == FALSE} {pcOnly} {
sl@0
   221
    cleanup
sl@0
   222
    list [catch {testfile mv tf1 tf2} msg] $msg
sl@0
   223
} {1 ENOENT} 
sl@0
   224
test winFCmd-1.18 {TclpRenameFile: srcAttr == -1} {pcOnly} {
sl@0
   225
    cleanup
sl@0
   226
    list [catch {testfile mv tf1 tf2} msg] $msg
sl@0
   227
} {1 ENOENT} 
sl@0
   228
test winFCmd-1.19 {TclpRenameFile: errno == EACCES} {pcOnly win2000orXP} {
sl@0
   229
    cleanup
sl@0
   230
    list [catch {testfile mv nul tf1} msg] $msg
sl@0
   231
} {1 EINVAL}
sl@0
   232
test winFCmd-1.19.1 {TclpRenameFile: errno == EACCES} {pcOnly winOlderThan2000} {
sl@0
   233
    cleanup
sl@0
   234
    list [catch {testfile mv nul tf1} msg] $msg
sl@0
   235
} {1 EACCES}
sl@0
   236
test winFCmd-1.20 {TclpRenameFile: src is dir} {pcOnly nt} {
sl@0
   237
    # under 95, this would actually succeed and move the current dir out from 
sl@0
   238
    # under the current process!
sl@0
   239
    cleanup
sl@0
   240
    file delete /tf1
sl@0
   241
    list [catch {testfile mv [pwd] /tf1} msg] $msg
sl@0
   242
} {1 EACCES}
sl@0
   243
test winFCmd-1.21 {TclpRenameFile: long src} {pcOnly} {
sl@0
   244
    cleanup
sl@0
   245
    list [catch {testfile mv $longname tf1} msg] $msg
sl@0
   246
} {1 ENAMETOOLONG}
sl@0
   247
test winFCmd-1.22 {TclpRenameFile: long dst} {pcOnly} {
sl@0
   248
    cleanup
sl@0
   249
    createfile tf1
sl@0
   250
    list [catch {testfile mv tf1 $longname} msg] $msg
sl@0
   251
} {1 ENAMETOOLONG}
sl@0
   252
test winFCmd-1.23 {TclpRenameFile: move dir into self} {pcOnly} {
sl@0
   253
    cleanup
sl@0
   254
    file mkdir td1
sl@0
   255
    list [catch {testfile mv [pwd]/td1 td1/td2} msg] $msg
sl@0
   256
} {1 EINVAL}
sl@0
   257
test winFCmd-1.24 {TclpRenameFile: move a root dir} {pcOnly} {
sl@0
   258
    cleanup
sl@0
   259
    list [catch {testfile mv / c:/} msg] $msg
sl@0
   260
} {1 EINVAL}
sl@0
   261
test winFCmd-1.25 {TclpRenameFile: cross file systems} {pcOnly cdrom} {
sl@0
   262
    cleanup
sl@0
   263
    file mkdir td1
sl@0
   264
    list [catch {testfile mv td1 $cdrom/td1} msg] $msg
sl@0
   265
} {1 EXDEV} 
sl@0
   266
test winFCmd-1.26 {TclpRenameFile: readonly fs} {pcOnly cdrom} {
sl@0
   267
    cleanup
sl@0
   268
    list [catch {testfile mv $cdfile $cdrom/dummy~~.fil} msg] $msg
sl@0
   269
} {1 EACCES}
sl@0
   270
test winFCmd-1.27 {TclpRenameFile: open file} {pcOnly} {
sl@0
   271
    cleanup
sl@0
   272
    set fd [open tf1 w]
sl@0
   273
    set msg [list [catch {testfile mv tf1 tf2} msg] $msg]
sl@0
   274
    close $fd
sl@0
   275
    set msg
sl@0
   276
} {1 EACCES}    
sl@0
   277
test winFCmd-1.28 {TclpRenameFile: errno == EEXIST} {pcOnly} {
sl@0
   278
    cleanup
sl@0
   279
    createfile tf1
sl@0
   280
    createfile tf2
sl@0
   281
    testfile mv tf1 tf2
sl@0
   282
    list [file exists tf1] [file exists tf2]
sl@0
   283
} {0 1}
sl@0
   284
test winFCmd-1.29 {TclpRenameFile: src is dir} {pcOnly} {
sl@0
   285
    cleanup
sl@0
   286
    file mkdir td1
sl@0
   287
    createfile tf1
sl@0
   288
    list [catch {testfile mv td1 tf1} msg] $msg
sl@0
   289
} {1 ENOTDIR} 
sl@0
   290
test winFCmd-1.30 {TclpRenameFile: dst is dir} {pcOnly} {
sl@0
   291
    cleanup
sl@0
   292
    file mkdir td1
sl@0
   293
    file mkdir td2/td2
sl@0
   294
    list [catch {testfile mv td1 td2} msg] $msg
sl@0
   295
} {1 EEXIST}
sl@0
   296
test winFCmd-1.31 {TclpRenameFile: TclpRemoveDirectory fails} {pcOnly} {
sl@0
   297
    cleanup
sl@0
   298
    file mkdir td1
sl@0
   299
    file mkdir td2/td2
sl@0
   300
    list [catch {testfile mv td1 td2} msg] $msg
sl@0
   301
} {1 EEXIST}
sl@0
   302
test winFCmd-1.32 {TclpRenameFile: TclpRemoveDirectory succeeds} {pcOnly} {
sl@0
   303
    cleanup
sl@0
   304
    file mkdir td1/td2
sl@0
   305
    file mkdir td2
sl@0
   306
    testfile mv td1 td2
sl@0
   307
    list [file exists td1] [file exists td2] [file exists td2/td2]
sl@0
   308
} {0 1 1}
sl@0
   309
test winFCmd-1.33 {TclpRenameFile: After removing dst dir, MoveFile fails} \
sl@0
   310
	{pcOnly exdev} {
sl@0
   311
    file mkdir d:/td1
sl@0
   312
    testchmod 000 d:/td1
sl@0
   313
    file mkdir c:/tf1
sl@0
   314
    set msg [list [catch {testfile mv c:/tf1 d:/td1} msg] $msg]
sl@0
   315
    set msg "$msg [file writable d:/td1]"
sl@0
   316
    file delete d:/td1
sl@0
   317
    file delete -force c:/tf1
sl@0
   318
    set msg
sl@0
   319
} {1 EXDEV 0}
sl@0
   320
test winFCmd-1.34 {TclpRenameFile: src is dir, dst is not} {pcOnly} {
sl@0
   321
    file mkdir td1
sl@0
   322
    createfile tf1
sl@0
   323
    list [catch {testfile mv td1 tf1} msg] $msg
sl@0
   324
} {1 ENOTDIR}
sl@0
   325
test winFCmd-1.35 {TclpRenameFile: src is not dir, dst is} {pcOnly} {
sl@0
   326
    file mkdir td1
sl@0
   327
    createfile tf1
sl@0
   328
    list [catch {testfile mv tf1 td1} msg] $msg
sl@0
   329
} {1 EISDIR}
sl@0
   330
test winFCmd-1.36 {TclpRenameFile: src and dst not dir} {pcOnly} {
sl@0
   331
    createfile tf1 tf1
sl@0
   332
    createfile tf2 tf2
sl@0
   333
    testfile mv tf1 tf2
sl@0
   334
    contents tf2
sl@0
   335
} {tf1}
sl@0
   336
test winFCmd-1.37 {TclpRenameFile: need to restore temp file} {pcOnly} {
sl@0
   337
    # Can't figure out how to cause this. 
sl@0
   338
    # Need a file that can't be copied.
sl@0
   339
} {}
sl@0
   340
sl@0
   341
test winFCmd-2.1 {TclpCopyFile: errno: EACCES} {pcOnly cdrom} {
sl@0
   342
    cleanup
sl@0
   343
    list [catch {testfile cp $cdfile $cdrom/dummy~~.fil} msg] $msg
sl@0
   344
} {1 EACCES}
sl@0
   345
test winFCmd-2.2 {TclpCopyFile: errno: EISDIR} {pcOnly} {
sl@0
   346
    cleanup
sl@0
   347
    file mkdir td1
sl@0
   348
    list [catch {testfile cp td1 tf1} msg] $msg
sl@0
   349
} {1 EISDIR}
sl@0
   350
test winFCmd-2.3 {TclpCopyFile: errno: EISDIR} {pcOnly} {
sl@0
   351
    cleanup
sl@0
   352
    createfile tf1
sl@0
   353
    file mkdir td1
sl@0
   354
    list [catch {testfile cp tf1 td1} msg] $msg
sl@0
   355
} {1 EISDIR}
sl@0
   356
test winFCmd-2.4 {TclpCopyFile: errno: ENOENT} {pcOnly} {
sl@0
   357
    cleanup
sl@0
   358
    list [catch {testfile cp tf1 tf2} msg] $msg
sl@0
   359
} {1 ENOENT}
sl@0
   360
test winFCmd-2.5 {TclpCopyFile: errno: ENOENT} {pcOnly} {
sl@0
   361
    cleanup
sl@0
   362
    list [catch {testfile cp "" tf2} msg] $msg
sl@0
   363
} {1 ENOENT}
sl@0
   364
test winFCmd-2.6 {TclpCopyFile: errno: ENOENT} {pcOnly} {
sl@0
   365
    cleanup
sl@0
   366
    createfile tf1
sl@0
   367
    list [catch {testfile cp tf1 ""} msg] $msg
sl@0
   368
} {1 ENOENT}
sl@0
   369
test winFCmd-2.7 {TclpCopyFile: errno: EACCES} {pcOnly 95} {
sl@0
   370
    cleanup
sl@0
   371
    createfile tf1
sl@0
   372
    set fd [open tf2 w]
sl@0
   373
    set msg [list [catch {testfile cp tf1 tf2} msg] $msg]
sl@0
   374
    close $fd
sl@0
   375
    set msg
sl@0
   376
} {1 EACCES}
sl@0
   377
test winFCmd-2.8 {TclpCopyFile: errno: EACCES} {pcOnly win2000orXP} {
sl@0
   378
    cleanup
sl@0
   379
    list [catch {testfile cp nul tf1} msg] $msg
sl@0
   380
} {1 EINVAL}
sl@0
   381
test winFCmd-2.8.1 {TclpCopyFile: errno: EACCES} {pcOnly nt winOlderThan2000} {
sl@0
   382
    cleanup
sl@0
   383
    list [catch {testfile cp nul tf1} msg] $msg
sl@0
   384
} {1 EACCES}
sl@0
   385
test winFCmd-2.9 {TclpCopyFile: errno: ENOENT} {pcOnly 95} {
sl@0
   386
    cleanup
sl@0
   387
    list [catch {testfile cp nul tf1} msg] $msg
sl@0
   388
} {1 ENOENT}
sl@0
   389
test winFCmd-2.10 {TclpCopyFile: CopyFile succeeds} {pcOnly} {
sl@0
   390
    cleanup
sl@0
   391
    createfile tf1 tf1
sl@0
   392
    testfile cp tf1 tf2
sl@0
   393
    list [contents tf1] [contents tf2]
sl@0
   394
} {tf1 tf1}
sl@0
   395
test winFCmd-2.11 {TclpCopyFile: CopyFile succeeds} {pcOnly} {
sl@0
   396
    cleanup
sl@0
   397
    createfile tf1 tf1
sl@0
   398
    createfile tf2 tf2
sl@0
   399
    testfile cp tf1 tf2
sl@0
   400
    list [contents tf1] [contents tf2]
sl@0
   401
} {tf1 tf1}
sl@0
   402
test winFCmd-2.12 {TclpCopyFile: CopyFile succeeds} {pcOnly} {
sl@0
   403
    cleanup
sl@0
   404
    createfile tf1 tf1
sl@0
   405
    testchmod 000 tf1
sl@0
   406
    testfile cp tf1 tf2
sl@0
   407
    list [contents tf2] [file writable tf2]
sl@0
   408
} {tf1 0}
sl@0
   409
test winFCmd-2.13 {TclpCopyFile: CopyFile fails} {pcOnly} {
sl@0
   410
    cleanup
sl@0
   411
    createfile tf1
sl@0
   412
    file mkdir td1
sl@0
   413
    list [catch {testfile cp tf1 td1} msg] $msg
sl@0
   414
} {1 EISDIR} 
sl@0
   415
test winFCmd-2.14 {TclpCopyFile: errno == EACCES} {pcOnly} {
sl@0
   416
    cleanup
sl@0
   417
    file mkdir td1
sl@0
   418
    list [catch {testfile cp td1 tf1} msg] $msg
sl@0
   419
} {1 EISDIR}
sl@0
   420
test winFCmd-2.15 {TclpCopyFile: src is directory} {pcOnly} {
sl@0
   421
    cleanup
sl@0
   422
    file mkdir td1
sl@0
   423
    list [catch {testfile cp td1 tf1} msg] $msg
sl@0
   424
} {1 EISDIR}
sl@0
   425
test winFCmd-2.16 {TclpCopyFile: dst is directory} {pcOnly} {
sl@0
   426
    cleanup
sl@0
   427
    createfile tf1
sl@0
   428
    file mkdir td1
sl@0
   429
    list [catch {testfile cp tf1 td1} msg] $msg
sl@0
   430
} {1 EISDIR}
sl@0
   431
test winFCmd-2.17 {TclpCopyFile: dst is readonly} {pcOnly} {
sl@0
   432
    cleanup
sl@0
   433
    createfile tf1 tf1
sl@0
   434
    createfile tf2 tf2
sl@0
   435
    testchmod 000 tf2
sl@0
   436
    testfile cp tf1 tf2
sl@0
   437
    list [file writable tf2] [contents tf2]
sl@0
   438
} {1 tf1}
sl@0
   439
test winFCmd-2.18 {TclpCopyFile: still can't copy onto dst} {pcOnly 95} {
sl@0
   440
    cleanup
sl@0
   441
    createfile tf1
sl@0
   442
    createfile tf2
sl@0
   443
    testchmod 000 tf2
sl@0
   444
    set fd [open tf2]
sl@0
   445
    set msg [list [catch {testfile cp tf1 tf2} msg] $msg]
sl@0
   446
    close $fd
sl@0
   447
    set msg "$msg [file writable tf2]"
sl@0
   448
} {1 EACCES 0}    
sl@0
   449
sl@0
   450
test winFCmd-3.1 {TclpDeleteFile: errno: EACCES} {pcOnly cdrom} {
sl@0
   451
    list [catch {testfile rm $cdfile $cdrom/dummy~~.fil} msg] $msg
sl@0
   452
} {1 EACCES}
sl@0
   453
test winFCmd-3.2 {TclpDeleteFile: errno: EISDIR} {pcOnly} {
sl@0
   454
    cleanup
sl@0
   455
    file mkdir td1
sl@0
   456
    list [catch {testfile rm td1} msg] $msg
sl@0
   457
} {1 EISDIR} 
sl@0
   458
test winFCmd-3.3 {TclpDeleteFile: errno: ENOENT} {pcOnly} {
sl@0
   459
    cleanup
sl@0
   460
    list [catch {testfile rm tf1} msg] $msg
sl@0
   461
} {1 ENOENT}
sl@0
   462
test winFCmd-3.4 {TclpDeleteFile: errno: ENOENT} {pcOnly} {
sl@0
   463
    cleanup
sl@0
   464
    list [catch {testfile rm ""} msg] $msg
sl@0
   465
} {1 ENOENT}
sl@0
   466
test winFCmd-3.5 {TclpDeleteFile: errno: EACCES} {pcOnly} {
sl@0
   467
    cleanup
sl@0
   468
    set fd [open tf1 w]
sl@0
   469
    set msg [list [catch {testfile rm tf1} msg] $msg]
sl@0
   470
    close $fd
sl@0
   471
    set msg
sl@0
   472
} {1 EACCES}
sl@0
   473
test winFCmd-3.6 {TclpDeleteFile: errno: EACCES} {pcOnly} {
sl@0
   474
    cleanup
sl@0
   475
    list [catch {testfile rm nul} msg] $msg
sl@0
   476
} {1 EACCES}
sl@0
   477
test winFCmd-3.7 {TclpDeleteFile: DeleteFile succeeds} {pcOnly} {
sl@0
   478
    cleanup
sl@0
   479
    createfile tf1
sl@0
   480
    testfile rm tf1
sl@0
   481
    file exists tf1
sl@0
   482
} {0}
sl@0
   483
test winFCmd-3.8 {TclpDeleteFile: DeleteFile fails} {pcOnly} {
sl@0
   484
    cleanup
sl@0
   485
    file mkdir td1
sl@0
   486
    list [catch {testfile rm td1} msg] $msg
sl@0
   487
} {1 EISDIR}
sl@0
   488
test winFCmd-3.9 {TclpDeleteFile: errno == EACCES} {pcOnly} {
sl@0
   489
    cleanup
sl@0
   490
    set fd [open tf1 w]
sl@0
   491
    set msg [list [catch {testfile rm tf1} msg] $msg]
sl@0
   492
    close $fd
sl@0
   493
    set msg
sl@0
   494
} {1 EACCES}
sl@0
   495
test winFCmd-3.10 {TclpDeleteFile: path is readonly} {pcOnly} {
sl@0
   496
    cleanup
sl@0
   497
    createfile tf1
sl@0
   498
    testchmod 000 tf1
sl@0
   499
    testfile rm tf1
sl@0
   500
    file exists tf1
sl@0
   501
} {0}
sl@0
   502
test winFCmd-3.11 {TclpDeleteFile: still can't remove path} {pcOnly} {
sl@0
   503
    cleanup
sl@0
   504
    set fd [open tf1 w]
sl@0
   505
    testchmod 000 tf1
sl@0
   506
    set msg [list [catch {testfile rm tf1} msg] $msg]
sl@0
   507
    close $fd
sl@0
   508
    set msg
sl@0
   509
} {1 EACCES}
sl@0
   510
sl@0
   511
test winFCmd-4.1 {TclpCreateDirectory: errno: EACCES} {pcOnly nt cdrom} {
sl@0
   512
    list [catch {testfile mkdir $cdrom/dummy~~.dir} msg] $msg
sl@0
   513
} {1 EACCES}
sl@0
   514
test winFCmd-4.2 {TclpCreateDirectory: errno: EACCES} {pcOnly 95 cdrom} {
sl@0
   515
    list [catch {testfile mkdir $cdrom/dummy~~.dir} msg] $msg
sl@0
   516
} {1 ENOSPC}
sl@0
   517
test winFCmd-4.3 {TclpCreateDirectory: errno: EEXIST} {pcOnly} {
sl@0
   518
    cleanup
sl@0
   519
    file mkdir td1
sl@0
   520
    list [catch {testfile mkdir td1} msg] $msg
sl@0
   521
} {1 EEXIST}
sl@0
   522
test winFCmd-4.4 {TclpCreateDirectory: errno: ENOENT} {pcOnly} {
sl@0
   523
    cleanup
sl@0
   524
    list [catch {testfile mkdir td1/td2} msg] $msg
sl@0
   525
} {1 ENOENT}
sl@0
   526
test winFCmd-4.5 {TclpCreateDirectory: CreateDirectory succeeds} {pcOnly} {
sl@0
   527
    cleanup
sl@0
   528
    testfile mkdir td1
sl@0
   529
    file type td1
sl@0
   530
} {directory}
sl@0
   531
sl@0
   532
test winFCmd-5.1 {TclpCopyDirectory: calls TraverseWinTree} {pcOnly} {
sl@0
   533
    cleanup
sl@0
   534
    file mkdir td1
sl@0
   535
    testfile cpdir td1 td2
sl@0
   536
    list [file type td1] [file type td2]
sl@0
   537
} {directory directory}
sl@0
   538
sl@0
   539
test winFCmd-6.1 {TclpRemoveDirectory: errno: EACCES} {pcOnly} {
sl@0
   540
    cleanup
sl@0
   541
    file mkdir td1
sl@0
   542
    testchmod 000 td1
sl@0
   543
    testfile rmdir td1
sl@0
   544
    file exists td1
sl@0
   545
} {0}
sl@0
   546
test winFCmd-6.2 {TclpRemoveDirectory: errno: EEXIST} {pcOnly} {
sl@0
   547
    cleanup
sl@0
   548
    file mkdir td1/td2
sl@0
   549
    list [catch {testfile rmdir td1} msg] [file tail $msg]
sl@0
   550
} {1 {td1 EEXIST}}
sl@0
   551
test winFCmd-6.3 {TclpRemoveDirectory: errno: EACCES} {pcOnly} {
sl@0
   552
    # can't test this w/o removing everything on your hard disk first!
sl@0
   553
    # testfile rmdir /
sl@0
   554
} {}
sl@0
   555
test winFCmd-6.4 {TclpRemoveDirectory: errno: ENOENT} {pcOnly} {
sl@0
   556
    cleanup
sl@0
   557
    list [catch {testfile rmdir td1} msg] [file tail $msg]
sl@0
   558
} {1 {td1 ENOENT}}
sl@0
   559
test winFCmd-6.5 {TclpRemoveDirectory: errno: ENOENT} {pcOnly} {
sl@0
   560
    cleanup
sl@0
   561
    list [catch {testfile rmdir ""} msg] $msg
sl@0
   562
} {1 ENOENT}
sl@0
   563
test winFCmd-6.6 {TclpRemoveDirectory: errno: ENOTDIR} {pcOnly} {
sl@0
   564
    cleanup
sl@0
   565
    createfile tf1
sl@0
   566
    list [catch {testfile rmdir tf1} msg] [file tail $msg]
sl@0
   567
} {1 {tf1 ENOTDIR}}
sl@0
   568
test winFCmd-6.7 {TclpRemoveDirectory: RemoveDirectory succeeds} {pcOnly} {
sl@0
   569
    cleanup
sl@0
   570
    file mkdir td1
sl@0
   571
    testfile rmdir td1
sl@0
   572
    file exists td1
sl@0
   573
} {0}
sl@0
   574
test winFCmd-6.8 {TclpRemoveDirectory: RemoveDirectory fails} {pcOnly} {
sl@0
   575
    cleanup
sl@0
   576
    createfile tf1
sl@0
   577
    list [catch {testfile rmdir tf1} msg] [file tail $msg]
sl@0
   578
} {1 {tf1 ENOTDIR}}
sl@0
   579
test winFCmd-6.9 {TclpRemoveDirectory: errno == EACCES} {pcOnly} {
sl@0
   580
    cleanup
sl@0
   581
    file mkdir td1
sl@0
   582
    testchmod 000 td1
sl@0
   583
    testfile rmdir td1
sl@0
   584
    file exists td1
sl@0
   585
} {0}
sl@0
   586
test winFCmd-6.10 {TclpRemoveDirectory: attr == -1} {pcOnly 95} {
sl@0
   587
    cleanup
sl@0
   588
    list [catch {testfile rmdir nul} msg] $msg
sl@0
   589
} {1 {nul EACCES}}
sl@0
   590
test winFCmd-6.11 {TclpRemoveDirectory: attr == -1} {pcOnly nt} {
sl@0
   591
    cleanup
sl@0
   592
    set res [list [catch {testfile rmdir /} msg] $msg]
sl@0
   593
    # WinXP returns EEXIST, WinNT seems to return EACCES.  No policy
sl@0
   594
    # decision has been made as to which is correct.
sl@0
   595
    regsub {E(ACCES|EXIST)} $res "EACCES or EEXIST" res
sl@0
   596
    # Don't mind which drive we're on
sl@0
   597
    regsub {[A-Z]:} $res ""
sl@0
   598
} {1 {/ EACCES or EEXIST}}
sl@0
   599
test winFCmd-6.12 {TclpRemoveDirectory: errno == EACCES} {pcOnly 95} {
sl@0
   600
    cleanup
sl@0
   601
    createfile tf1
sl@0
   602
    list [catch {testfile rmdir tf1} msg] $msg
sl@0
   603
} {1 {tf1 ENOTDIR}}
sl@0
   604
test winFCmd-6.13 {TclpRemoveDirectory: write-protected} {pcOnly} {
sl@0
   605
    cleanup
sl@0
   606
    file mkdir td1
sl@0
   607
    testchmod 000 td1
sl@0
   608
    testfile rmdir td1
sl@0
   609
    file exists td1
sl@0
   610
} {0}
sl@0
   611
test winFCmd-6.14 {TclpRemoveDirectory: check if empty dir} {pcOnly 95} {
sl@0
   612
    cleanup
sl@0
   613
    file mkdir td1/td2
sl@0
   614
    list [catch {testfile rmdir td1} msg] $msg
sl@0
   615
} {1 {td1 EEXIST}}
sl@0
   616
test winFCmd-6.15 {TclpRemoveDirectory: !recursive} {pcOnly} {
sl@0
   617
    cleanup
sl@0
   618
    file mkdir td1/td2
sl@0
   619
    list [catch {testfile rmdir td1} msg] [file tail $msg]
sl@0
   620
} {1 {td1 EEXIST}}
sl@0
   621
test winFCmd-6.16 {TclpRemoveDirectory: recursive, but errno != EEXIST} {pcOnly} {
sl@0
   622
    cleanup
sl@0
   623
    createfile tf1
sl@0
   624
    list [catch {testfile rmdir -force tf1} msg] $msg
sl@0
   625
} {1 {tf1 ENOTDIR}}
sl@0
   626
test winFCmd-6.17 {TclpRemoveDirectory: calls TraverseWinTree} {pcOnly} {
sl@0
   627
    cleanup
sl@0
   628
    file mkdir td1/td2
sl@0
   629
    testfile rmdir -force td1
sl@0
   630
    file exists td1
sl@0
   631
} {0}
sl@0
   632
sl@0
   633
test winFCmd-7.1 {TraverseWinTree: targetPtr == NULL} {pcOnly} {
sl@0
   634
    cleanup
sl@0
   635
    file mkdir td1/td2/td3
sl@0
   636
    testfile rmdir -force td1
sl@0
   637
    file exists td1
sl@0
   638
} {0}
sl@0
   639
test winFCmd-7.2 {TraverseWinTree: targetPtr != NULL} {pcOnly} {
sl@0
   640
    cleanup
sl@0
   641
    file mkdir td1/td2/td3
sl@0
   642
    testfile cpdir td1 td2
sl@0
   643
    list [file exists td1] [file exists td2]
sl@0
   644
} {1 1}
sl@0
   645
test winFCmd-7.3 {TraverseWinTree: sourceAttr == -1} {pcOnly} {
sl@0
   646
    cleanup
sl@0
   647
    list [catch {testfile cpdir td1 td2} msg] $msg
sl@0
   648
} {1 {td1 ENOENT}}
sl@0
   649
test winFCmd-7.4 {TraverseWinTree: source isn't directory} {pcOnly} {
sl@0
   650
    cleanup
sl@0
   651
    file mkdir td1
sl@0
   652
    createfile td1/tf1 tf1
sl@0
   653
    testfile cpdir td1 td2
sl@0
   654
    contents td2/tf1
sl@0
   655
} {tf1}
sl@0
   656
test winFCmd-7.5 {TraverseWinTree: call TraversalCopy: DOTREE_F} {pcOnly} {
sl@0
   657
    cleanup
sl@0
   658
    file mkdir td1
sl@0
   659
    createfile td1/tf1 tf1
sl@0
   660
    testfile cpdir td1 td2
sl@0
   661
    contents td2/tf1
sl@0
   662
} {tf1}
sl@0
   663
test winFCmd-7.6 {TraverseWinTree: call TraversalDelete: DOTREE_F} {pcOnly} {
sl@0
   664
    cleanup
sl@0
   665
    file mkdir td1
sl@0
   666
    createfile td1/tf1 tf1
sl@0
   667
    testfile rmdir -force td1
sl@0
   668
    file exists td1
sl@0
   669
} {0}
sl@0
   670
test winFCmd-7.7 {TraverseWinTree: append \ to source if necessary} {pcOnly} {
sl@0
   671
    cleanup
sl@0
   672
    file mkdir td1
sl@0
   673
    createfile td1/tf1 tf1
sl@0
   674
    testfile cpdir td1 td2
sl@0
   675
    contents td2/tf1
sl@0
   676
} {tf1}    
sl@0
   677
test winFCmd-7.8 {TraverseWinTree: append \ to source if necessary} {pcOnly 95 cdrom} {
sl@0
   678
    # cdrom can return either d:\ or D:/, but we only care about the errcode
sl@0
   679
    list [catch {testfile rmdir $cdrom/} msg] [lindex $msg 1]
sl@0
   680
} {1 EEXIST}
sl@0
   681
test winFCmd-7.9 {TraverseWinTree: append \ to source if necessary} {pcOnly nt cdrom} {
sl@0
   682
    list [catch {testfile rmdir $cdrom/} msg]  [lindex $msg 1]
sl@0
   683
} {1 EACCES}
sl@0
   684
test winFCmd-7.10 {TraverseWinTree: can't read directory: handle == INVALID} \
sl@0
   685
	{pcOnly} {
sl@0
   686
    # can't make it happen
sl@0
   687
} {}
sl@0
   688
test winFCmd-7.11 {TraverseWinTree: call TraversalCopy: DOTREE_PRED} {pcOnly} {
sl@0
   689
    cleanup
sl@0
   690
    file mkdir td1
sl@0
   691
    createfile td1/tf1 tf1
sl@0
   692
    testchmod 000 td1
sl@0
   693
    testfile cpdir td1 td2
sl@0
   694
    list [file exists td2] [file writable td2]
sl@0
   695
} {1 1}
sl@0
   696
test winFCmd-7.12 {TraverseWinTree: call TraversalDelete: DOTREE_PRED} {pcOnly} {
sl@0
   697
    cleanup
sl@0
   698
    file mkdir td1
sl@0
   699
    createfile td1/tf1 tf1
sl@0
   700
    testfile rmdir -force td1
sl@0
   701
    file exists td1
sl@0
   702
} {0}
sl@0
   703
test winFCmd-7.13 {TraverseWinTree: append \ to target if necessary} {pcOnly} {
sl@0
   704
    cleanup
sl@0
   705
    file mkdir td1
sl@0
   706
    createfile td1/tf1 tf1
sl@0
   707
    testfile cpdir td1 td2
sl@0
   708
    contents td2/tf1
sl@0
   709
} {tf1}    
sl@0
   710
test winFCmd-7.14 {TraverseWinTree: append \ to target if necessary} {pcOnly 95} {
sl@0
   711
    cleanup
sl@0
   712
    file mkdir td1
sl@0
   713
    list [catch {testfile cpdir td1 /} msg] $msg
sl@0
   714
} {1 {/ EEXIST}}
sl@0
   715
test winFCmd-7.15 {TraverseWinTree: append \ to target if necessary} {pcOnly nt} {
sl@0
   716
    cleanup
sl@0
   717
    file mkdir td1
sl@0
   718
    list [catch {testfile cpdir td1 /} msg] $msg
sl@0
   719
} {1 {/ EACCES}}
sl@0
   720
test winFCmd-7.16 {TraverseWinTree: recurse on files: no files} {pcOnly} {
sl@0
   721
    cleanup
sl@0
   722
    file mkdir td1
sl@0
   723
    testfile cpdir td1 td2
sl@0
   724
} {}
sl@0
   725
test winFCmd-7.17 {TraverseWinTree: recurse on files: one file} {pcOnly} {
sl@0
   726
    cleanup
sl@0
   727
    file mkdir td1
sl@0
   728
    createfile td1/td2
sl@0
   729
    testfile cpdir td1 td2
sl@0
   730
    glob td2/*
sl@0
   731
} {td2/td2}
sl@0
   732
test winFCmd-7.18 {TraverseWinTree: recurse on files: several files and dir} \
sl@0
   733
	{pcOnly} {
sl@0
   734
    cleanup
sl@0
   735
    file mkdir td1
sl@0
   736
    createfile td1/tf1
sl@0
   737
    createfile td1/tf2
sl@0
   738
    file mkdir td1/td2/td3
sl@0
   739
    createfile td1/tf3
sl@0
   740
    createfile td1/tf4
sl@0
   741
    testfile cpdir td1 td2
sl@0
   742
    lsort [glob td2/*]
sl@0
   743
} {td2/td2 td2/tf1 td2/tf2 td2/tf3 td2/tf4}
sl@0
   744
test winFCmd-7.19 {TraverseWinTree: call TraversalCopy: DOTREE_POSTD} {pcOnly} {
sl@0
   745
    cleanup
sl@0
   746
    file mkdir td1
sl@0
   747
    createfile td1/tf1 tf1
sl@0
   748
    testchmod 000 td1
sl@0
   749
    testfile cpdir td1 td2
sl@0
   750
    list [file exists td2] [file writable td2]
sl@0
   751
} {1 1}
sl@0
   752
test winFCmd-7.20 {TraverseWinTree: call TraversalDelete: DOTREE_POSTD} \
sl@0
   753
	{pcOnly} {
sl@0
   754
    cleanup
sl@0
   755
    file mkdir td1
sl@0
   756
    createfile td1/tf1 tf1
sl@0
   757
    testfile rmdir -force td1
sl@0
   758
    file exists td1
sl@0
   759
} {0}
sl@0
   760
test winFCmd-7.21 {TraverseWinTree: fill errorPtr} {pcOnly} {
sl@0
   761
    cleanup
sl@0
   762
    list [catch {testfile cpdir td1 td2} msg] $msg
sl@0
   763
} {1 {td1 ENOENT}}
sl@0
   764
sl@0
   765
test winFCmd-8.1 {TraversalCopy: DOTREE_F} {pcOnly} {
sl@0
   766
    cleanup
sl@0
   767
    file mkdir td1
sl@0
   768
    list [catch {testfile cpdir td1 td1} msg] $msg
sl@0
   769
} {1 {td1 EEXIST}}
sl@0
   770
test winFCmd-8.2 {TraversalCopy: DOTREE_PRED} {pcOnly} {
sl@0
   771
    cleanup
sl@0
   772
    file mkdir td1/td2
sl@0
   773
    testchmod 000 td1
sl@0
   774
    testfile cpdir td1 td2
sl@0
   775
    list [file writable td1] [file writable td1/td2]
sl@0
   776
} {0 1}
sl@0
   777
test winFCmd-8.3 {TraversalCopy: DOTREE_POSTD} {pcOnly} {
sl@0
   778
    cleanup
sl@0
   779
    file mkdir td1
sl@0
   780
    testfile cpdir td1 td2
sl@0
   781
} {}
sl@0
   782
sl@0
   783
test winFCmd-9.1 {TraversalDelete: DOTREE_F} {pcOnly} {
sl@0
   784
    cleanup
sl@0
   785
    file mkdir td1
sl@0
   786
    createfile td1/tf1
sl@0
   787
    testfile rmdir -force td1
sl@0
   788
} {}
sl@0
   789
test winFCmd-9.2 {TraversalDelete: DOTREE_F} {pcOnly 95} {
sl@0
   790
    cleanup
sl@0
   791
    file mkdir td1
sl@0
   792
    set fd [open td1/tf1 w]
sl@0
   793
    set msg [list [catch {testfile rmdir -force td1} msg] $msg]
sl@0
   794
    close $fd
sl@0
   795
    set msg
sl@0
   796
} {1 {td1\tf1 EACCES}}
sl@0
   797
test winFCmd-9.3 {TraversalDelete: DOTREE_PRED} {pcOnly} {
sl@0
   798
    cleanup
sl@0
   799
    file mkdir td1/td2
sl@0
   800
    testchmod 000 td1
sl@0
   801
    testfile rmdir -force td1
sl@0
   802
    file exists td1
sl@0
   803
} {0}
sl@0
   804
test winFCmd-9.4 {TraversalDelete: DOTREE_POSTD} {pcOnly} {
sl@0
   805
    cleanup
sl@0
   806
    file mkdir td1/td1/td3/td4/td5
sl@0
   807
    testfile rmdir -force td1
sl@0
   808
} {}
sl@0
   809
sl@0
   810
test winFCmd-10.1 {AttributesPosixError - get} {pcOnly} {
sl@0
   811
    cleanup
sl@0
   812
    list [catch {file attributes td1 -archive} msg] $msg
sl@0
   813
} {1 {could not read "td1": no such file or directory}}
sl@0
   814
test winFCmd-10.2 {AttributesPosixError - set} {pcOnly} {
sl@0
   815
    cleanup
sl@0
   816
    list [catch {file attributes td1 -archive 0} msg] $msg
sl@0
   817
} {1 {could not read "td1": no such file or directory}}
sl@0
   818
sl@0
   819
test winFCmd-11.1 {GetWinFileAttributes} {pcOnly} {
sl@0
   820
    cleanup
sl@0
   821
    close [open td1 w]
sl@0
   822
    list [catch {file attributes td1 -archive} msg] $msg [cleanup]
sl@0
   823
} {0 1 {}}
sl@0
   824
test winFCmd-11.2 {GetWinFileAttributes} {pcOnly} {
sl@0
   825
    cleanup
sl@0
   826
    close [open td1 w]
sl@0
   827
    list [catch {file attributes td1 -readonly} msg] $msg [cleanup]
sl@0
   828
} {0 0 {}}
sl@0
   829
test winFCmd-11.3 {GetWinFileAttributes} {pcOnly} {
sl@0
   830
    cleanup
sl@0
   831
    close [open td1 w]
sl@0
   832
    list [catch {file attributes td1 -hidden} msg] $msg [cleanup]
sl@0
   833
} {0 0 {}}
sl@0
   834
test winFCmd-11.4 {GetWinFileAttributes} {pcOnly} {
sl@0
   835
    cleanup
sl@0
   836
    close [open td1 w]
sl@0
   837
    list [catch {file attributes td1 -system} msg] $msg [cleanup]
sl@0
   838
} {0 0 {}}
sl@0
   839
test winFCmd-11.5 {GetWinFileAttributes} {pcOnly} {
sl@0
   840
    # attr of relative paths that resolve to root was failing
sl@0
   841
    # don't care about answer, just that test runs.
sl@0
   842
sl@0
   843
    set old [pwd]
sl@0
   844
    cd c:/
sl@0
   845
    file attr c:	    
sl@0
   846
    file attr c:.
sl@0
   847
    file attr . 
sl@0
   848
    cd $old
sl@0
   849
} {}
sl@0
   850
test winFCmd-11.6 {GetWinFileAttributes} {pcOnly} {
sl@0
   851
    file attr c:/ -hidden
sl@0
   852
} {0}
sl@0
   853
sl@0
   854
test winFCmd-12.1 {ConvertFileNameFormat} {pcOnly} {
sl@0
   855
    cleanup
sl@0
   856
    close [open td1 w]
sl@0
   857
    list [catch {string tolower [file attributes td1 -longname]} msg] $msg [cleanup]
sl@0
   858
} {0 td1 {}}
sl@0
   859
test winFCmd-12.2 {ConvertFileNameFormat} {pcOnly} {
sl@0
   860
    cleanup
sl@0
   861
    file mkdir td1
sl@0
   862
    close [open td1/td1 w]
sl@0
   863
    list [catch {string tolower [file attributes td1/td1 -longname]} msg] $msg [cleanup]
sl@0
   864
} {0 td1/td1 {}}
sl@0
   865
test winFCmd-12.3 {ConvertFileNameFormat} {pcOnly} {
sl@0
   866
    cleanup
sl@0
   867
    file mkdir td1
sl@0
   868
    file mkdir td1/td2
sl@0
   869
    close [open td1/td3 w]
sl@0
   870
    list [catch {string tolower [file attributes td1/td2/../td3 -longname]} msg] $msg [cleanup]
sl@0
   871
} {0 td1/td2/../td3 {}}
sl@0
   872
test winFCmd-12.4 {ConvertFileNameFormat} {pcOnly} {
sl@0
   873
    cleanup
sl@0
   874
    close [open td1 w]
sl@0
   875
    list [catch {string tolower [file attributes ./td1 -longname]} msg] $msg [cleanup]
sl@0
   876
} {0 ./td1 {}}
sl@0
   877
test winFCmd-12.5 {ConvertFileNameFormat: absolute path} {pcOnly} {
sl@0
   878
    list [file attributes / -longname] [file attributes \\ -longname]
sl@0
   879
} {/ /}
sl@0
   880
test winFCmd-12.6 {ConvertFileNameFormat: absolute path with drive} {pcOnly} {
sl@0
   881
    catch {file delete -force -- c:/td1}
sl@0
   882
    close [open c:/td1 w]
sl@0
   883
    list [catch {string tolower [file attributes c:/td1 -longname]} msg] $msg [file delete -force -- c:/td1]
sl@0
   884
} {0 c:/td1 {}}
sl@0
   885
test winFCmd-12.7 {ConvertFileNameFormat} {nonPortable pcOnly} {
sl@0
   886
    string tolower [file attributes //bisque/tcl/ws -longname]
sl@0
   887
} {//bisque/tcl/ws}
sl@0
   888
test winFCmd-12.8 {ConvertFileNameFormat} {pcOnly longFileNames} {
sl@0
   889
    cleanup
sl@0
   890
    close [open td1 w]
sl@0
   891
    list [catch {string tolower [file attributes td1 -longname]} msg] $msg [cleanup]
sl@0
   892
} {0 td1 {}}
sl@0
   893
test winFCmd-12.10 {ConvertFileNameFormat} {longFileNames pcOnly} {
sl@0
   894
    cleanup
sl@0
   895
    close [open td1td1td1 w]
sl@0
   896
    list [catch {file attributes td1td1td1 -shortname}] [cleanup]
sl@0
   897
} {0 {}}
sl@0
   898
test winFCmd-12.11 {ConvertFileNameFormat} {longFileNames pcOnly} {
sl@0
   899
    cleanup
sl@0
   900
    close [open td1 w]
sl@0
   901
    list [catch {string tolower [file attributes td1 -shortname]} msg] $msg [cleanup]
sl@0
   902
} {0 td1 {}}
sl@0
   903
sl@0
   904
test winFCmd-13.1 {GetWinFileLongName} {pcOnly} {
sl@0
   905
    cleanup
sl@0
   906
    close [open td1 w]
sl@0
   907
    list [catch {string tolower [file attributes td1 -longname]} msg] $msg [cleanup]
sl@0
   908
} {0 td1 {}}
sl@0
   909
sl@0
   910
test winFCmd-14.1 {GetWinFileShortName} {pcOnly} {
sl@0
   911
    cleanup
sl@0
   912
    close [open td1 w]
sl@0
   913
    list [catch {string tolower [file attributes td1 -shortname]} msg] $msg [cleanup]
sl@0
   914
} {0 td1 {}}
sl@0
   915
sl@0
   916
test winFCmd-15.1 {SetWinFileAttributes} {pcOnly} {
sl@0
   917
    cleanup
sl@0
   918
    list [catch {file attributes td1 -archive 0} msg] $msg
sl@0
   919
} {1 {could not read "td1": no such file or directory}}
sl@0
   920
test winFCmd-15.2 {SetWinFileAttributes - archive} {pcOnly} {
sl@0
   921
    cleanup
sl@0
   922
    close [open td1 w]
sl@0
   923
    list [catch {file attributes td1 -archive 1} msg] $msg [file attributes td1 -archive] [cleanup]
sl@0
   924
} {0 {} 1 {}}
sl@0
   925
test winFCmd-15.3 {SetWinFileAttributes - archive} {pcOnly} {
sl@0
   926
    cleanup
sl@0
   927
    close [open td1 w]
sl@0
   928
    list [catch {file attributes td1 -archive 0} msg] $msg [file attributes td1 -archive] [cleanup]
sl@0
   929
} {0 {} 0 {}}
sl@0
   930
test winFCmd-15.4 {SetWinFileAttributes - hidden} {pcOnly} {
sl@0
   931
    cleanup
sl@0
   932
    close [open td1 w]
sl@0
   933
    list [catch {file attributes td1 -hidden 1} msg] $msg [file attributes td1 -hidden] [file attributes td1 -hidden 0] [cleanup]
sl@0
   934
} {0 {} 1 {} {}}
sl@0
   935
test winFCmd-15.5 {SetWinFileAttributes - hidden} {pcOnly} {
sl@0
   936
    cleanup
sl@0
   937
    close [open td1 w]
sl@0
   938
    list [catch {file attributes td1 -hidden 0} msg] $msg [file attributes td1 -hidden] [cleanup]
sl@0
   939
} {0 {} 0 {}}
sl@0
   940
test winFCmd-15.6 {SetWinFileAttributes - readonly} {pcOnly} {
sl@0
   941
    cleanup
sl@0
   942
    close [open td1 w]
sl@0
   943
    list [catch {file attributes td1 -readonly 1} msg] $msg [file attributes td1 -readonly] [cleanup]
sl@0
   944
} {0 {} 1 {}}
sl@0
   945
test winFCmd-15.7 {SetWinFileAttributes - readonly} {pcOnly} {
sl@0
   946
    cleanup
sl@0
   947
    close [open td1 w]
sl@0
   948
    list [catch {file attributes td1 -readonly 0} msg] $msg [file attributes td1 -readonly] [cleanup]
sl@0
   949
} {0 {} 0 {}}
sl@0
   950
test winFCmd-15.8 {SetWinFileAttributes - system} {pcOnly} {
sl@0
   951
    cleanup
sl@0
   952
    close [open td1 w]
sl@0
   953
    list [catch {file attributes td1 -system 1} msg] $msg [file attributes td1 -system] [cleanup]
sl@0
   954
} {0 {} 1 {}}
sl@0
   955
test winFCmd-15.9 {SetWinFileAttributes - system} {pcOnly} {
sl@0
   956
    cleanup
sl@0
   957
    close [open td1 w]
sl@0
   958
    list [catch {file attributes td1 -system 0} msg] $msg [file attributes td1 -system] [cleanup]
sl@0
   959
} {0 {} 0 {}}
sl@0
   960
test winFCmd-15.10 {SetWinFileAttributes - failing} {pcOnly cdrom} {
sl@0
   961
    cleanup
sl@0
   962
    catch {file attributes $cdfile -archive 1}
sl@0
   963
} {1}
sl@0
   964
test winFCmd-16.1 {Windows file normalization} {pcOnly} {
sl@0
   965
    list [file normalize c:/] [file normalize C:/]
sl@0
   966
} {C:/ C:/}
sl@0
   967
test winFCmd-16.2 {Windows file normalization} {pcOnly} {
sl@0
   968
    close [open td1... w]
sl@0
   969
    set res [file tail [file normalize td1]]
sl@0
   970
    file delete td1...
sl@0
   971
    set res
sl@0
   972
} {td1}
sl@0
   973
sl@0
   974
set pwd [pwd]
sl@0
   975
set d [string index $pwd 0]
sl@0
   976
sl@0
   977
test winFCmd-16.3 {Windows file normalization} {pcOnly} {
sl@0
   978
    file norm ${d}:foo
sl@0
   979
} [file join $pwd foo]
sl@0
   980
test winFCmd-16.4 {Windows file normalization} {pcOnly} {
sl@0
   981
    file norm [string tolower ${d}]:foo
sl@0
   982
} [file join $pwd foo]
sl@0
   983
test winFCmd-16.5 {Windows file normalization} {pcOnly} {
sl@0
   984
    file norm ${d}:foo/bar
sl@0
   985
} [file join $pwd foo/bar]
sl@0
   986
test winFCmd-16.6 {Windows file normalization} {pcOnly} {
sl@0
   987
    file norm ${d}:foo\\bar
sl@0
   988
} [file join $pwd foo/bar]
sl@0
   989
test winFCmd-16.7 {Windows file normalization} {pcOnly} {
sl@0
   990
    file norm /bar
sl@0
   991
} "${d}:/bar"
sl@0
   992
test winFCmd-16.8 {Windows file normalization} {pcOnly} {
sl@0
   993
    file norm ///bar
sl@0
   994
} "${d}:/bar"
sl@0
   995
test winFCmd-16.9 {Windows file normalization} {pcOnly} {
sl@0
   996
    file norm /bar/foo
sl@0
   997
} "${d}:/bar/foo"
sl@0
   998
if {$d eq "C"} { set dd "D" } else { set dd "C" }
sl@0
   999
test winFCmd-16.10 {Windows file normalization} {pcOnly} {
sl@0
  1000
    file norm ${dd}:foo
sl@0
  1001
} "${dd}:/foo"
sl@0
  1002
test winFCmd-16.11 {Windows file normalization} {pcOnly cdrom} {
sl@0
  1003
    cd ${d}:
sl@0
  1004
    cd $cdrom
sl@0
  1005
    cd ${d}:
sl@0
  1006
    cd $cdrom
sl@0
  1007
    # Must not crash
sl@0
  1008
    set result "no crash"
sl@0
  1009
} {no crash}
sl@0
  1010
test winFCmd-16.12 {Windows file normalization} {pcOnly} {
sl@0
  1011
    set oldhome ""
sl@0
  1012
    catch {set oldhome $::env(HOME)}
sl@0
  1013
    set ::env(HOME) ${d}:
sl@0
  1014
    cd
sl@0
  1015
    set result [pwd]; # <- Must not crash
sl@0
  1016
    set ::env(HOME) $oldhome
sl@0
  1017
    set result
sl@0
  1018
} ${d}:/
sl@0
  1019
sl@0
  1020
cd $pwd
sl@0
  1021
unset d dd pwd
sl@0
  1022
sl@0
  1023
test winFCmd-18.1 {Windows reserved path names} -constraints win -body {
sl@0
  1024
    file pathtype com1
sl@0
  1025
} -result "absolute"
sl@0
  1026
sl@0
  1027
test winFCmd-18.1.2 {Windows reserved path names} -constraints win -body {
sl@0
  1028
    file pathtype com4
sl@0
  1029
} -result "absolute"
sl@0
  1030
sl@0
  1031
test winFCmd-18.1.3 {Windows reserved path names} -constraints win -body {
sl@0
  1032
    file pathtype com5
sl@0
  1033
} -result "relative"
sl@0
  1034
sl@0
  1035
test winFCmd-18.1.4 {Windows reserved path names} -constraints win -body {
sl@0
  1036
    file pathtype lpt3
sl@0
  1037
} -result "absolute"
sl@0
  1038
sl@0
  1039
test winFCmd-18.1.5 {Windows reserved path names} -constraints win -body {
sl@0
  1040
    file pathtype lpt4
sl@0
  1041
} -result "relative"
sl@0
  1042
sl@0
  1043
test winFCmd-18.1.6 {Windows reserved path names} -constraints win -body {
sl@0
  1044
    file pathtype nul
sl@0
  1045
} -result "absolute"
sl@0
  1046
sl@0
  1047
test winFCmd-18.1.7 {Windows reserved path names} -constraints win -body {
sl@0
  1048
    file pathtype null
sl@0
  1049
} -result "relative"
sl@0
  1050
sl@0
  1051
test winFCmd-18.2 {Windows reserved path names} -constraints win -body {
sl@0
  1052
    file pathtype com1:
sl@0
  1053
} -result "absolute"
sl@0
  1054
sl@0
  1055
test winFCmd-18.3 {Windows reserved path names} -constraints win -body {
sl@0
  1056
    file pathtype COM1
sl@0
  1057
} -result "absolute"
sl@0
  1058
sl@0
  1059
test winFCmd-18.4 {Windows reserved path names} -constraints win -body {
sl@0
  1060
    file pathtype CoM1:
sl@0
  1061
} -result "absolute"
sl@0
  1062
sl@0
  1063
test winFCmd-18.5 {Windows reserved path names} -constraints win -body {
sl@0
  1064
    file normalize com1:
sl@0
  1065
} -result COM1
sl@0
  1066
sl@0
  1067
test winFCmd-18.6 {Windows reserved path names} -constraints win -body {
sl@0
  1068
    file normalize COM1:
sl@0
  1069
} -result COM1
sl@0
  1070
sl@0
  1071
test winFCmd-18.7 {Windows reserved path names} -constraints win -body {
sl@0
  1072
    file normalize cOm1
sl@0
  1073
} -result COM1
sl@0
  1074
sl@0
  1075
test winFCmd-18.8 {Windows reserved path names} -constraints win -body {
sl@0
  1076
    file normalize cOm1:
sl@0
  1077
} -result COM1
sl@0
  1078
sl@0
  1079
# This block of code used to occur after the "return" call, so I'm
sl@0
  1080
# commenting it out and assuming that this code is still under construction.
sl@0
  1081
#foreach source {tef ted tnf tnd "" nul com1} {
sl@0
  1082
#    foreach chmodsrc {000 755} {
sl@0
  1083
#        foreach dest "tfn tfe tdn tdempty tdfull td1/td2 $p $p/td1 {} nul" {
sl@0
  1084
#	    foreach chmoddst {000 755} {
sl@0
  1085
#		puts hi
sl@0
  1086
#		cleanup
sl@0
  1087
#		file delete -force ted tef
sl@0
  1088
#		file mkdir ted
sl@0
  1089
#		createfile tef
sl@0
  1090
#		createfile tfe
sl@0
  1091
#		file mkdir tdempty
sl@0
  1092
#		file mkdir tdfull/td1/td2
sl@0
  1093
#
sl@0
  1094
#		catch {testchmod $chmodsrc $source}
sl@0
  1095
#		catch {testchmod $chmoddst $dest}
sl@0
  1096
#
sl@0
  1097
#		if [catch {file rename $source $dest} msg] {
sl@0
  1098
#		    puts "file rename $source ($chmodsrc) $dest ($chmoddst)"
sl@0
  1099
#		    puts $msg
sl@0
  1100
#		}
sl@0
  1101
#	    }
sl@0
  1102
#	}
sl@0
  1103
#    }
sl@0
  1104
#}
sl@0
  1105
sl@0
  1106
# cleanup
sl@0
  1107
cleanup
sl@0
  1108
::tcltest::cleanupTests
sl@0
  1109
return