diff -N -r -u -b boost_1_34_0/tools/jam/src/fileamiga.c boost_1_34_0_amiga/tools/jam/src/fileamiga.c --- boost_1_34_0/tools/jam/src/fileamiga.c 2114-02-06 23:28:16 +++ boost_1_34_0_amiga/tools/jam/src/fileamiga.c 2007-06-02 08:11:27 @@ -0,0 +1,132 @@ +/* + * This file is part of Jam - see jam.c for Copyright information. + */ + +#include "jam.h" + +#if defined(OS_AMIGA) + +#include "filesys.h" +#include "strings.h" +#include "pathsys.h" + +#include +#include +#include +#include + +/* + * fileamiga.c - manipulate file names and scan directories on AmigaOS + * + * External routines: + * + * file_dirscan() - scan a directory for files + * file_time() - get timestamp of file, if not done by file_dirscan() + * file_archscan() - scan an archive for files + * + * File_dirscan() and file_archscan() call back a caller provided function + * for each file found. A flag to this callback function lets file_dirscan() + * and file_archscan() indicate that a timestamp is being provided with the + * file. If file_dirscan() or file_archscan() do not provide the file's + * timestamp, interested parties may later call file_time(). + */ + +/* + * file_dirscan() - scan a directory for files + */ +void file_dirscan(char *dir, scanback func, void *closure) +{ + PATHNAME f; + DIR *d; + struct dirent *dirent; + string filename[1]; + + /* First enter directory itself */ + memset((char*)&f, '\0', sizeof(f)); + f.f_dir.ptr = dir; + f.f_dir.len = strlen(dir); + + dir = *dir ? dir : "."; + + /* Special case / : enter it */ + if ( f.f_dir.len == 1 && f.f_dir.ptr[0] == '/' ) + { + (*func)(closure, dir, 0 /* not stat()'ed */, (time_t)0); + } + + /* Now enter contents of directory */ + if ( !(d = opendir(dir)) ) + { + return; + } + + if ( DEBUG_BINDSCAN ) + { + printf("scan directory %s\n", dir); + } + + string_new(filename); + + while ( dirent = readdir(d) ) + { + f.f_base.ptr = dirent->d_name; + f.f_base.len = strlen(f.f_base.ptr); + + string_truncate(filename, 0); + path_build(&f, filename, 0); + + (*func)(closure, filename->value, 0 /* not stat()'ed */, (time_t)0); + } + + string_free(filename); + + closedir(d); +} + + +/* + * file_time() - get timestamp of file, if not done by file_dirscan() + */ +int file_time(char *filename, time_t *time) +{ + struct stat statbuf; + + if ( stat(filename, &statbuf) < 0 ) + { + return -1; + } + + *time = statbuf.st_mtime; + + return 0; +} + + +int file_is_file(char* filename) +{ + struct stat statbuf; + + if( stat( filename, &statbuf ) < 0 ) + { + return -1; + } + + if (S_ISREG(statbuf.st_mode)) + { + return 1; + } + else + { + return 0; + } +} + + +/* + * file_archscan() - scan an archive for files + */ +void file_archscan(char *archive, scanback func, void *closure ) +{ +} + +#endif