1File(3)               User Contributed Perl Documentation              File(3)
2
3
4

NAME

6       Test::File -- test file attributes
7

SYNOPSIS

9       use Test::File;
10

DESCRIPTION

12       This modules provides a collection of test utilities for file
13       attributes.
14
15       Some file attributes depend on the owner of the process testing the
16       file in the same way the file test operators do.  For instance, root
17       (or super-user or Administrator) may always be able to read files no
18       matter the permissions.
19
20       Some attributes don't make sense outside of Unix, either, so some tests
21       automatically skip if they think they won't work on the platform.  If
22       you have a way to make these functions work on Windows, for instance,
23       please send me a patch. :)
24
25       Functions
26
27       file_exists_ok( FILENAME [, NAME ] )
28           Ok if the file exists, and not ok otherwise.
29
30       file_not_exists_ok( FILENAME [, NAME ] )
31           Ok if the file does not exist, and not okay if it does exist.
32
33       file_empty_ok( FILENAME [, NAME ] )
34           Ok if the file exists and has empty size, not ok if the file does
35           not exist or exists with non-zero size.
36
37       file_not_empty_ok( FILENAME [, NAME ] )
38           Ok if the file exists and has non-zero size, not ok if the file
39           does not exist or exists with zero size.
40
41       file_size_ok( FILENAME, SIZE [, NAME ]  )
42           Ok if the file exists and has SIZE size in bytes (exactly), not ok
43           if the file does not exist or exists with size other than SIZE.
44
45       file_max_size_ok( FILENAME, MAX [, NAME ] )
46           Ok if the file exists and has size less than or equal to MAX bytes,
47           not ok if the file does not exist or exists with size greater than
48           MAX bytes.
49
50       file_min_size_ok( FILENAME, MIN [, NAME ] )
51           Ok if the file exists and has size greater than or equal to MIN
52           bytes, not ok if the file does not exist or exists with size less
53           than MIN bytes.
54
55       file_readable_ok( FILENAME [, NAME ] )
56           Ok if the file exists and is readable, not ok if the file does not
57           exist or is not readable.
58
59       file_not_readable_ok( FILENAME [, NAME ] )
60           Ok if the file exists and is not readable, not ok if the file does
61           not exist or is readable.
62
63       file_writeable_ok( FILENAME [, NAME ] )
64           Ok if the file exists and is writeable, not ok if the file does not
65           exist or is not writeable.
66
67       file_not_writeable_ok( FILENAME [, NAME ] )
68           Ok if the file exists and is not writeable, not ok if the file does
69           not exist or is writeable.
70
71       file_executable_ok( FILENAME [, NAME ] )
72           Ok if the file exists and is executable, not ok if the file does
73           not exist or is not executable.
74
75           This test automatically skips if it thinks it is on a Windows plat‐
76           form.
77
78       file_not_executable_ok( FILENAME [, NAME ] )
79           Ok if the file exists and is not executable, not ok if the file
80           does not exist or is executable.
81
82           This test automatically skips if it thinks it is on a Windows plat‐
83           form.
84
85       file_mode_is( FILENAME, MODE [, NAME ] )
86           Ok if the file exists and the mode matches, not ok if the file does
87           not exist or the mode does not match.
88
89           This test automatically skips if it thinks it is on a Windows plat‐
90           form.
91
92           Contributed by Shawn Sorichetti "<ssoriche@coloredblocks.net>"
93
94       file_mode_isnt( FILENAME, MODE [, NAME ] )
95           Ok if the file exists and mode does not match, not ok if the file
96           does not exist or mode does match.
97
98           This test automatically skips if it thinks it is on a Windows plat‐
99           form.
100
101           Contributed by Shawn Sorichetti "<ssoriche@coloredblocks.net>"
102
103       file_is_symlink_ok( FILENAME [, NAME] )
104           Ok is FILENAME is a symlink, even if it points to a non-existent
105           file. This test automatically skips if the operating system does
106           not support symlinks. If the file does not exist, the test fails.
107
108           The optional NAME parameter is the name of the test.
109
110       symlink_target_exists_ok( SYMLINK [, TARGET] [, NAME] )
111           Ok is FILENAME is a symlink and it points to a existing file. With
112           the optional TARGET argument, the test fails if SYMLINK's target is
113           not TARGET. This test automatically skips if the operating system
114           does not support symlinks. If the file does not exist, the test
115           fails.
116
117           The optional NAME parameter is the name of the test.
118
119       symlink_target_dangles_ok( SYMLINK [, NAME] )
120           Ok if FILENAME is a symlink and if it doesn't point to a existing
121           file. This test automatically skips if the operating system does
122           not support symlinks. If the file does not exist, the test fails.
123
124           The optional NAME parameter is the name of the test.
125
126       link_count_is_ok( FILE, LINK_COUNT [, NAME] )
127           Ok if the link count to FILE is LINK_COUNT. LINK_COUNT is inter‐
128           preted as an integer. A LINK_COUNT that evaluates to 0 returns Ok
129           if the file does not exist. This test automatically skips if the
130           operating system does not support symlinks. If the file does not
131           exist, the test fails.
132
133           The optional NAME parameter is the name of the test.
134
135       link_count_gt_ok( FILE, LINK_COUNT [, NAME] )
136           Ok if the link count to FILE is greater than LINK_COUNT. LINK_COUNT
137           is interpreted as an integer. A LINK_COUNT that evaluates to 0
138           returns Ok if the file has at least one link. This test automati‐
139           cally skips if the operating system does not support symlinks. If
140           the file does not exist, the test fails.
141
142           The optional NAME parameter is the name of the test.
143
144       link_count_lt_ok( FILE, LINK_COUNT [, NAME] )
145           Ok if the link count to FILE is less than LINK_COUNT. LINK_COUNT is
146           interpreted as an integer. A LINK_COUNT that evaluates to 0 returns
147           Ok if the file has at least one link. This test automatically skips
148           if the operating system does not support symlinks. If the file does
149           not exist, the test fails.
150
151           The optional NAME parameter is the name of the test.
152
153       owner_is( FILE , OWNER [, NAME] )
154           Ok if FILE's owner is the same as OWNER.  OWNER may be a text user
155           name or a numeric userid.  Test skips on Dos, and Mac OS <= 9.  If
156           the file does not exist, the test fails.
157
158           The optional NAME parameter is the name of the test.
159
160           Contributed by Dylan Martin
161
162       owner_isnt( FILE, OWNER [, NAME] )
163           Ok if FILE's owner is not the same as OWNER.  OWNER may be a text
164           user name or a numeric userid.  Test skips on Dos and Mac OS <= 9.
165           If the file does not exist, the test fails.
166
167           The optional NAME parameter is the name of the test.
168
169           Contributed by Dylan Martin
170
171       group_is( FILE , GROUP [, NAME] )
172           Ok if FILE's group is the same as GROUP.  GROUP may be a text group
173           name or a numeric group id.  Test skips on Dos, Mac OS <= 9 and any
174           other operating systems that do not support getpwuid() and friends.
175           If the file does not exist, the test fails.
176
177           The optional NAME parameter is the name of the test.
178
179           Contributed by Dylan Martin
180
181       group_isnt( FILE , GROUP [, NAME] )
182           Ok if FILE's group is not the same as GROUP.  GROUP may be a text
183           group name or a numeric group id.  Test skips on Dos, Mac OS <= 9
184           and any other operating systems that do not support getpwuid() and
185           friends.  If the file does not exist, the test fails.
186
187           The optional NAME parameter is the name of the test.
188
189           Contributed by Dylan Martin
190

TO DO

192       * check properties for other users (readable_by_root, for instance)
193
194       * check times
195
196       * check number of links to file
197
198       * check path parts (directory, filename, extension)
199

SEE ALSO

201       Test::Builder, Test::More
202

SOURCE AVAILABILITY

204       This source is part of a SourceForge project which always has the lat‐
205       est sources in CVS, as well as all of the previous releases.
206
207               http://sourceforge.net/projects/brian-d-foy/
208
209       If, for some reason, I disappear from the world, one of the other mem‐
210       bers of the project can shepherd this module appropriately.
211

AUTHOR

213       brian d foy, "<bdfoy@cpan.org>"
214

CREDITS

216       Shawn Sorichetti "<ssoriche@coloredblocks.net>" provided some func‐
217       tions.
218
219       Tom Metro helped me figure out some Windows capabilities.
220
221       Dylan Martin added "owner_is" and "owner_isnt"
222
224       Copyright 2002-2006, brian d foy, All Rights Reserved
225
226       You may use, modify, and distribute this under the same terms as Perl
227       itself.
228
229
230
231perl v5.8.8                       2006-07-08                           File(3)
Impressum