예제 #1
0
PluginItemList FilePanel::create_volume_items( ) {
	auto volume_list = enum_volumes( );
	PluginItemList pi_list;
	pi_list.extend( volume_list.size( ) );
	pi_list.names.extend( volume_list.size( ) );
	pi_list.col_str.extend( volume_list.size( ) * 2 );
	pi_list.col_data.extend( volume_list.size( ) );
	unsigned col_N_width = 0;
	unsigned col_C0_width = 0;
	unsigned col_C1_width = 0;
	Array<const wchar_t*> col_data;
	for ( auto vol_iter = volume_list.cbegin( ); vol_iter != volume_list.cend( ); ++vol_iter ) {
		wstring name = vol_iter->drive_path.empty( ) ? vol_iter->guid_path : vol_iter->drive_path;
		if ( name.size( ) > col_N_width ) {
			col_N_width = name.size( );
			}
		pi_list.names += std::string( name.data( ), name.size( ) );
		PluginPanelItem pi;
		memzero( pi );
		pi.FileName = pi_list.names.last( ).data( );
		pi.FileAttributes = FILE_ATTRIBUTE_DIRECTORY;
		// custom columns
		col_data.clear( );
		pi_list.col_str += std::string( vol_iter->dev_path.data( ), vol_iter->dev_path.size( ) );
		col_data += pi_list.col_str.last( ).data( );
		if ( vol_iter->dev_path.size( ) > col_C0_width ) {
			col_C0_width = vol_iter->dev_path.size( );
			}
		std::string mount_points;
		for ( auto mp_iter = vol_iter->mount_points.cbegin( ); mp_iter != vol_iter->mount_points.cend( ); ++mp_iter ) {
			if ( mount_points.size( ) ) {
				mount_points += L';';
				}
			mount_points.add( mp_iter->data( ), mp_iter->size( ) );
			}
		pi_list.col_str += mount_points;
		col_data += pi_list.col_str.last( ).data( );
		if ( mount_points.size( ) > col_C1_width ) {
			col_C1_width = mount_points.size( );
			}
		pi_list.col_data += col_data;
		pi.CustomColumnData = const_cast< wchar_t** >( pi_list.col_data.last( ).data( ) );
		pi.CustomColumnNumber = pi_list.col_data.last( ).size( );
		pi_list += pi;
		}
	if ( col_N_width < 7 ) {
		col_N_width = 7;
		}
	col_widths.copy_fmt( L"%u,%u,%u", col_N_width, col_C0_width, col_C1_width );
	return pi_list;
	}
예제 #2
0
파일: sdparm_wscan.c 프로젝트: fortsage/nio
static int
do_wscan(char letter, int show_bt, int scsi_scan)
{
    int k, j, n;
    struct storage_elem * sp;

    if (scsi_scan < 2) {
        k = enum_pds();
        if (k)
            return k;
        k = enum_cdroms();
        if (k)
            return k;
        k = enum_tapes();
        if (k)
            return k;
        k = enum_volumes(letter);
        if (k)
            return k;

        for (k = 0; k < next_unused_elem; ++k) {
            sp = storage_arr + k;
            if ('\0' == sp->name[0])
                continue;
            printf("%-7s ", sp->name);
            n = strlen(sp->volume_letters);
            if (0 == n)
                printf("        ");
            else if (1 == n)
                printf("[%s]     ", sp->volume_letters);
            else if (2 == n)
                printf("[%s]    ", sp->volume_letters);
            else if (3 == n)
                printf("[%s]   ", sp->volume_letters);
            else if (4 == n)
                printf("[%s]  ", sp->volume_letters);
            else
                printf("[%4s+] ", sp->volume_letters);
            if (sp->qp_descriptor_valid) {
                if (show_bt)
                    printf("<%s>  ",
                           get_bus_type(sp->qp_descriptor.desc.BusType));
                j = sp->qp_descriptor.desc.VendorIdOffset;
                if (j > 0)
                    printf("%s  ", sp->qp_descriptor.raw + j);
                j = sp->qp_descriptor.desc.ProductIdOffset;
                if (j > 0)
                    printf("%s  ", sp->qp_descriptor.raw + j);
                j = sp->qp_descriptor.desc.ProductRevisionOffset;
                if (j > 0)
                    printf("%s  ", sp->qp_descriptor.raw + j);
                j = sp->qp_descriptor.desc.SerialNumberOffset;
                if (j > 0)
                    printf("%s", sp->qp_descriptor.raw + j);
                printf("\n");
                if (verbose > 2)
                    dStrHexErr(sp->qp_descriptor.raw, 144, 0);
            } else
                printf("\n");
            if ((verbose > 3) && sp->qp_uid_valid) {
                printf("  UID valid, in hex:\n");
                dStrHexErr(sp->qp_uid.raw, sizeof(sp->qp_uid.raw), 1);
            }
        }
    }

    if (scsi_scan) {
        if (scsi_scan < 2)
            printf("\n");
        enum_scsi_adapters();
    }
    return 0;
}