static int xbsd_create_disklabel (void) { char c; #if defined (__alpha__) fprintf (stderr, _("%s contains no disklabel.\n"), disk_device); #else fprintf (stderr, _("%s contains no disklabel.\n"), partname(disk_device, xbsd_part_index+1, 0)); #endif while (1) { c = read_char (_("Do you want to create a disklabel? (y/n) ")); if (tolower(c) == 'y') { if (xbsd_initlabel ( #if defined (__alpha__) || defined (__powerpc__) NULL, &xbsd_dlabel, 0 #else xbsd_part, &xbsd_dlabel, xbsd_part_index #endif ) == 1) { xbsd_print_disklabel (1); return 1; } else return 0; } else if (c == 'n') return 0; } }
static int xbsd_create_disklabel(void) { char c; #if defined(__alpha__) printf("%s contains no disklabel\n", disk_device); #else printf("%s contains no disklabel\n", partname(disk_device, xbsd_part_index + 1, 0)); #endif while (1) { c = read_nonempty("Do you want to create a disklabel? (y/n) "); if ((c|0x20) == 'y') { if (xbsd_initlabel( #if defined(__alpha__) || defined(__powerpc__) || defined(__hppa__) || \ defined(__s390__) || defined(__s390x__) NULL #else xbsd_part #endif ) == 1) { xbsd_print_disklabel(1); return 1; } return 0; } if ((c|0x20) == 'n') return 0; } }
static void xbsd_write_disklabel (void) { #if defined (__alpha__) printf (_("Writing disklabel to %s.\n"), disk_device); xbsd_writelabel (NULL, &xbsd_dlabel); #else printf (_("Writing disklabel to %s.\n"), partname(disk_device, xbsd_part_index+1, 0)); xbsd_writelabel (xbsd_part, &xbsd_dlabel); #endif reread_partition_table(0); /* no exit yet */ }
static void sgi_list_table(int xtra) { int i, w, wd; int kpi = 0; /* kernel partition ID */ if (xtra) { printf("\nDisk %s (SGI disk label): %d heads, %d sectors\n" "%d cylinders, %d physical cylinders\n" "%d extra sects/cyl, interleave %d:1\n" "%s\n" "Units = %s of %d * 512 bytes\n\n", disk_device, heads, sectors, cylinders, SGI_SSWAP16(sgiparam.pcylcount), SGI_SSWAP16(sgiparam.sparecyl), SGI_SSWAP16(sgiparam.ilfact), (char *)sgilabel, str_units(PLURAL), units_per_sector); } else { printf("\nDisk %s (SGI disk label): " "%d heads, %d sectors, %d cylinders\n" "Units = %s of %d * 512 bytes\n\n", disk_device, heads, sectors, cylinders, str_units(PLURAL), units_per_sector ); } w = strlen(disk_device); wd = sizeof("Device") - 1; if (w < wd) w = wd; printf("----- partitions -----\n" "Pt# %*s Info Start End Sectors Id System\n", w + 2, "Device"); for (i = 0 ; i < partitions; i++) { if (sgi_get_num_sectors(i) || debug ) { uint32_t start = sgi_get_start_sector(i); uint32_t len = sgi_get_num_sectors(i); kpi++; /* only count nonempty partitions */ printf( "%2d: %s %4s %9ld %9ld %9ld %2x %s\n", /* fdisk part number */ i+1, /* device */ partname(disk_device, kpi, w+3), /* flags */ (sgi_get_swappartition() == i) ? "swap" : /* flags */ (sgi_get_bootpartition() == i) ? "boot" : " ", /* start */ (long) scround(start), /* end */ (long) scround(start+len)-1, /* no odd flag on end */(long) len, /* type id */ sgi_get_sysid(i), /* type name */ partition_type(sgi_get_sysid(i))); } } printf("----- Bootinfo -----\nBootfile: %s\n" "----- Directory Entries -----\n", sgilabel->boot_file); for (i = 0 ; i < sgi_volumes; i++) { if (sgilabel->directory[i].vol_file_size) { uint32_t start = SGI_SSWAP32(sgilabel->directory[i].vol_file_start); uint32_t len = SGI_SSWAP32(sgilabel->directory[i].vol_file_size); unsigned char *name = sgilabel->directory[i].vol_file_name; printf("%2d: %-10s sector%5u size%8u\n", i, (char*)name, (unsigned int) start, (unsigned int) len); } } }
static void xbsd_write_bootstrap(void) { char path[MAXPATHLEN]; const char *bootdir = BSD_LINUX_BOOTDIR; const char *dkbasename; struct xbsd_disklabel dl; char *d, *p, *e; int sector; if (xbsd_dlabel.d_type == BSD_DTYPE_SCSI) dkbasename = "sd"; else dkbasename = "wd"; snprintf(path, sizeof(path), "Bootstrap: %sboot -> boot%s (%s): ", dkbasename, dkbasename, dkbasename); if (read_line(path)) { dkbasename = line_ptr; } snprintf(path, sizeof(path), "%s/%sboot", bootdir, dkbasename); if (!xbsd_get_bootstrap(path, disklabelbuffer, (int) xbsd_dlabel.d_secsize)) return; /* We need a backup of the disklabel (xbsd_dlabel might have changed). */ d = &disklabelbuffer[BSD_LABELSECTOR * SECTOR_SIZE]; memmove(&dl, d, sizeof(struct xbsd_disklabel)); /* The disklabel will be overwritten by 0's from bootxx anyway */ memset(d, 0, sizeof(struct xbsd_disklabel)); snprintf(path, sizeof(path), "%s/boot%s", bootdir, dkbasename); if (!xbsd_get_bootstrap(path, &disklabelbuffer[xbsd_dlabel.d_secsize], (int) xbsd_dlabel.d_bbsize - xbsd_dlabel.d_secsize)) return; e = d + sizeof(struct xbsd_disklabel); for (p = d; p < e; p++) if (*p) { printf("Bootstrap overlaps with disk label!\n"); exit(EXIT_FAILURE); } memmove(d, &dl, sizeof(struct xbsd_disklabel)); #if defined(__powerpc__) || defined(__hppa__) sector = 0; #elif defined(__alpha__) sector = 0; alpha_bootblock_checksum(disklabelbuffer); #else sector = get_start_sect(xbsd_part); #endif seek_sector(sector); xwrite(dev_fd, disklabelbuffer, BSD_BBSIZE); #if defined(__alpha__) printf("Bootstrap installed on %s\n", disk_device); #else printf("Bootstrap installed on %s\n", partname(disk_device, xbsd_part_index+1, 0)); #endif sync_disks(); }
static void xbsd_print_disklabel(int show_all) { struct xbsd_disklabel *lp = &xbsd_dlabel; struct xbsd_partition *pp; int i, j; if (show_all) { static const int d_masks[] = { BSD_D_REMOVABLE, BSD_D_ECC, BSD_D_BADSECT }; #if defined(__alpha__) printf("# %s:\n", disk_device); #else printf("# %s:\n", partname(disk_device, xbsd_part_index+1, 0)); #endif if ((unsigned) lp->d_type < ARRAY_SIZE(xbsd_dktypenames)-1) printf("type: %s\n", xbsd_dktypenames[lp->d_type]); else printf("type: %u\n", lp->d_type); printf("disk: %.*s\n", (int) sizeof(lp->d_typename), lp->d_typename); printf("label: %.*s\n", (int) sizeof(lp->d_packname), lp->d_packname); printf("flags: "); print_flags_separated(d_masks, "removable\0""ecc\0""badsect\0", lp->d_flags, " "); bb_putchar('\n'); /* On various machines the fields of *lp are short/int/long */ /* In order to avoid problems, we cast them all to long. */ printf("bytes/sector: %lu\n", (long) lp->d_secsize); printf("sectors/track: %lu\n", (long) lp->d_nsectors); printf("tracks/cylinder: %lu\n", (long) lp->d_ntracks); printf("sectors/cylinder: %lu\n", (long) lp->d_secpercyl); printf("cylinders: %lu\n", (long) lp->d_ncylinders); printf("rpm: %u\n", lp->d_rpm); printf("interleave: %u\n", lp->d_interleave); printf("trackskew: %u\n", lp->d_trackskew); printf("cylinderskew: %u\n", lp->d_cylskew); printf("headswitch: %lu\t\t# milliseconds\n", (long) lp->d_headswitch); printf("track-to-track seek: %lu\t# milliseconds\n", (long) lp->d_trkseek); printf("drivedata: "); for (i = NDDATA - 1; i >= 0; i--) if (lp->d_drivedata[i]) break; if (i < 0) i = 0; for (j = 0; j <= i; j++) printf("%lu ", (long) lp->d_drivedata[j]); } printf("\n%u partitions:\n", lp->d_npartitions); printf("# start end size fstype [fsize bsize cpg]\n"); pp = lp->d_partitions; for (i = 0; i < lp->d_npartitions; i++, pp++) { if (pp->p_size) { if (display_in_cyl_units && lp->d_secpercyl) { printf(" %c: %8lu%c %8lu%c %8lu%c ", 'a' + i, (unsigned long) pp->p_offset / lp->d_secpercyl + 1, (pp->p_offset % lp->d_secpercyl) ? '*' : ' ', (unsigned long) (pp->p_offset + pp->p_size + lp->d_secpercyl - 1) / lp->d_secpercyl, ((pp->p_offset + pp->p_size) % lp->d_secpercyl) ? '*' : ' ', (long) pp->p_size / lp->d_secpercyl, (pp->p_size % lp->d_secpercyl) ? '*' : ' ' ); } else { printf(" %c: %8lu %8lu %8lu ", 'a' + i, (long) pp->p_offset, (long) pp->p_offset + pp->p_size - 1, (long) pp->p_size ); } if ((unsigned) pp->p_fstype < ARRAY_SIZE(xbsd_fstypes)-1) printf("%8.8s", xbsd_fstypes[pp->p_fstype]); else printf("%8x", pp->p_fstype); switch (pp->p_fstype) { case BSD_FS_UNUSED: printf(" %5lu %5lu %5.5s ", (long) pp->p_fsize, (long) pp->p_fsize * pp->p_frag, ""); break; case BSD_FS_BSDFFS: printf(" %5lu %5lu %5u ", (long) pp->p_fsize, (long) pp->p_fsize * pp->p_frag, pp->p_cpg); break; default: printf("%22.22s", ""); break; } bb_putchar('\n'); } } }
static void bsd_select(void) { #if !defined(__alpha__) int t, ss; struct partition *p; for (t = 0; t < 4; t++) { p = get_part_table(t); if (p && is_bsd_partition_type(p->sys_ind)) { xbsd_part = p; xbsd_part_index = t; ss = get_start_sect(xbsd_part); if (ss == 0) { printf("Partition %s has invalid starting sector 0\n", partname(disk_device, t+1, 0)); return; } printf("Reading disklabel of %s at sector %u\n", partname(disk_device, t+1, 0), ss + BSD_LABELSECTOR); if (xbsd_readlabel(xbsd_part) == 0) { if (xbsd_create_disklabel() == 0) return; break; } } } if (t == 4) { printf("There is no *BSD partition on %s\n", disk_device); return; } #elif defined(__alpha__) if (xbsd_readlabel(NULL) == 0) if (xbsd_create_disklabel() == 0) exit(EXIT_SUCCESS); #endif while (1) { bb_putchar('\n'); switch (tolower(read_nonempty("BSD disklabel command (m for help): "))) { case 'd': xbsd_delete_part(); break; case 'e': xbsd_edit_disklabel(); break; case 'i': xbsd_write_bootstrap(); break; case 'l': xbsd_list_types(); break; case 'n': xbsd_new_part(); break; case 'p': xbsd_print_disklabel(0); break; case 'q': if (ENABLE_FEATURE_CLEAN_UP) close_dev_fd(); exit(EXIT_SUCCESS); case 'r': return; case 's': xbsd_print_disklabel(1); break; case 't': xbsd_change_fstype(); break; case 'u': change_units(); break; case 'w': xbsd_write_disklabel(); break; #if !defined(__alpha__) case 'x': xbsd_link_part(); break; #endif default: bsd_menu(); break; } } }
bool PCBMODEL::getModelLabel( const std::string aFileName, TDF_Label& aLabel ) { MODEL_MAP::const_iterator mm = m_models.find( aFileName ); if( mm != m_models.end() ) { aLabel = mm->second; return true; } aLabel.Nullify(); Handle( TDocStd_Document ) doc; m_app->NewDocument( "MDTV-XCAF", doc ); FormatType modelFmt = fileType( aFileName.c_str() ); switch( modelFmt ) { case FMT_IGES: if( !readIGES( doc, aFileName.c_str() ) ) { std::ostringstream ostr; ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n"; ostr << " * readIGES() failed on filename '" << aFileName << "'\n"; wxLogMessage( "%s\n", ostr.str().c_str() ); return false; } break; case FMT_STEP: if( !readSTEP( doc, aFileName.c_str() ) ) { std::ostringstream ostr; ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n"; ostr << " * readSTEP() failed on filename '" << aFileName << "'\n"; wxLogMessage( "%s\n", ostr.str().c_str() ); return false; } break; // TODO: implement IDF and EMN converters default: return false; } aLabel = transferModel( doc, m_doc ); if( aLabel.IsNull() ) { std::ostringstream ostr; ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n"; ostr << " * could not transfer model data from file '" << aFileName << "'\n"; wxLogMessage( "%s\n", ostr.str().c_str() ); return false; } // attach the PART NAME ( base filename: note that in principle // different models may have the same base filename ) wxFileName afile( aFileName.c_str() ); std::string pname( afile.GetName().ToUTF8() ); TCollection_ExtendedString partname( pname.c_str() ); TDataStd_Name::Set( aLabel, partname ); m_models.insert( MODEL_DATUM( aFileName, aLabel ) ); ++m_components; return true; }
void sgi_list_table(struct fdisk_context *cxt, int xtra) { int i, w; int kpi = 0; /* kernel partition ID */ w = strlen(cxt->dev_path); if (xtra) { printf(_("\nDisk %s (SGI disk label): %d heads, %llu sectors\n" "%llu cylinders, %d physical cylinders\n" "%d extra sects/cyl, interleave %d:1\n" "%s\n" "Units = %s of %d * %ld bytes\n\n"), cxt->dev_path, cxt->geom.heads, cxt->geom.sectors, cxt->geom.cylinders, SSWAP16(sgiparam.pcylcount), (int) sgiparam.sparecyl, SSWAP16(sgiparam.ilfact), (char *)sgilabel, str_units(PLURAL), units_per_sector, cxt->sector_size); } else { printf(_("\nDisk %s (SGI disk label): " "%d heads, %llu sectors, %llu cylinders\n" "Units = %s of %d * %ld bytes\n\n"), cxt->dev_path, cxt->geom.heads, cxt->geom.sectors, cxt->geom.cylinders, str_units(PLURAL), units_per_sector, cxt->sector_size); } printf(_("----- partitions -----\n" "Pt# %*s Info Start End Sectors Id System\n"), w + 1, _("Device")); for (i = 0 ; i < partitions; i++) { if (sgi_get_num_sectors(cxt, i) || debug) { uint32_t start = sgi_get_start_sector(cxt, i); uint32_t len = sgi_get_num_sectors(cxt, i); struct fdisk_parttype *t = fdisk_get_partition_type(cxt, i); kpi++; /* only count nonempty partitions */ printf( "%2d: %s %4s %9ld %9ld %9ld %2x %s\n", /* fdisk part number */ i+1, /* device */ partname(cxt->dev_path, kpi, w+2), /* flags */ (sgi_get_swappartition(cxt) == i) ? "swap" : /* flags */ (sgi_get_bootpartition(cxt) == i) ? "boot" : " ", /* start */ (long) scround(start), /* end */ (long) scround(start+len)-1, /* no odd flag on end */ (long) len, /* type id */ t->type, /* type name */ t->name); fdisk_free_parttype(t); } } printf(_("----- Bootinfo -----\nBootfile: %s\n" "----- Directory Entries -----\n"), sgilabel->boot_file); for (i = 0 ; i < volumes; i++) { if (sgilabel->directory[i].vol_file_size) { uint32_t start = SSWAP32(sgilabel->directory[i].vol_file_start); uint32_t len = SSWAP32(sgilabel->directory[i].vol_file_size); unsigned char *name = sgilabel->directory[i].vol_file_name; printf(_("%2d: %-10s sector%5u size%8u\n"), i, name, (unsigned int) start, (unsigned int) len); } } }
static void xbsd_write_bootstrap (void) { char *bootdir = BSD_LINUX_BOOTDIR; char path[MAXPATHLEN]; char *dkbasename; struct xbsd_disklabel dl; char *d, *p, *e; int sector; if (xbsd_dlabel.d_type == BSD_DTYPE_SCSI) dkbasename = "sd"; else dkbasename = "wd"; printf (_("Bootstrap: %sboot -> boot%s (%s): "), dkbasename, dkbasename, dkbasename); if (read_line ()) { line_ptr[strlen (line_ptr)-1] = '\0'; dkbasename = line_ptr; } sprintf (path, "%s/%sboot", bootdir, dkbasename); if (!xbsd_get_bootstrap (path, disklabelbuffer, (int) xbsd_dlabel.d_secsize)) return; /* We need a backup of the disklabel (xbsd_dlabel might have changed). */ d = &disklabelbuffer[BSD_LABELSECTOR * SECTOR_SIZE]; bcopy (d, &dl, sizeof (struct xbsd_disklabel)); /* The disklabel will be overwritten by 0's from bootxx anyway */ bzero (d, sizeof (struct xbsd_disklabel)); sprintf (path, "%s/boot%s", bootdir, dkbasename); if (!xbsd_get_bootstrap (path, &disklabelbuffer[xbsd_dlabel.d_secsize], (int) xbsd_dlabel.d_bbsize - xbsd_dlabel.d_secsize)) return; e = d + sizeof (struct xbsd_disklabel); for (p=d; p < e; p++) if (*p) { fprintf (stderr, _("Bootstrap overlaps with disk label!\n")); exit ( EXIT_FAILURE ); } bcopy (&dl, d, sizeof (struct xbsd_disklabel)); #if defined (__powerpc__) sector = 0; #elif defined (__alpha__) sector = 0; alpha_bootblock_checksum (disklabelbuffer); #else sector = get_start_sect(xbsd_part); #endif if (ext2_llseek (fd, (ext2_loff_t) sector * SECTOR_SIZE, SEEK_SET) == -1) fatal (unable_to_seek); if (BSD_BBSIZE != write (fd, disklabelbuffer, BSD_BBSIZE)) fatal (unable_to_write); #if defined (__alpha__) printf (_("Bootstrap installed on %s.\n"), disk_device); #else printf (_("Bootstrap installed on %s.\n"), partname (disk_device, xbsd_part_index+1, 0)); #endif sync_disks (); }
void xbsd_print_disklabel (int show_all) { struct xbsd_disklabel *lp = &xbsd_dlabel; struct xbsd_partition *pp; FILE *f = stdout; int i, j; if (show_all) { #if defined (__alpha__) fprintf(f, "# %s:\n", disk_device); #else fprintf(f, "# %s:\n", partname(disk_device, xbsd_part_index+1, 0)); #endif if ((unsigned) lp->d_type < BSD_DKMAXTYPES) fprintf(f, _("type: %s\n"), xbsd_dktypenames[lp->d_type]); else fprintf(f, _("type: %d\n"), lp->d_type); fprintf(f, _("disk: %.*s\n"), (int) sizeof(lp->d_typename), lp->d_typename); fprintf(f, _("label: %.*s\n"), (int) sizeof(lp->d_packname), lp->d_packname); fprintf(f, _("flags:")); if (lp->d_flags & BSD_D_REMOVABLE) fprintf(f, _(" removable")); if (lp->d_flags & BSD_D_ECC) fprintf(f, _(" ecc")); if (lp->d_flags & BSD_D_BADSECT) fprintf(f, _(" badsect")); fprintf(f, "\n"); /* On various machines the fields of *lp are short/int/long */ /* In order to avoid problems, we cast them all to long. */ fprintf(f, _("bytes/sector: %ld\n"), (long) lp->d_secsize); fprintf(f, _("sectors/track: %ld\n"), (long) lp->d_nsectors); fprintf(f, _("tracks/cylinder: %ld\n"), (long) lp->d_ntracks); fprintf(f, _("sectors/cylinder: %ld\n"), (long) lp->d_secpercyl); fprintf(f, _("cylinders: %ld\n"), (long) lp->d_ncylinders); fprintf(f, _("rpm: %d\n"), lp->d_rpm); fprintf(f, _("interleave: %d\n"), lp->d_interleave); fprintf(f, _("trackskew: %d\n"), lp->d_trackskew); fprintf(f, _("cylinderskew: %d\n"), lp->d_cylskew); fprintf(f, _("headswitch: %ld\t\t# milliseconds\n"), (long) lp->d_headswitch); fprintf(f, _("track-to-track seek: %ld\t# milliseconds\n"), (long) lp->d_trkseek); fprintf(f, _("drivedata: ")); for (i = NDDATA - 1; i >= 0; i--) if (lp->d_drivedata[i]) break; if (i < 0) i = 0; for (j = 0; j <= i; j++) fprintf(f, "%ld ", (long) lp->d_drivedata[j]); } fprintf (f, _("\n%d partitions:\n"), lp->d_npartitions); fprintf (f, _("# start end size fstype [fsize bsize cpg]\n")); pp = lp->d_partitions; for (i = 0; i < lp->d_npartitions; i++, pp++) { if (pp->p_size) { if (display_in_cyl_units && lp->d_secpercyl) { fprintf(f, " %c: %8ld%c %8ld%c %8ld%c ", 'a' + i, (long) pp->p_offset / lp->d_secpercyl + 1, (pp->p_offset % lp->d_secpercyl) ? '*' : ' ', (long) (pp->p_offset + pp->p_size + lp->d_secpercyl - 1) / lp->d_secpercyl, ((pp->p_offset + pp->p_size) % lp->d_secpercyl) ? '*' : ' ', (long) pp->p_size / lp->d_secpercyl, (pp->p_size % lp->d_secpercyl) ? '*' : ' '); } else { fprintf(f, " %c: %8ld %8ld %8ld ", 'a' + i, (long) pp->p_offset, (long) pp->p_offset + pp->p_size - 1, (long) pp->p_size); } if ((unsigned) pp->p_fstype < BSD_FSMAXTYPES) fprintf(f, "%8.8s", xbsd_fstypes[pp->p_fstype].name); else fprintf(f, "%8x", pp->p_fstype); switch (pp->p_fstype) { case BSD_FS_UNUSED: fprintf(f, " %5ld %5ld %5.5s ", (long) pp->p_fsize, (long) pp->p_fsize * pp->p_frag, ""); break; case BSD_FS_BSDFFS: fprintf(f, " %5ld %5ld %5d ", (long) pp->p_fsize, (long) pp->p_fsize * pp->p_frag, pp->p_cpg); break; default: fprintf(f, "%22.22s", ""); break; } fprintf(f, "\n"); } } }
bool PCBMODEL::getModelLabel( const std::string aFileName, TDF_Label& aLabel ) { MODEL_MAP::const_iterator mm = m_models.find( aFileName ); if( mm != m_models.end() ) { aLabel = mm->second; return true; } aLabel.Nullify(); Handle( TDocStd_Document ) doc; m_app->NewDocument( "MDTV-XCAF", doc ); FormatType modelFmt = fileType( aFileName.c_str() ); switch( modelFmt ) { case FMT_IGES: if( !readIGES( doc, aFileName.c_str() ) ) { std::ostringstream ostr; #ifdef __WXDEBUG__ ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n"; #endif /* __WXDEBUG */ ostr << " * readIGES() failed on filename '" << aFileName << "'\n"; wxLogMessage( "%s", ostr.str().c_str() ); return false; } break; case FMT_STEP: if( !readSTEP( doc, aFileName.c_str() ) ) { std::ostringstream ostr; #ifdef __WXDEBUG__ ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n"; #endif /* __WXDEBUG */ ostr << " * readSTEP() failed on filename '" << aFileName << "'\n"; wxLogMessage( "%s", ostr.str().c_str() ); return false; } break; case FMT_WRL: /* WRL files are preferred for internal rendering, * due to superior material properties, etc. * However they are not suitable for MCAD export. * * If a .wrl file is specified, attempt to locate * a replacement file for it. * * If a valid replacement file is found, the label * for THAT file will be associated with the .wrl file * */ { wxFileName wrlName( aFileName ); wxString basePath = wrlName.GetPath(); wxString baseName = wrlName.GetName(); // List of alternate files to look for // Given in order of preference // (Break if match is found) wxArrayString alts; // Step files alts.Add( "stp" ); alts.Add( "step" ); alts.Add( "STP" ); alts.Add( "STEP" ); alts.Add( "Stp" ); alts.Add( "Step" ); // IGES files alts.Add( "iges" ); alts.Add( "IGES" ); alts.Add( "igs" ); alts.Add( "IGS" ); //TODO - Other alternative formats? for( auto alt : alts ) { wxFileName altFile( basePath, baseName + "." + alt ); if( altFile.IsOk() && altFile.FileExists() ) { std::string altFileName = altFile.GetFullPath().ToStdString(); if( getModelLabel( altFileName, aLabel ) ) { return true; } } } } break; // TODO: implement IDF and EMN converters default: return false; } aLabel = transferModel( doc, m_doc ); if( aLabel.IsNull() ) { std::ostringstream ostr; #ifdef __WXDEBUG__ ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n"; #endif /* __WXDEBUG */ ostr << " * could not transfer model data from file '" << aFileName << "'\n"; wxLogMessage( "%s", ostr.str().c_str() ); return false; } // attach the PART NAME ( base filename: note that in principle // different models may have the same base filename ) wxFileName afile( aFileName.c_str() ); std::string pname( afile.GetName().ToUTF8() ); TCollection_ExtendedString partname( pname.c_str() ); TDataStd_Name::Set( aLabel, partname ); m_models.insert( MODEL_DATUM( aFileName, aLabel ) ); ++m_components; return true; }
void processFile(HumdrumFile& infile) { int i, j; int pindex; int hastext = 0; vector<int> ktracks; infile.getTracksByExInterp(ktracks, "**kern"); int partcount = ktracks.size(); vector<int> rktracks; rktracks.resize(infile.getMaxTracks() + 1); fill(rktracks.begin(), rktracks.end(), -1); for (i=0; i<(int)ktracks.size(); i++) { rktracks[ktracks[i]] = i; } char buffer[1024] = {0}; vector<string> partname(partcount); vector<string> partabbr(partcount); for (i=0; i<partcount; i++) { sprintf(buffer, "part %d", partcount - i); partname[i] = buffer; sprintf(buffer, "P%d", partcount - i); partabbr[i] = buffer; } for (i=0; i<infile.getNumLines(); i++) { if (infile[i].isData()) { break; } if (!infile[i].isInterpretation()) { continue; } for (j=0; j<infile[i].getFieldCount(); j++) { if (infile[i].isExInterp(j, "**text")) { hastext = 1; } if (!infile[i].isExInterp(j, "**kern")) { continue; } pindex = rktracks[infile[i].getPrimaryTrack(j)]; if (strncmp(infile[i][j], "*I\"", 3) == 0) { partname[pindex] = &(infile[i][j][3]); } else if (strncmp(infile[i][j], "*I'", 3) == 0) { partabbr[pindex] = &(infile[i][j][3]); } } } cout << "**spine\t**pname\t**pabbr\n"; cout << "!!voice-count:\t" << partcount << "\n"; for (i=0; i<(int)ktracks.size(); i++) { cout << ktracks[i] << "\t"; cout << partname[i] << "\t"; cout << partabbr[i]; cout << "\n"; } if (hastext) { cout << "!!has-text:\ttrue\n"; } cout << "*-\t*-\t*-\t\n"; }