The Machine Perception Toolbox

[Introduction]- [News]- [Download]- [Screenshots]- [Manual (pdf)]- [Forums]- [API Reference]- [Repository ]

 

Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

fileos2.c

Go to the documentation of this file.
00001 /*
00002  * Copyright 1993-2002 Christopher Seiwald and Perforce Software, Inc.
00003  *
00004  * This file is part of Jam - see jam.c for Copyright information.
00005  */
00006 
00007 /*  This file is ALSO:
00008  *  (C) Copyright David Abrahams 2001. Permission to copy, use,
00009  *  modify, sell and distribute this software is granted provided this
00010  *  copyright notice appears in all copies. This software is provided
00011  *  "as is" without express or implied warranty, and with no claim as
00012  *  to its suitability for any purpose.
00013  */
00014 
00015 # include "jam.h"
00016 # include "filesys.h"
00017 # include "pathsys.h"
00018 
00019 /* note that we use "fileunix.c" when compiling with EMX on OS/2 */
00020 # if defined(OS_OS2) && !defined(__EMX__)
00021 
00022 # include <io.h>
00023 # include <dos.h>
00024 
00025 /*
00026  * fileos2.c - scan directories and archives on NT
00027  *
00028  * External routines:
00029  *
00030  *      file_dirscan() - scan a directory for files
00031  *      file_time() - get timestamp of file, if not done by file_dirscan()
00032  *      file_archscan() - scan an archive for files
00033  *
00034  * File_dirscan() and file_archscan() call back a caller provided function
00035  * for each file found.  A flag to this callback function lets file_dirscan()
00036  * and file_archscan() indicate that a timestamp is being provided with the
00037  * file.   If file_dirscan() or file_archscan() do not provide the file's
00038  * timestamp, interested parties may later call file_time().
00039  *
00040  * 07/10/95 (taylor)  Findfirst() returns the first file on NT.
00041  * 05/03/96 (seiwald) split apart into pathnt.c
00042  * 09/22/00 (seiwald) handle \ and c:\ specially: don't add extra /
00043  */
00044 
00045 /*
00046  * file_dirscan() - scan a directory for files
00047  */
00048 
00049 void
00050 file_dirscan( 
00051         char *dir,
00052         scanback func,
00053         void    *closure )
00054 {
00055     PATHNAME f;
00056     string filespec[1];
00057     long handle;
00058     int ret;
00059     struct _find_t finfo[1];
00060 
00061     /* First enter directory itself */
00062 
00063     memset( (char *)&f, '\0', sizeof( f ) );
00064 
00065     f.f_dir.ptr = dir;
00066     f.f_dir.len = strlen(dir);
00067 
00068     dir = *dir ? dir : ".";
00069 
00070     /* Special case \ or d:\ : enter it */
00071     string_copy( filespec, dir );
00072 
00073     if( f.f_dir.len == 1 && f.f_dir.ptr[0] == '\\' )
00074             (*func)( closure, dir, 0 /* not stat()'ed */, (time_t)0 );
00075     else if( f.f_dir.len == 3 && f.f_dir.ptr[1] == ':' )
00076             (*func)( closure, dir, 0 /* not stat()'ed */, (time_t)0 );
00077     else
00078         string_push_back( filespec, '/' );
00079 
00080     string_push_back( filespec, '*' );
00081 
00082     /* Now enter contents of directory */
00083 
00084     if( DEBUG_BINDSCAN )
00085         printf( "scan directory %s\n", filespec->value );
00086 
00087     /* Time info in dos find_t is not very useful.  It consists */
00088     /* of a separate date and time, and putting them together is */
00089     /* not easy.  So we leave that to a later stat() call. */
00090 
00091     if( !_dos_findfirst( filespec->value, _A_NORMAL|_A_RDONLY|_A_SUBDIR, finfo ) )
00092     {
00093         string filename[1];
00094         string_new( filename );
00095         do
00096         {
00097             
00098             f.f_base.ptr = finfo->name;
00099             f.f_base.len = strlen( finfo->name );
00100 
00101             string_truncate( filename, 0 );
00102             path_build( &f, filename, 0 );
00103             (*func)( closure, filename->value, 0 /* not stat()'ed */, (time_t)0 );
00104         }
00105         while( !_dos_findnext( finfo ) );
00106         string_free( filename );
00107     }
00108 }
00109 
00110 /*
00111  * file_time() - get timestamp of file, if not done by file_dirscan()
00112  */
00113 
00114 int
00115 file_time(
00116         char    *filename,
00117         time_t  *time )
00118 {
00119         /* This is called on OS2, not NT.  */
00120         /* NT fills in the time in the dirscan. */
00121 
00122         struct stat statbuf;
00123 
00124         if( stat( filename, &statbuf ) < 0 )
00125             return -1;
00126 
00127         *time = statbuf.st_mtime;
00128 
00129         return 0;
00130 }
00131 
00132 void
00133 file_archscan(
00134         char *archive,
00135         scanback func,
00136         void    *closure )
00137 {
00138 }
00139 
00140 # endif /* OS2 && !__EMX__ */
00141 

Generated on Mon Nov 8 17:07:34 2004 for MPT by  doxygen 1.3.9.1