void * BURGERCALL GetRealBufferProtectedPtr(void) { Word32 TempReal; /* Get real pointer and then convert to true pointer */ TempReal = GetRealBufferPtr(); /* Get the buffer pointer */ if (TempReal) { /* Did it allocate? */ return RealToProtectedPtr(TempReal); /* Convert to real pointer */ } return 0; /* Error! */ }
Word Burger::File::Open(Filename *pFileName,eFileAccess eAccess) { static const Word16 g_OpenAccess[4] = { 0x00,0x01,0x01,0x02 }; static const Word16 g_CreateAction[4] = {1,2+16,1+16,1+16}; Close(); // Copy the filename to "Real" memory StringCopy(static_cast<char *>(GetRealBufferProtectedPtr()),pFileName->GetNative()); eAccess = static_cast<eFileAccess>(eAccess&3); Regs16 Regs; Word32 uTemp = GetRealBufferPtr(); // Local buffer Word uResult = FILENOTFOUND; // Are long filenames supported? if (!FileManager::AreLongFilenamesAllowed()) { // Use the old dos commands // Open preexisting file? Regs.ax = g_OpenAccess[eAccess]+0x3D00; Regs.dx = static_cast<Word16>(uTemp); // Pass the filename buffer Regs.ds = static_cast<Word16>(uTemp>>16); // Get the segment // Int 0x21,0x3D Open Int86x(0x21,&Regs,&Regs); if (!(Regs.flags&1)) { // Preexisting file was opened m_pFile = reinterpret_cast<void *>(Regs.ax); uResult = OKAY; if (eAccess==APPEND) { uResult= SetMarkAtEOF(); } } else { if (eAccess!=READONLY) { // Attempt to create the file Int 0x21,0x3C Create Regs.ax = 0x3C00; Regs.cx = 0; Regs.dx = static_cast<Word16>(uTemp); // Pass the filename buffer Regs.ds = static_cast<Word16>(uTemp>>16); // Get the segment Int86x(0x21,&Regs,&Regs); if (!(Regs.flags&1)) { // File was created m_pFile = reinterpret_cast<void *>(Regs.ax); uResult = OKAY; } } }
void Burger::Filename::SetFromNative(const char *pInput) { Clear(); Regs16 Regs; // Used for DOS calls // Parse out the C: (Drive number) // Assume no drive is found Word uDriveNum = static_cast<Word>(-1); // Get the possible drive letter WordPtr uInputLength = Burger::StringLength(pInput); if (uInputLength>=2) { Word uTemp = reinterpret_cast<const Word8*>(pInput)[0]; uTemp = (uTemp&0xDF)-'A'; // Upper case // Could this be a drive letter? if ((uTemp<26) && (reinterpret_cast<const Word8*>(pInput)[1]==':')) { uDriveNum = uTemp; pInput += 2; // Accept the drive letter uInputLength -= 2; // Shrink the input string } } // If not a network name, (//), query MSDOS for the current drive if (uDriveNum==static_cast<Word>(-1)) { if ((uInputLength<2) || (reinterpret_cast<const Word8*>(pInput)[0]!='\\') || (reinterpret_cast<const Word8*>(pInput)[1]!='\\')) { // Get the default drive number _dos_getdrive(&uDriveNum); --uDriveNum; } else { pInput+=2; uInputLength-=2; // Parse past the volume slashes } } WordPtr uWorkingDirectoryLength = 0; const Word8 *pWorkingDirectory = NULL; // Obtain the current working directory for the current drive if (uInputLength && (uDriveNum!=static_cast<Word>(-1))) { if (reinterpret_cast<const Word8*>(pInput)[0] != '\\') { Regs.dx = static_cast<Word16>(uDriveNum+1); // Requested drive Word32 DosBuffer = GetRealBufferPtr(); // Get real memory buffer Regs.ds = static_cast<Word16>(DosBuffer>>16U); // Pass to Dos call Regs.si = static_cast<Word16>(DosBuffer&0xFFFFU); Regs.ax = 0x7147; // First try long version Int86x(0x21,&Regs,&Regs); // Call DOS if (Regs.flags&1) { // Carry set?? Regs.ax = 0x4700; // Try DOS 2.0 version Int86x(0x21,&Regs,&Regs); // Get the working directory } // If carry is clear, then one of the preceeding calls succeeded if (!(Regs.flags&1)) { // Convert to my pointer pWorkingDirectory = static_cast<Word8 *>(RealToProtectedPtr(DosBuffer)); uWorkingDirectoryLength = Burger::StringLength(reinterpret_cast<const char *>(pWorkingDirectory)); } } else { --uInputLength;