|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#include "jam.h" |
|
#ifdef USE_FILEUNIX |
|
#include "filesys.h" |
|
|
|
#include "object.h" |
|
#include "pathsys.h" |
|
#include "strings.h" |
|
|
|
#include <assert.h> |
|
#include <stdio.h> |
|
#include <sys/stat.h> |
|
|
|
#if defined( sun ) || defined( __sun ) || defined( linux ) |
|
# include <unistd.h> |
|
#endif |
|
|
|
#if defined( OS_SEQUENT ) || \ |
|
defined( OS_DGUX ) || \ |
|
defined( OS_SCO ) || \ |
|
defined( OS_ISC ) |
|
# define PORTAR 1 |
|
#endif |
|
|
|
#if defined( OS_RHAPSODY ) || defined( OS_MACOSX ) || defined( OS_NEXT ) |
|
# include <sys/dir.h> |
|
# include <unistd.h> |
|
# define STRUCT_DIRENT struct direct |
|
#else |
|
# include <dirent.h> |
|
# define STRUCT_DIRENT struct dirent |
|
#endif |
|
|
|
|
|
|
|
|
|
|
|
int file_collect_dir_content_( file_info_t * const d ) |
|
{ |
|
LIST * files = L0; |
|
PATHNAME f; |
|
DIR * dd; |
|
STRUCT_DIRENT * dirent; |
|
string path[ 1 ]; |
|
char const * dirstr; |
|
|
|
assert( d ); |
|
assert( d->is_dir ); |
|
assert( list_empty( d->files ) ); |
|
|
|
dirstr = object_str( d->name ); |
|
|
|
memset( (char *)&f, '\0', sizeof( f ) ); |
|
f.f_dir.ptr = dirstr; |
|
f.f_dir.len = strlen( dirstr ); |
|
|
|
if ( !*dirstr ) dirstr = "."; |
|
|
|
if ( !( dd = opendir( dirstr ) ) ) |
|
return -1; |
|
|
|
string_new( path ); |
|
while ( ( dirent = readdir( dd ) ) ) |
|
{ |
|
OBJECT * name; |
|
f.f_base.ptr = dirent->d_name |
|
#ifdef old_sinix |
|
- 2 |
|
#endif |
|
; |
|
f.f_base.len = strlen( f.f_base.ptr ); |
|
|
|
string_truncate( path, 0 ); |
|
path_build( &f, path ); |
|
name = object_new( path->value ); |
|
|
|
if ( file_query( name ) ) |
|
files = list_push_back( files, name ); |
|
else |
|
object_free( name ); |
|
} |
|
string_free( path ); |
|
|
|
closedir( dd ); |
|
|
|
d->files = files; |
|
return 0; |
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
void file_dirscan_( file_info_t * const d, scanback func, void * closure ) |
|
{ |
|
assert( d ); |
|
assert( d->is_dir ); |
|
|
|
|
|
if ( !strcmp( object_str( d->name ), "/" ) ) |
|
(*func)( closure, d->name, 1 , &d->time ); |
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
int file_mkdir( char const * const path ) |
|
{ |
|
#if defined(__MINGW32__) |
|
|
|
mkdir(path); |
|
#else |
|
|
|
|
|
|
|
return mkdir( (char *)path, 0777 ); |
|
#endif |
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
void file_query_( file_info_t * const info ) |
|
{ |
|
file_query_posix_( info ); |
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void file_supported_fmt_resolution( timestamp * const t ) |
|
{ |
|
|
|
|
|
|
|
timestamp_init( t, 1, 0 ); |
|
} |
|
|
|
#endif |
|
|