Example #1
0
 DWORD __fixed_GetFileAttributesA( LPCSTR lpFileName )
#endif
/*****************************************************/
{
    HANDLE              handle;
    WIN32_FIND_DATA     finddata;

    if( WIN32_IS_NT4 ) {
        return( GetFileAttributes( lpFileName ) );
    }
    /*** Fail if the filename contains a wildcard ***/
    if( __F_NAME(strchr,wcschr)( lpFileName, STRING( '*' ) ) != NULL ||
        __F_NAME(strchr,wcschr)( lpFileName, STRING( '?' ) ) != NULL ) {
        return( INVALID_FILE_ATTRIBUTES );
    }

    /*** Ok, use FindFirstFile to get the file attribute ***/
    handle = __lib_FindFirstFile( lpFileName, &finddata );
    if( handle == INVALID_HANDLE_VALUE ) {
        return( INVALID_FILE_ATTRIBUTES );
    } else {
        FindClose( handle );
    }
    return( finddata.dwFileAttributes );
}
Example #2
0
static DIR_TYPE *__F_NAME(___opendir,___wopendir)( const CHAR_TYPE *dirname, DIR_TYPE *dirp )
/*******************************************************************************************/
{
    WIN32_FIND_DATA     ffb;
    HANDLE              h;

    if( dirp->d_first != _DIR_CLOSED ) {
        FindClose( DIR_HANDLE_OF( dirp ) );
        dirp->d_first = _DIR_CLOSED;
    }
    h = __lib_FindFirstFile( dirname, &ffb );
    if( h == INVALID_HANDLE_VALUE ) {
        __set_errno_nt();
        return( NULL );
    }
    DIR_HANDLE_OF( dirp ) = h;
    __GetNTDirInfo( dirp, &ffb );
    dirp->d_first = _DIR_ISFIRST;
    return( dirp );
}
Example #3
0
  _WCRTLINK long _findfirst( const char *filespec, struct _finddata_t *fileinfo )
 #endif
#endif
/******************************************************************************/
{
#if defined( __NT__ )
    WIN32_FIND_DATA ffb;
    HANDLE          h;

    /*** Initialize the find ***/
    h = __lib_FindFirstFile( filespec, &ffb );
    if( h == INVALID_HANDLE_VALUE ) {
        return( __set_errno_nt() );
    }

    /*** Look for the first file ***/
    if( !__NTFindNextFileWithAttr( h, FIND_ATTR, &ffb ) ) {
        FindClose( h );
        return( __set_errno_dos( ERROR_FILE_NOT_FOUND ) );
    }

    /*** Got one! ***/
  #ifdef __INT64__
    __F_NAME(__nt_finddatai64_cvt,__nt_wfinddatai64_cvt)( &ffb, fileinfo );
  #else
    __F_NAME(__nt_finddata_cvt,__nt_wfinddata_cvt)( &ffb, fileinfo );
  #endif
    return( (long)h );
#elif defined( __OS2__ )
    APIRET          rc;
    HDIR            h = HDIR_CREATE;
    FF_BUFFER       ffb;
    OS_UINT         searchcount = 1;
 #ifdef __WIDECHAR__
    char            mbFilespec[MB_CUR_MAX * _MAX_PATH];

    if( wcstombs( mbFilespec, filespec, sizeof( mbFilespec ) ) == -1 ) {
        mbFilespec[0] = '\0';
    }
 #endif
    rc = DosFindFirst( (char*)__F_NAME(filespec,mbFilespec), &h, FIND_ATTR,
                                &ffb, sizeof( ffb ), &searchcount, FF_LEVEL );
    if( rc != 0 ) {
        return( -1L );
    }
    /*** Got one! ***/
 #ifdef __INT64__
    __F_NAME(__os2_finddatai64_cvt,__os2_wfinddatai64_cvt)( &ffb, fileinfo );
 #else
    __F_NAME(__os2_finddata_cvt,__os2_wfinddata_cvt)( &ffb, fileinfo );
 #endif
    return( (long)h );
#elif defined( __RDOS__ )
    RDOSFINDTYPE *  findbuf;

    findbuf = (RDOSFINDTYPE*) lib_malloc( sizeof( RDOSFINDTYPE ) );
    if( findbuf == NULL )  return( -1L );

    findbuf->handle = RdosOpenDir( filespec );
    findbuf->entry = 0;

    if( __rdos_finddata_get( findbuf, fileinfo ) )
        return( (long) findbuf );
    else {
        lib_free( findbuf );
        return( -1 );
    }
#else   /* DOS */
    DOSFINDTYPE     *findbuf;
    unsigned       rc;

    /*** Start a new find using _dos_findfirst ***/
    findbuf = (DOSFINDTYPE*) lib_malloc( sizeof( DOSFINDTYPE ) );
    if( findbuf == NULL )  return( -1L );
    rc = __F_NAME(_dos_findfirst,_wdos_findfirst)( filespec, FIND_ATTR, findbuf );
    if( rc != 0 ) {
        lib_free( findbuf );
        return( -1L );
    }

    /*** Got one! ***/
  #ifdef __INT64__
    __F_NAME(__dos_finddatai64_cvt,__dos_wfinddatai64_cvt)( findbuf, fileinfo );
  #else
    __F_NAME(__dos_finddata_cvt,__dos_wfinddata_cvt)( findbuf, fileinfo );
  #endif
    return( (long)findbuf );
#endif
}