Пример #1
0
_mfs_error MFS_Find_next_file
    (
        MFS_DRIVE_STRUCT_PTR drive_ptr,

        MFS_SEARCH_DATA_PTR     transfer_ptr    /* [IN/OUT] address of search data block indicating the current criteria and the results of 
                                                ** the last search results of this search are placed in this data block */
    )
{
    _mfs_error              error_code;

    error_code = MFS_lock_dos_disk( drive_ptr );

    if ( error_code == MFS_NO_ERROR )
    {
        error_code = MFS_Find_next_slave(drive_ptr, transfer_ptr);
        MFS_unlock(drive_ptr,FALSE);
    }
    return(error_code);
}  
Пример #2
0
_mfs_error MFS_Find_next_file
    (
    MQX_FILE_PTR            mfs_fd_ptr,     /*[IN] pointer to the file struct returned by fopen("MFS...:",..); */
    MFS_SEARCH_DATA_PTR     transfer_ptr    /* [IN/OUT] address of search data block indicating the current criteria and the results of 
                                            ** the last search results of this search are placed in this data block */
    )
{
    MFS_DRIVE_STRUCT_PTR    drive_ptr;
    _mfs_error              error_code;

    error_code = MFS_lock_dos_disk( mfs_fd_ptr, &drive_ptr );

    if ( error_code == MFS_NO_ERROR )
    {
        error_code = MFS_Find_next_slave(drive_ptr, transfer_ptr);
        MFS_unlock(drive_ptr,FALSE);
    }
    return(error_code);
}  
Пример #3
0
_mfs_error MFS_Find_first_file
    (
        MFS_DRIVE_STRUCT_PTR drive_ptr,

        unsigned char       attribute,      /*[IN] type of file to find, Search attributes */
        char                *pathname,       /*[IN] optionally the directory and filename to search for */
        MFS_SEARCH_DATA_PTR transfer_ptr    /*[IN] address of search data block into which the results of the search are put */
    )
{
    MFS_INTERNAL_SEARCH_PTR internal_search_ptr;
    char                *temp_dirname;
    char                *temp_filename;
    uint32_t                 current_cluster;
    _mfs_error              error_code;
    uint32_t                 i;
    char                    c;

    if ( (pathname==NULL) || (*pathname=='\0') )
    {
        return MFS_INVALID_PARAMETER;
    }

    if ( transfer_ptr == NULL )
    {
        return MFS_INVALID_MEMORY_BLOCK_ADDRESS;
    }

    error_code = MFS_alloc_2paths(&temp_dirname,&temp_filename);
    if ( error_code != MFS_NO_ERROR )
    {
        return( error_code );
    }

    error_code = MFS_lock_dos_disk( drive_ptr );
    if ( error_code != MFS_NO_ERROR )
    {
        MFS_free_path(temp_dirname);
        MFS_free_path(temp_filename);
        return error_code;
    }

    _mem_zero(transfer_ptr, sizeof (MFS_SEARCH_DATA));
    transfer_ptr->DRIVE_PTR = drive_ptr;

    MFS_Parse_pathname(temp_dirname, temp_filename, pathname);

    current_cluster = drive_ptr->CUR_DIR_CLUSTER;
    current_cluster = MFS_Find_directory(drive_ptr, temp_dirname, current_cluster);

    if ( current_cluster == CLUSTER_INVALID )
    {
        error_code = MFS_PATH_NOT_FOUND;
    }
    else
    {
        /*
        ** The internal search is only initialised if the directory exists.
        */
        internal_search_ptr = &transfer_ptr->INTERNAL_SEARCH_DATA;
        internal_search_ptr->CURRENT_CLUSTER = current_cluster;
        internal_search_ptr->PREV_CLUSTER = CLUSTER_INVALID;  
        internal_search_ptr->DIR_ENTRY_INDEX = 0;

        MFS_Expand_wildcard(temp_filename, internal_search_ptr->FILENAME);   
        internal_search_ptr->FULLNAME = temp_filename;

        i = _strnlen(pathname, PATHNAME_SIZE + FILENAME_SIZE + 1);
        c = pathname[--i];
        while ( (c != '\\') && (c != '/') && (c != ':') && i )
        {
            i--;         
            c = pathname[i];
        }  
        if ( i || c == '\\' || c == '/' )
        {
            i++;
        }

        internal_search_ptr->SRC_PTR = pathname + i;
        internal_search_ptr->ATTRIBUTE = attribute;
        error_code = MFS_Find_next_slave(drive_ptr, transfer_ptr);
    }  

    MFS_free_path(temp_dirname);
    MFS_free_path(temp_filename);
    MFS_unlock(drive_ptr,FALSE);

    return(error_code);
}