コード例 #1
0
/*
   read first dir buffer into Dir_buffer
*/
void vdrive_dir_find_first_slot(vdrive_t *vdrive, const char *name,
                                int length, unsigned int type,
                                vdrive_dir_context_t *dir)
{
    if (length > 0) {
        BYTE *nslot;

        nslot = cbmdos_dir_slot_create(name, length);
        memcpy(dir->find_nslot, nslot, CBMDOS_SLOT_NAME_LENGTH);
        lib_free(nslot);
    }

    dir->vdrive = vdrive;
    dir->find_length = length;
    dir->find_type = type;

    dir->track = vdrive->Header_Track;
    dir->sector = vdrive->Header_Sector;
    dir->slot = 7;

    vdrive_read_sector(vdrive, dir->buffer, dir->track, dir->sector);

    dir->buffer[0] = vdrive->Dir_Track;
    dir->buffer[1] = vdrive->Dir_Sector;

#ifdef DEBUG_DRIVE
    log_debug("DIR: vdrive_dir_find_first_slot (curr t:%d/s:%d dir t:%d/s:%d)",
              dir->track, dir->sector, vdrive->Dir_Track, vdrive->Dir_Sector);
#endif
}
コード例 #2
0
ファイル: vdrive-dir.c プロジェクト: SMTDDR/droidsound
/*
   read first dir buffer into Dir_buffer
*/
void vdrive_dir_find_first_slot(vdrive_t *vdrive, const char *name,
                                int length, unsigned int type)
{
    if (length > 0) {
        BYTE *nslot;

        nslot = cbmdos_dir_slot_create(name, length);
        memcpy(vdrive->find_nslot, nslot, CBMDOS_SLOT_NAME_LENGTH);
        lib_free(nslot);
    }

    vdrive->find_length = length;
    vdrive->find_type = type;

    vdrive->Curr_track = vdrive->Header_Track;
    vdrive->Curr_sector = vdrive->Header_Sector;
    vdrive->SlotNumber = 7;

    disk_image_read_sector(vdrive->image, vdrive->Dir_buffer,
                           vdrive->Curr_track, vdrive->Curr_sector);

    vdrive->Dir_buffer[0] = vdrive->Dir_Track;
    vdrive->Dir_buffer[1] = vdrive->Dir_Sector;

#ifdef DEBUG_DRIVE
    log_debug("DIR: vdrive_dir_find_first_slot (curr t:%d/s:%d dir t:%d/s:%d)", 
              vdrive->Curr_track, vdrive->Curr_sector,
              vdrive->Dir_Track, vdrive->Dir_Sector
             );
#endif
}
コード例 #3
0
ファイル: cbmfile.c プロジェクト: bobsummerwill/VICE
static char *cbmfile_find_file(const char *fsname, const char *path)
{
    struct ioutil_dir_s *ioutil_dir;
    BYTE *name1, *name2;
    char *name, *retname = NULL;
    const char *open_path;

    open_path = path;
    if (path == NULL)
        open_path = "";

    ioutil_dir = ioutil_opendir(open_path);

    if (ioutil_dir == NULL)
        return NULL;

    name1 = cbmdos_dir_slot_create(fsname, (unsigned int)strlen(fsname));

    while (1) {
        unsigned int equal;

        name = ioutil_readdir(ioutil_dir);

        if (name == NULL)
            break;

        name2 = cbmdos_dir_slot_create(name, (unsigned int)strlen(name));
        equal = cbmdos_parse_wildcard_compare(name1, name2);

        lib_free(name2);

        if (equal > 0) {
            retname = lib_stralloc(name);
            break;
        }
    }

    lib_free(name1);
    ioutil_closedir(ioutil_dir);

    return retname;
}
コード例 #4
0
ファイル: p00.c プロジェクト: martinpiper/VICE
static char *p00_file_find(const char *file_name, const char *path)
{
    struct ioutil_dir_s *ioutil_dir;
    struct rawfile_info_s *rawfile;
    BYTE p00_header_file_name[P00_HDR_CBMNAME_LEN];
    char *name, *alloc_name = NULL;
    int rc;

    ioutil_dir = ioutil_opendir(path);

    if (ioutil_dir == NULL)
        return NULL;

    while (1) {
        name = ioutil_readdir(ioutil_dir);

        if (name == NULL)
            break;

        if (p00_check_name(name) < 0)
            continue;

        rawfile = rawfile_open(name, path, FILEIO_COMMAND_READ);
        if (rawfile == NULL)
            continue;

        rc = p00_read_header(rawfile, (BYTE *)p00_header_file_name, NULL);

        if (rc >= 0) {
            BYTE *cname;
            unsigned int equal;

            p00_pad_a0(p00_header_file_name);
            cname = cbmdos_dir_slot_create(file_name, strlen(file_name));
            equal = cbmdos_parse_wildcard_compare(cname, p00_header_file_name);
            lib_free(cname);

            if (equal > 0)
                alloc_name = lib_stralloc(name);
            else
                rc = -1;
        }

        rawfile_destroy(rawfile);

        if (rc >= 0)
            break;
    }

    ioutil_closedir(ioutil_dir);

    return alloc_name;
}
コード例 #5
0
ファイル: vdrive-dir.c プロジェクト: BigBoss21X/vice-emu
void vdrive_dir_find_first_slot(vdrive_t *vdrive, const char *name,
                                int length, unsigned int type)
{
    if (length > 0) {
        BYTE *nslot;

        nslot = cbmdos_dir_slot_create(name, length);
        memcpy(vdrive->find_nslot, nslot, CBMDOS_SLOT_NAME_LENGTH);
        lib_free(nslot);
    }

    vdrive->find_length = length;
    vdrive->find_type = type;

    vdrive->Curr_track = vdrive->Dir_Track;
    vdrive->Curr_sector = vdrive->Dir_Sector;
    vdrive->SlotNumber = 0;
    vdrive->SlotNumber--;

    disk_image_read_sector(vdrive->image, vdrive->Dir_buffer,
                           vdrive->Dir_Track, vdrive->Dir_Sector);
}