void Sound::Recorder::Flush(const Nes::Sound::Output& output) { if (recording) { NST_VERIFY( file.IsOpen() ); try { for (uint i=0; i < 2; ++i) file.Write( output.samples[i], output.length[i] * waveFormat.nBlockAlign ); } catch (Io::Wave::Exception ids) { recording = false; Window::User::Fail( ids ); return; } size += output.length[0] + output.length[1]; if (size >= nextBigSizeNotification) { nextBigSizeNotification += BIG_SIZE; Window::User::Inform( IDS_WAVE_WARN_FILE_BIG ); } else if (size >= nextSmallSizeNotification) { Io::Screen() << Resource::String(IDS_SCREEN_SOUND_RECORDER_WRITTEN).Invoke( HeapString() << (nextSmallSizeNotification / ONE_MB) ); nextSmallSizeNotification += SMALL_SIZE; } } }
HeapString HeapString::Sub(size_t startPos) const { size_t stringLen = GetStringData()->stringLen; if (startPos >= stringLen) return HeapString(); return Sub(startPos, stringLen - startPos); }
HeapString DateTime::GetTimeZoneName() { #ifdef MEDUSA_WINDOWS //return _tzname[0]; size_t s; char tzname[100]; _get_tzname(&s, tzname, sizeof(tzname), 0); return HeapString(tzname, s - 1); #else return HeapString(tzname[0]); /*size_t s; char tzname[100]; get_tzname( &s, tzname, sizeof(tzname), 0 ); return HeapString(tzname,s-1);*/ #endif }
int main(void) { String resp = HeapString(1024 * 150); // Fetch max. 150 KiB HTTP_Client_GetResponse($("www.kernel.org"), $("/"), 80, &resp); String_Print(resp); String_Destroy(&resp); return ExitStatus_Success; }
HeapString HeapString::BeforeLast(char ch) const { HeapString str; int pos = ReverseFind(ch); if (pos == -1) str = *this; else str = HeapString(m_string, pos); return str; }
HeapString HeapString::Sub(size_t startPos, size_t count) const { size_t stringLen = GetStringData()->stringLen; if (startPos > stringLen || count == 0) return HeapString(); if (startPos + count > stringLen) count = stringLen - startPos; HeapString dest; dest.AllocBuffer(count); memcpy(dest.m_string, m_string + startPos, count * sizeof(char)); return dest; }
void Launcher::UpdateItemCount(const uint count) const { if (count == 0 || count == 1) { menu[IDM_LAUNCHER_EDIT_FIND].Enable( count ); menu[IDM_LAUNCHER_EDIT_CLEAR].Enable( count ); } static HeapString form( HeapString() << ' ' << Resource::String(IDS_TEXT_FILES) << ": " ); const uint length = form.Length(); statusBar.Text(StatusBar::SECOND_FIELD) << (form << count).Ptr(); form.ShrinkTo( length ); }
main(int argc, char *argv[]) { CDReader *cdreaderP; FILEHANDLE image_file; UWORD audio_blklen, mode1_blklen, mode2_blklen; TCHAR image_filnam[_MAX_PATH + 1]; TCHAR cue_filnam[_MAX_PATH + 1]; TCHAR cdtext_filnam[_MAX_PATH + 1]; TCHAR *image_filnamP = NULL, *cue_filnamP = NULL, *cdtext_filnamP = NULL; // Enable exception handling. EXCEPTION_HANDLER_START // Initialize and check the protection. ProtInitialize (NULL, FALSE); // Get the environment variables. GetEnvironmentVariables(); // Parse the command line arguments. ParseCommandLine (argc, argv); // Register the event callback function. EventRegisterCallback (ConsoleEventCallback); // Startup the ASPI manager. ASPIAdapter::StartupManager (FALSE, FALSE, TRUE); // Find a CDROM device... if (cdreader_id_specified) { if ((cdreaderP = (CDReader *)ASPIAdapter::FindDeviceObject ( ASPI_M_DEVTYPE_CDROM | ASPI_M_DEVTYPE_WORM, cdreader_adapter, cdreader_id, cdreader_lun)) == NULL) { fprintf (stderr, "\nError: Specified device (%u:%u:%u) is not a CDROM!\n", cdreader_adapter, cdreader_id, cdreader_lun); exit (1); } } else { if ((cdreaderP = (CDReader *)ASPIAdapter::FindDeviceObject ( ASPI_M_DEVTYPE_CDROM | ASPI_M_DEVTYPE_WORM)) == NULL) { fprintf (stderr, "\nError: Unable to find a known CDROM device!\n"); exit (1); } } if (log_flag) { printf ("CDROM device found...\n"); printf (" HA #%u - ASPI ID #%u - %-8s %-16s %-4s\n\n", cdreaderP->GetAdapter(), cdreaderP->GetId(), cdreaderP->GetVendorId(), cdreaderP->GetProductId(), cdreaderP->GetFirmwareLevel()); } if (cdreaderP->GetModel() == GENERIC_CDROM_SCSI) { fprintf (stderr, "Warning: CDROM device model is unknown to this program!\n"); fprintf (stderr, "The generic CDROM device driver will be used...\n\n"); } // If necessary, check that this device supports the reading of SUBCODEs. if ((scan_subcode_mode == SCAN_SUBCODE_QUICK) || (scan_subcode_mode == SCAN_SUBCODE_FULL)) { if (! cdreaderP->IsFlagSet(CDReader::crfReadSUBQ)) { fprintf (stderr, "Error: CDROM device does not support the reading of subcodes!\n"); exit (1); } } // If necessary, check that this device supports the reading of CD+G discs. if (cdg_flag && (! cdreaderP->IsFlagSet(CDReader::crfReadCDG))) { fprintf (stderr, "Error: CDROM device does not support the reading of CD+G discs!\n"); exit (1); } // Analyze the disc layout. auto_ptr<DiscLayout> disclayoutP(new DiscLayout ( cdreaderP, read_speed, scan_subcode_mode, mcn_isrc_flag, cdtext_flag, log_flag)); if (log_flag) { printf ("\nDisc Statistics:\n"); printf (" Audio track count - %u\n", disclayoutP->m_nAudioTrackCount); printf (" Mode1 data track count - %u\n", disclayoutP->m_nMode1TrackCount); printf (" Mode2 data track count - %u\n", disclayoutP->m_nMode2TrackCount); } // Is the disc too long? if (disclayoutP->m_nLastLBA > CDROM_80MIN_BLKCNT) fprintf (stderr, "\nWARNING: Disc is longer than 80 minutes!\n"); // Check the disc layout. if (! disclayoutP->Check()) { fprintf (stderr, "\nWARNING: Disc contains one or more tracks that are shorter than \n"); fprintf (stderr, "four seconds. This is a violation of the CDROM specification.\n"); } // Determine the block lengths. audio_blklen = (cdg_flag ? SECTOR_CDDA_SUBPW_BLKLEN : SECTOR_CDDA_BLKLEN); if (cooked_flag) {mode1_blklen = SECTOR_MODE1_BLKLEN; mode2_blklen = SECTOR_MODE2_BLKLEN;} else {mode1_blklen = SECTOR_RAW_BLKLEN; mode2_blklen = SECTOR_RAW_BLKLEN;} // Set the block length for each track. DiscInfo *discinfoP = disclayoutP->m_pDiscInfo; for (int i = 0; i < discinfoP->m_nTrackCount; i++) { TRACKINFO *trackinfoP = &discinfoP->m_TrackInfo[i]; switch (trackinfoP->datatype) { case DATATYPE_CDDA: trackinfoP->blklen = audio_blklen; break; case DATATYPE_CDROM: trackinfoP->blklen = mode1_blklen; break; case DATATYPE_CDROMXA: case DATATYPE_CDI: trackinfoP->blklen = mode2_blklen; break; } } // Build the cuesheet filename. StringCopy (cue_filnam, base_filnamP); FileAddExtension (cue_filnam, ".cue", (! cueonly_flag)); cue_filnamP = cue_filnam; // If we're not just writing a cuesheet, then build the image and CD-TEXT filenames. if (! cueonly_flag) { StringCopy (image_filnam, base_filnamP); FileAddExtension (image_filnam, ".bin", FALSE); image_filnamP = image_filnam; if (cdtext_flag && (discinfoP->m_pCDTextPackVec != NULL)) { StringCopy (cdtext_filnam, base_filnamP); FileAddExtension (cdtext_filnam, ".cdt", TRUE); cdtext_filnamP = cdtext_filnam; } // Display image file stats? if (log_flag) { // Compute the amount of disc space required. ULONG blkcnt = disclayoutP->m_nLastLBA + 1; printf ("\nImage file will require approximately %luMb of disk space.\n", CDIV (blkcnt * SECTOR_RAW_BLKLEN, 0x100000)); } // Prompt to begin copy? if (confirm_flag) { printf ("\nHit <ENTER> to copy disc (or CTRL/C to exit)..."); getchar (); printf ("\n"); } } // Generate the CUE SHEET file. disclayoutP->GenerateCuesheetFile (cue_filnamP, image_filnamP, cdtext_filnamP); // Generate the CD-TEXT data file? if (cdtext_filnamP != NULL) { FILEHANDLE handle; ULONG null = 0; if ((handle = FileCreate (cdtext_filnamP)) == NULL) SignalException (E_CreateFile, 1, 0, 0, HeapString(cdtext_filnamP)); FileWrite ( handle, discinfoP->m_pCDTextPackVec, discinfoP->m_nCDTextPackCount * sizeof(CDTEXTPACK)); FileWrite (handle, &null, 1); FileClose (handle); } // Generate the image file? if (image_filnamP != NULL) { // Make sure the device is ready. cdreaderP->LoadDisc (TRUE); // Create the output image file. if ((image_file = FileCreate (image_filnamP)) == NULL) { fprintf (stderr, "\nError creating image file \"%s\"\n", image_filnamP); exit (1); } // Loop through the "copy instructions"... for (int i = 0; i < disclayoutP->m_nCopyInstrCount; i++) { COPYINSTR *copyinstrP = &disclayoutP->m_CopyInstr[i]; // Set the block length. UWORD blklen = ((copyinstrP->datatype == DATATYPE_CDDA) ? audio_blklen : ((copyinstrP->datatype == DATATYPE_CDROM) ? mode1_blklen : mode2_blklen)); // Select operation... switch (copyinstrP->opcode) { // Read a range of audio/data sectors. case CI_READ_SECTORS: { if (copyinstrP->datatype == DATATYPE_CDDA) { // Set the reading speed. cdreaderP->SetSpindleSpeed (read_speed, FALSE, FALSE); // Extract the audio sectors. cdreaderP->ExtractSectorsToFile ( image_file, DATATYPE_CDDA, blklen, copyinstrP->lba, copyinstrP->blkcnt, jitter_mode, 0, error_mode, FALSE, log_flag); } else { // Set the reading speed to maximum. cdreaderP->SetSpindleSpeed (SPEED_MAX, TRUE, FALSE); // Extract the data sectors. cdreaderP->ExtractSectorsToFile ( image_file, copyinstrP->datatype, blklen, copyinstrP->lba, copyinstrP->blkcnt, JITTER_MODE_DISABLE, 0, error_mode, FALSE, log_flag); } break; } // Generate replacements for unreadable blocks at the end of a track. case CI_GENERATE_SECTORS: { WriteEmptySectors ( image_file, copyinstrP->datatype, blklen, copyinstrP->lba, copyinstrP->blkcnt); break; } // Ignore PREGAP instructions. case CI_GENERATE_PREGAP: case CI_GENERATE_PREGAP2: break; default: SignalException (E_BugCheck); } } // Reset the reading speed. cdreaderP->SetSpindleSpeed (SPEED_MAX, FALSE, FALSE); // Close the image file. FileClose (image_file); // Success! if (log_flag) printf ("\nCopy completed successfully!\n"); // Notify user of completion? if (beep_flag) BeepUser(); } // Shutdown the ASPI manager. ASPIAdapter::ShutdownManager(); // End exception handling. EXCEPTION_HANDLER_EXIT return (0); }
HeapString DateTime::ToString(const StringRef& formaterStr) const { char s[256]; strftime(s, sizeof(s), formaterStr.c_str(), &mDate); return HeapString(s); }
HeapString StringParser::StringTo(const StringRef& inString, int base /*= 10*/) { return HeapString(inString); }
inline HeapString ScriptObject::GetReturn<HeapString>(asIScriptContext* context) { return HeapString((*(HeapString*)context->GetReturnAddress()).c_str()); }