2 * Copyright 1993-2002 Christopher Seiwald and Perforce Software, Inc.
4 * This file is part of Jam - see jam.c for Copyright information.
8 * Copyright 2001-2004 David Abrahams.
9 * Distributed under the Boost Software License, Version 1.0.
10 * (See accompanying file LICENSE_1_0.txt or http://www.boost.org/LICENSE_1_0.txt)
17 /* note that we use "fileunix.c" when compiling with EMX on OS/2 */
18 # if defined(OS_OS2) && !defined(__EMX__)
24 * fileos2.c - scan directories and archives on NT
28 * file_dirscan() - scan a directory for files
29 * file_time() - get timestamp of file, if not done by file_dirscan()
30 * file_archscan() - scan an archive for files
32 * File_dirscan() and file_archscan() call back a caller provided function
33 * for each file found. A flag to this callback function lets file_dirscan()
34 * and file_archscan() indicate that a timestamp is being provided with the
35 * file. If file_dirscan() or file_archscan() do not provide the file's
36 * timestamp, interested parties may later call file_time().
38 * 07/10/95 (taylor) Findfirst() returns the first file on NT.
39 * 05/03/96 (seiwald) split apart into pathnt.c
40 * 09/22/00 (seiwald) handle \ and c:\ specially: don't add extra /
44 * file_dirscan() - scan a directory for files
57 struct _find_t finfo[1];
59 /* First enter directory itself */
61 memset( (char *)&f, '\0', sizeof( f ) );
64 f.f_dir.len = strlen(dir);
66 dir = *dir ? dir : ".";
68 /* Special case \ or d:\ : enter it */
69 string_copy( filespec, dir );
71 if ( f.f_dir.len == 1 && f.f_dir.ptr[0] == '\\' )
72 (*func)( closure, dir, 0 /* not stat()'ed */, (time_t)0 );
73 else if ( f.f_dir.len == 3 && f.f_dir.ptr[1] == ':' )
74 (*func)( closure, dir, 0 /* not stat()'ed */, (time_t)0 );
76 string_push_back( filespec, '/' );
78 string_push_back( filespec, '*' );
80 /* Now enter contents of directory */
83 printf( "scan directory %s\n", filespec->value );
85 /* Time info in dos find_t is not very useful. It consists */
86 /* of a separate date and time, and putting them together is */
87 /* not easy. So we leave that to a later stat() call. */
89 if ( !_dos_findfirst( filespec->value, _A_NORMAL|_A_RDONLY|_A_SUBDIR, finfo ) )
92 string_new( filename );
95 f.f_base.ptr = finfo->name;
96 f.f_base.len = strlen( finfo->name );
98 string_truncate( filename, 0 );
99 path_build( &f, filename, 0 );
100 (*func)( closure, filename->value, 0 /* not stat()'ed */, (time_t)0 );
102 while ( !_dos_findnext( finfo ) );
103 string_free( filename );
108 * file_time() - get timestamp of file, if not done by file_dirscan()
116 /* This is called on OS2, not NT. */
117 /* NT fills in the time in the dirscan. */
121 if ( stat( filename, &statbuf ) < 0 )
124 *time = statbuf.st_mtime;
137 # endif /* OS2 && !__EMX__ */