Advertisement
Guest User

Untitled

a guest
Nov 22nd, 2012
107
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 4.73 KB | None | 0 0
  1. uint64 jpWindow::GetVRCDSize()
  2. {
  3.     char command[1024];
  4.     char buffer[1024], buf[1024];
  5.     uint32 i;
  6.     uint64 tempas = 0;
  7.     if (IMAGE_TYPE == 0) {
  8.         FILE* f1;
  9.         sprintf(command, "mkisofs -print-size %s %s -gui -f -V \"%s\" -C %s \"%s\" 2>&1", DATA_STRING, BOOTSTRING, VOL_NAME, fBurnDevice->scsiid, BURN_DIR);
  10.         printf("com: %s\n",command);
  11.         f1 = popen(command, "r");
  12.         while (!feof(f1) && !ferror(f1)) {
  13.             buffer[0] = 0;
  14.             fgets(buffer, 1024, f1);    //printf("# %s",buffer);
  15.             if (!strncmp("Total extents scheduled to be written = ", &buffer[0], 40)) {
  16.                 for (i = 0; i < strlen(&buffer[40]); i++) {
  17.                     if ((buffer[i + 40] != '\n') || (buffer[i + 41] != '\0'))
  18.                         buf[i] = buffer[i + 40];
  19.                 }
  20.             }
  21.         }
  22.         pclose(f1);
  23.         tempas = atol(buf) * 2048;
  24.     } else if (IMAGE_TYPE == 1)
  25.         tempas = GetBFSSize();
  26.  
  27.     return tempas;
  28. }
  29.  
  30.  
  31. void jpWindow::CalculateSize()
  32. {
  33.     BFile f1;
  34.     char temp_char[1024];
  35.     char what[100];
  36.     uint32 angle_temp[100];
  37.     uint32 tracks, i;
  38.     off_t temp, total_audio, total, total_iso, total_vrcd;
  39.    
  40.     total_audio = 0;
  41.     total = 0;
  42.     total_iso = 0;
  43.     total_vrcd = 0;
  44.     temp = 0;   nrtracks = 0;
  45.    
  46.     if (BURN_TYPE == 0) {
  47.         sprintf(what, "DataCD");
  48.         total_vrcd = total = total_iso = total_audio = 0;
  49.         fStatusBar->SetBarColor(blue);
  50.         if (fLeftList->CountItems() > 0) {
  51.             LeftListItem* item1 = (LeftListItem*)fLeftList->ItemAt(0);
  52.             if (item1->fIconBitmap == fLeftList->fISOBitmap) {
  53.                 f1.SetTo(&item1->fRef, B_READ_ONLY);
  54.                 f1.GetSize(&temp);
  55.                 total_iso += temp;
  56.                 angle_temp[0] = temp / 1024 / 1024;
  57.                 nrtracks = 1;
  58.             } else if (item1->fIconBitmap == fLeftList->fVRCDBitmap) {
  59.                 nrtracks = 1;
  60.                 total_vrcd = temp = GetVRCDSize();
  61.                 angle_temp[0] = temp / 1024 / 1024;
  62.             }
  63.         }
  64.     } else if (BURN_TYPE == 1) {
  65.         sprintf(what, "AudioCD");
  66.         total_vrcd = total = total_iso = total_audio = temp = 0;
  67.         fStatusBar->SetBarColor(green);
  68.         if (fLeftList->CountItems() > 0) {
  69.             LeftListItem* item1 = (LeftListItem*)fLeftList->ItemAt(0);
  70.             LeftListItem* item2 = (LeftListItem*)fLeftList->ItemAt(1);
  71.             if (item1->fIconBitmap == fLeftList->fAudioBitmap) {
  72.                 tracks = fLeftList->CountItems();
  73.                 for (i = 0; i < tracks; i++) {
  74.                     item1 = (LeftListItem*)fLeftList->ItemAt(i);
  75.                     f1.SetTo(&item1->fRef, B_READ_ONLY);
  76.                     f1.GetSize(&temp);
  77.                     total_audio += temp;
  78.                     angle_temp[i] = temp / 1024 / 1024;
  79.                     nrtracks++;
  80.                 }
  81.             } else if (fLeftList->CountItems() > 1) {
  82.                 if (item2->fIconBitmap == fLeftList->fAudioBitmap) {
  83.                     tracks = fLeftList->CountItems();
  84.                     for (i = 1; i < tracks; i++) {
  85.                         item1 = (LeftListItem*)fLeftList->ItemAt(i);
  86.                         f1.SetTo(&item1->fRef, B_READ_ONLY);
  87.                         f1.GetSize(&temp);
  88.                         total_audio += temp;
  89.                         angle_temp[i - 1] = temp / 1024 / 1024;
  90.                         nrtracks++;
  91.                     }
  92.                 }
  93.             }
  94.         }
  95.     } else if (BURN_TYPE == 2) {
  96.         sprintf(what, "MixCD");
  97.         total_vrcd = total = total_iso = total_audio = 0;
  98.         fStatusBar->SetBarColor(greenblue);
  99.         if (fLeftList->CountItems() > 0) {
  100.             LeftListItem* item1 = (LeftListItem*)fLeftList->ItemAt(0);
  101.             LeftListItem* item2 = (LeftListItem*)fLeftList->ItemAt(1);
  102.             if (item1->fIconBitmap == fLeftList->fISOBitmap) {
  103.                 nrtracks = 1;
  104.                 f1.SetTo(&item1->fRef, B_READ_ONLY);
  105.                 f1.GetSize(&temp);
  106.                 total_iso = temp;
  107.                 angle_temp[nrtracks - 1] = temp / 1024 / 1024;
  108.             } else if (item1->fIconBitmap == fLeftList->fVRCDBitmap) {
  109.                 nrtracks = 1;
  110.                 total_vrcd = temp = GetVRCDSize();
  111.                 angle_temp[nrtracks - 1] = temp / 1024 / 1024;
  112.             }
  113.  
  114.             if (item1->fIconBitmap == fLeftList->fAudioBitmap) {
  115.                 tracks = fLeftList->CountItems();
  116.                 for (i = 0; i < tracks; i++) {
  117.                     item1 = (LeftListItem*)fLeftList->ItemAt(i);
  118.                     f1.SetTo(&item1->fRef, B_READ_ONLY);
  119.                     f1.GetSize(&temp);
  120.                     total_audio += temp;
  121.                     nrtracks++;
  122.                     angle_temp[nrtracks - 1] = temp / 1024 / 1024;
  123.  
  124.                 }
  125.             }
  126.  
  127.             else if (fLeftList->CountItems() > 1)
  128.                 if (item2->fIconBitmap == fLeftList->fAudioBitmap) {
  129.                     tracks = fLeftList->CountItems();
  130.                     for (i = 1; i < tracks; i++) {
  131.                         item1 = (LeftListItem*)fLeftList->ItemAt(i);
  132.                         f1.SetTo(&item1->fRef, B_READ_ONLY);
  133.                         f1.GetSize(&temp);
  134.                         total_audio += temp;
  135.                         nrtracks++;
  136.                         angle_temp[nrtracks - 1] = temp / 1024 / 1024;
  137.                     }
  138.                 }
  139.         }
  140.     }
  141.  
  142.     total = total_audio + total_iso + total_vrcd;
  143.     sprintf(temp_char, "%s - [%lld of 698 Mb]", what, total / 1024 / 1024);
  144.     fStatusBar->Reset();
  145.     fStatusBar->SetMaxValue(CDSIZE);
  146.     fStatusBar->Update((total / 1024 / 1024), temp_char);
  147.  
  148.     for (i = 0; i < nrtracks; i++) {
  149.         if (i == 0)
  150.             angles[i] = ((float)360 / (float)(total / 1024 / 1024)) * (float)angle_temp[i];
  151.         else
  152.             angles[i] = ((float)360 / (float)(total / 1024 / 1024)) * (float)angle_temp[i] + angles[i - 1];
  153.     }
  154. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement