home *** CD-ROM | disk | FTP | other *** search
Text File | 1995-11-08 | 22.8 KB | 822 lines | [TEXT/MPS ] |
- //========================================================================================
- //
- // File: FWFilRep.cpp
- // Release Version: $ 1.0d11 $
- //
- // Copyright: 1995 by Apple Computer, Inc., all rights reserved.
- //
- //========================================================================================
-
- #include "FWOS.hpp"
-
- #ifndef FWFILREP_H
- #include "FWFilRep.h"
- #endif
-
- #include <Limits.h>
-
- #ifndef FWFILEAC_H
- #include "FWFileAc.h"
- #endif
-
- #ifndef FWPRIDEB_H
- #include "FWPriDeb.h"
- #endif
-
- #ifndef FWEXCDEF_H
- #include "FWExcDef.h"
- #endif
-
- #if defined(FW_BUILD_MAC) && !defined(__FILES__)
- #include "Files.h"
- #endif
-
- #if defined(FW_BUILD_WIN) && !defined(IO_H)
- #include "io.h"
- #endif
-
- #if FW_LIB_EXPORT_PRAGMAS
- #pragma lib_export on
- #endif
-
- #ifdef FW_BUILD_MAC
- #pragma segment File
- #endif
-
- #ifdef FW_BUILD_WIN16
- extern "C" void FAR PASCAL DOS3Call(); // We use this instead of calling "Int 21h"
- #endif
-
- //========================================================================================
- // CLASS FW_PFile
- //========================================================================================
-
- //----------------------------------------------------------------------------------------
- // FW_PFile::FW_PFile
- //----------------------------------------------------------------------------------------
-
- FW_PFile::FW_PFile(FW_CFileRep* privFileAccessRep) :
- FW_CCountedPtr(privFileAccessRep)
- {
- }
-
- //----------------------------------------------------------------------------------------
- // FW_PFile::FW_PFile
- //----------------------------------------------------------------------------------------
-
- FW_PFile::FW_PFile(const FW_CFileSpecification& fileSpecification,
- long bufferSize,
- FW_Boolean allowCreate) :
- FW_CCountedPtr(new FW_CFileRep(fileSpecification, bufferSize, allowCreate))
- {
- }
-
- //----------------------------------------------------------------------------------------
- // FW_PFile::FW_PFile
- //----------------------------------------------------------------------------------------
-
- FW_PFile::FW_PFile(const FW_CFileSpecification& fileSpecification,
- const FW_CAccessPermission& permission,
- long bufferSize,
- FW_Boolean allowCreate) :
- FW_CCountedPtr(new FW_CFileRep(fileSpecification, permission, bufferSize, allowCreate))
- {
- }
-
- //----------------------------------------------------------------------------------------
- // FW_PFile::~FW_PFile
- //----------------------------------------------------------------------------------------
-
- FW_PFile::~FW_PFile()
- {
- }
-
- //========================================================================================
- // CLASS FW_CFileRep
- //
- // The FW_CFileRep class provides the implementation for FW_PFile. It is separate
- // from FW_PFile for the purpose of reference counting. Since this is an
- // implementation class, it should not be modified by the user.
- //========================================================================================
-
- //----------------------------------------------------------------------------------------
- // FW_CFileRep::FW_CFileRep
- //----------------------------------------------------------------------------------------
- FW_CFileRep::FW_CFileRep(const FW_CFileSpecification& fileSpecification,
- long bufferSize,
- FW_Boolean allowCreate) :
- FW_CCountedPtrRep(),
- fFileSpec(fileSpecification),
- fPermission(),
- fFileHandle(0),
- fFileBuffer(bufferSize)
- {
- PrivOpenFile(allowCreate);
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CFileRep::FW_CFileRep
- //----------------------------------------------------------------------------------------
-
- FW_CFileRep::FW_CFileRep(const FW_CFileSpecification& fileSpecification,
- const FW_CAccessPermission& permission,
- long bufferSize,
- FW_Boolean allowCreate) :
- FW_CCountedPtrRep(),
- fFileSpec(fileSpecification),
- fPermission(permission),
- fFileHandle(0),
- fFileBuffer(bufferSize)
- {
- PrivOpenFile(allowCreate);
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CFileRep::~FW_CFileRep
- //----------------------------------------------------------------------------------------
-
- FW_CFileRep::~FW_CFileRep()
- {
- PrivCloseFile();
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CFileRep::Read
- //----------------------------------------------------------------------------------------
- void FW_CFileRep::Read(void* destination, long count)
- {
- FlushAndInvalidateBuffer();
-
- PrivDoRead(destination, count);
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CFileRep::ReadPeek
- //----------------------------------------------------------------------------------------
- const void* FW_CFileRep::ReadPeek(long& availableReadBytes)
- {
- long currentPosition = GetPosition();
- void * source = fFileBuffer.ReadPeek(currentPosition, availableReadBytes);
-
- if (availableReadBytes == 0)
- {
- FlushAndInvalidateBuffer();
- availableReadBytes = FW_Minimum(BytesToEndOfFile(), fFileBuffer.GetCapacity());
- fFileBuffer.Initialize(FW_CPrivFileAccessBuffer::kReadPeek, currentPosition, availableReadBytes);
- source = fFileBuffer.GetAddress();
-
- long savePosition = GetPosition();
- PrivDoRead(source, availableReadBytes);
- SetPosition(FW_CFileSystem::kFromStart, savePosition);
- }
-
- return source;
- }
-
-
- //----------------------------------------------------------------------------------------
- // FW_CFileRep::ReadPeekAdvance
- //----------------------------------------------------------------------------------------
- void FW_CFileRep::ReadPeekAdvance(long bytesRead)
- {
- fFileBuffer.ReadPeekAdvance(GetPosition(), bytesRead);
-
- SetPosition(FW_CFileSystem::kFromCurrent, bytesRead);
- }
-
-
- //----------------------------------------------------------------------------------------
- // FW_CFileRep::Write
- //----------------------------------------------------------------------------------------
- void FW_CFileRep::Write(const void* source, long count)
- {
- FlushAndInvalidateBuffer();
-
- PrivDoWrite(source, count);
- }
-
-
- //----------------------------------------------------------------------------------------
- // FW_CFileRep::WritePeek
- //----------------------------------------------------------------------------------------
- void* FW_CFileRep::WritePeek(long& availableWriteBytes)
- {
- long currentPosition = GetPosition();
- void * source = fFileBuffer.WritePeek(currentPosition, availableWriteBytes);
-
- if (availableWriteBytes == 0)
- {
- FlushAndInvalidateBuffer();
- availableWriteBytes = fFileBuffer.GetCapacity();
- fFileBuffer.Initialize(FW_CPrivFileAccessBuffer::kWritePeek, currentPosition, availableWriteBytes);
- source = fFileBuffer.GetAddress();
- }
-
- return source;
- }
-
-
- //----------------------------------------------------------------------------------------
- // FW_CFileRep::WritePeekAdvance
- //----------------------------------------------------------------------------------------
- void FW_CFileRep::WritePeekAdvance(long bytesWritten)
- {
- fFileBuffer.WritePeekAdvance(GetPosition(), bytesWritten);
-
- long newPosition = GetPosition() + bytesWritten;
- if (newPosition > GetLength())
- SetLength(newPosition);
-
- SetPosition(FW_CFileSystem::kFromStart, newPosition);
- }
-
-
- //----------------------------------------------------------------------------------------
- // FW_CFileRep::GetLength
- //----------------------------------------------------------------------------------------
- long FW_CFileRep::GetLength() const
- {
- long length;
-
- #ifdef FW_BUILD_WIN
- // Since Windows does not support this feature directly, we have to reset the file
- // pointer to get the length and then restore the original position.
- long oldPosition = GetPosition();
- FW_FailOnError(PrivWinMoveFilePointer(0, FW_CFileSystem::kFromEnd, length));
- FW_FailOnError(PrivWinMoveFilePointer(oldPosition, FW_CFileSystem::kFromStart, oldPosition));
- #endif
-
- #ifdef FW_BUILD_MAC
- long macEOF;
-
- FW_FailOnError(::GetEOF(fFileHandle, &macEOF));
- length = macEOF;
- #endif
-
- return length;
- }
-
-
- //----------------------------------------------------------------------------------------
- // FW_CFileRep::SetLength
- //----------------------------------------------------------------------------------------
- void FW_CFileRep::SetLength(long length)
- {
- FW_CFileSystem::FileError theError = FW_CFileSystem::kNoError;
-
- // If file is shrinking, then assume our buffer is no longer valid.
- long currentLength = GetLength();
- if (length < currentLength)
- FlushAndInvalidateBuffer();
-
- #ifdef FW_BUILD_WIN16
- long oldPosition = GetPosition();
- FW_FailOnError(PrivWinMoveFilePointer(length, FW_CFileSystem::kFromStart, length));
-
- // writing 0 bytes truncates the file at the current position
- char buf;
- short actualWritten;
- FW_CFileSystem::FileError writeError = PrivWinPrimitiveWrite(fFileHandle, 0, &buf, actualWritten);
-
- // move back to the old position, regardless of whether the write was successfull
- if(oldPosition > length)
- oldPosition = length;
- FW_CFileSystem::FileError seekError = PrivWinMoveFilePointer(oldPosition, FW_CFileSystem::kFromStart, oldPosition);
-
- if(writeError != FW_CFileSystem::kNoError)
- FW_FailOnError(writeError);
- else
- FW_FailOnError(seekError);
- #endif
-
- #ifdef FW_BUILD_WIN32
- long oldPosition = GetPosition();
- SetPosition(FW_CFileSystem::kFromStart, length);
- if (!::SetEndOfFile(fFileHandle))
- theError = ::GetLastError();
- SetPosition(FW_CFileSystem::kFromStart, oldPosition);
- #endif
-
- #ifdef FW_BUILD_MAC
- theError = ::SetEOF(fFileHandle, length);
- #endif
-
- FW_FailOnError(theError);
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CFileRep::GetPosition
- //----------------------------------------------------------------------------------------
- long FW_CFileRep::GetPosition() const
- {
- FW_CFileSystem::FileError theError = FW_CFileSystem::kNoError;
- long currentPosition;
-
- #ifdef FW_BUILD_WIN
- theError = PrivWinMoveFilePointer(0, FW_CFileSystem::kFromCurrent, currentPosition);
- #endif
-
- #ifdef FW_BUILD_MAC
- theError = ::GetFPos(fFileHandle, ¤tPosition);
- #endif
-
- FW_FailOnError(theError);
- return currentPosition;
- }
-
-
- //----------------------------------------------------------------------------------------
- // FW_CFileRep::SetPosition
- //----------------------------------------------------------------------------------------
- void FW_CFileRep::SetPosition(FW_CFileSystem::MoveMethods positioningMode,
- long markOffset)
- {
- FW_CFileSystem::FileError theError = FW_CFileSystem::kNoError;
-
- #ifdef FW_BUILD_WIN
- theError = PrivWinMoveFilePointer(markOffset, positioningMode, markOffset);
- #endif
-
- #ifdef FW_BUILD_MAC
- long newLength = markOffset;
- theError = ::SetFPos(fFileHandle, positioningMode, newLength);
- #endif
-
- switch (theError)
- {
- #ifdef FW_BUILD_WIN16
- case FW_CFileSystem::kPermissionError:
- // Win16 returns this error to indicate an invalid positioningMode.
- theError = FW_CFileSystem::kParameterError;
- break;
- #endif
- default:
- break;
- }
- FW_FailOnError(theError);
- }
-
-
- //----------------------------------------------------------------------------------------
- // FW_CFileRep::BytesToEndOfFile
- //----------------------------------------------------------------------------------------
- long FW_CFileRep::BytesToEndOfFile() const
- {
- return (GetLength() - GetPosition());
- }
-
-
- //----------------------------------------------------------------------------------------
- // FW_CFileRep::GetPermissions
- //----------------------------------------------------------------------------------------
- void FW_CFileRep::GetPermissions(FW_CAccessPermission& thePerms) const
- {
- thePerms = fPermission;
- }
-
-
- //----------------------------------------------------------------------------------------
- // FW_CFileRep::GetFileSpecification
- //----------------------------------------------------------------------------------------
- FW_CFileSpecification FW_CFileRep::GetFileSpecification() const
- {
- return fFileSpec;
- }
-
-
- //----------------------------------------------------------------------------------------
- // FW_CFileRep::operator==
- //----------------------------------------------------------------------------------------
- FW_Boolean FW_CFileRep::operator==(const FW_CFileRep& theOtherFile) const
- {
- return (fFileHandle == theOtherFile.fFileHandle) && (fFileSpec == theOtherFile.fFileSpec);
- }
-
-
- //----------------------------------------------------------------------------------------
- // FW_CFileRep::operator!=
- //----------------------------------------------------------------------------------------
- FW_Boolean FW_CFileRep::operator!=(const FW_CFileRep& theOtherFile) const
- {
- return (fFileHandle != theOtherFile.fFileHandle) || (fFileSpec != theOtherFile.fFileSpec);
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CFileRep::PrivOpenFile
- //
- // Opens the file using the permissions set with SetPermission. If no permissions were
- // set, it tries to open the file for exclusive access. If the file is already open,
- // nothing happens. If any other errors occur, they are thrown as exceptions.
- //----------------------------------------------------------------------------------------
- void FW_CFileRep::PrivOpenFile(FW_Boolean allowCreate)
- {
- FW_CFileSystem::FileError theError = FW_CFileSystem::kNoError;
- FW_CAccessPermission::Access accessMode;
- FW_CAccessPermission::Deny denyMode;
-
- fPermission.GetPermission(accessMode, denyMode);
-
- #ifdef FW_BUILD_WIN
- FW_CDynamicString fileName;
-
- fFileSpec.GetFullPath(fileName);
- #endif
-
- #ifdef FW_BUILD_WIN16
- OFSTRUCT Buffer;
- fFileHandle = ::OpenFile((const FW_Char*)fileName, &Buffer, accessMode | denyMode);
- if (fFileHandle == FW_kInvalidAccessHandle)
- theError = Buffer.nErrCode;
- #endif
-
- #ifdef FW_BUILD_WIN32
- // If we allowCreate, always open the file. Otherwise, open only if it
- // already exists.
- long openMode = (allowCreate ? OPEN_ALWAYS : OPEN_EXISTING);
-
- fFileHandle = ::CreateFile((const FW_Char*)fileName,
- accessMode,
- denyMode,
- NULL,
- openMode,
- FILE_ATTRIBUTE_NORMAL,
- (HANDLE)NULL);
-
- if (fFileHandle == FW_kInvalidAccessHandle)
- theError = ::GetLastError();
- #endif
-
- #ifdef FW_BUILD_MAC
- // If we allowCreate, then try creating the file. If the file already
- // exists, we will FW_CATCH the attempt to re-create it and merrily roll
- // along. If the file does not exist, it will when we're done.
- if (allowCreate)
- {
- FW_TRY
- {
- FW_CFileSystem::CreateFile(fFileSpec, FALSE);
- }
- FW_CATCH_BEGIN
- FW_CATCH(FW_XException, theException)
- {
- if (theException.GetPlatformError() != FW_CFileSystem::kFileExists)
- FW_THROW_SAME();
- }
- FW_CATCH_END
-
- // At this point, the file exists (modulo another thread nuking it).
- }
-
- // Check to see if file sharing exists on this volume. If it does, open the file using
- // deny modes.
- FSSpec theMacSpec;
-
- fFileSpec.MacGetFSSpec(theMacSpec);
-
- if (FW_CFileSystem::MacIsVolumeShared(theMacSpec.vRefNum))
- {
- HParamBlockRec paramBlock;
-
- paramBlock.fileParam.ioNamePtr = (StringPtr) & (theMacSpec.name);
- paramBlock.fileParam.ioVRefNum = theMacSpec.vRefNum;
- paramBlock.fileParam.ioDirID = theMacSpec.parID;
- paramBlock.accessParam.ioDenyModes = accessMode | denyMode;
-
- theError = ::PBHOpenDenySync(¶mBlock);
- fFileHandle = paramBlock.fileParam.ioFRefNum;
- }
- else
- theError = ::FSpOpenDF(&(theMacSpec), accessMode, &fFileHandle);
-
- #endif
-
- FW_FailOnError(theError);
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CFileRep::PrivCloseFile
- //----------------------------------------------------------------------------------------
- void FW_CFileRep::PrivCloseFile()
- {
- FW_CFileSystem::FileError theError = FW_CFileSystem::kNoError;
-
- FlushAndInvalidateBuffer();
-
- #if 0
- //#ifdef FW_BUILD_WIN16
- FW_FileAccessHandle handle = fFileHandle;
-
- __asm {
- mov bx, [handle]
- mov ah, 03Eh
- }
-
- DOS3Call();
-
- __asm {
- jc _error
- xor ax, ax
- }
-
- _error:
-
- __asm {
- mov theError, ax
- }
- #endif
-
- #ifdef FW_BUILD_WIN32
- if(!::CloseHandle(fFileHandle))
- theError = ::GetLastError();
- #endif
-
- #ifdef FW_BUILD_MAC
- theError = ::FSClose(fFileHandle);
- #endif
-
- FW_FailOnError(theError);
-
- fFileHandle = FW_kInvalidAccessHandle;
- }
-
-
- #ifdef FW_BUILD_WIN16
- //----------------------------------------------------------------------------------------
- // FW_CFileRep::PrivWinGetIOBufferSize
- //----------------------------------------------------------------------------------------
- short FW_CFileRep::PrivWinGetIOBufferSize(long bytesDesired,
- const void* buffer)
- {
- short offset = (short)(long)buffer;
- long max = 0x10000L - offset;
- if(max > bytesDesired)
- max = bytesDesired;
- return max > 16384 ? 16384 : (short)max;
- }
-
-
- //----------------------------------------------------------------------------------------
- // FW_CFileRep::PrivWinPrimitiveRead
- //----------------------------------------------------------------------------------------
- FW_CFileSystem::FileError FW_CFileRep::PrivWinPrimitiveRead(FW_FileAccessHandle handle,
- short bytesToRead,
- void* buffer,
- short& bytesActuallyRead)
- {
- FW_CFileSystem::FileError theError;
-
- __asm {
- mov ah, 03Fh
- mov bx, [handle]
- mov cx, [bytesToRead]
- push ds
- lds dx, [buffer]
- }
-
- DOS3Call();
-
- __asm {
- pop ds
- jc _error
- les bx, [bytesActuallyRead]
- mov es:[bx], ax
- xor ax, ax
- }
-
- _error:
-
- __asm {
- mov theError, ax
- };
-
- return (theError);
- }
-
-
- //----------------------------------------------------------------------------------------
- // FW_CFileRep::PrivWinPrimitiveWrite
- //----------------------------------------------------------------------------------------
- FW_CFileSystem::FileError FW_CFileRep::PrivWinPrimitiveWrite(FW_FileAccessHandle handle,
- short bytesToWrite,
- const void* buffer,
- short& bytesActuallyWritten)
- {
- FW_CFileSystem::FileError theError;
-
- __asm {
- mov ah, 040h
- mov bx, [handle]
- mov cx, [bytesToWrite]
- push ds
- lds dx, [buffer]
- }
-
- DOS3Call();
-
- __asm {
- pop ds
- jc _error
- les bx, [bytesActuallyWritten]
- mov es:[bx], ax
- xor ax, ax
- }
-
- _error:
-
- _asm {
- mov theError, ax
- };
-
- return (theError);
- }
- #endif
-
- //----------------------------------------------------------------------------------------
- // FW_CFileRep::PrivDoRead
- //----------------------------------------------------------------------------------------
- void FW_CFileRep::PrivDoRead(void* destination, long count)
- {
- FW_CFileSystem::FileError theError = FW_CFileSystem::kNoError;
-
- FW_ASSERT (count >= 0);
-
- #ifdef FW_BUILD_WIN16
- long toRead = count;
- while(toRead > 0)
- {
- short readNow = PrivWinGetIOBufferSize(toRead, destination);
- short actualRead;
- theError = PrivWinPrimitiveRead(fFileHandle, readNow, destination, actualRead);
-
- if(theError != 0)
- break;
-
- toRead -= actualRead;
-
- if(actualRead < readNow)
- break;
-
- destination = ((char __huge*) destination) + toRead;
- }
-
- if (toRead != 0)
- theError = FW_CFileSystem::kEndOfFileReached;
- #endif
-
- #ifdef FW_BUILD_WIN32
- DWORD actualRead;
- if(!::ReadFile(fFileHandle, destination, count, &actualRead, NULL))
- theError = ::GetLastError();
- #endif
-
- #ifdef FW_BUILD_MAC
- theError = ::FSRead(fFileHandle, &count, destination);
- #endif
-
- FW_FailOnError(theError);
- }
-
-
- //----------------------------------------------------------------------------------------
- // FW_CFileRep::PrivDoWrite
- //----------------------------------------------------------------------------------------
- void FW_CFileRep::PrivDoWrite(const void* source, long count)
- {
- FW_CFileSystem::FileError theError = FW_CFileSystem::kNoError;
-
- FW_ASSERT (count > 0);
-
- #ifdef FW_BUILD_WIN16
- long toWrite = count;
- while(toWrite > 0)
- {
- short writeNow = PrivWinGetIOBufferSize(toWrite, source);
- short actualWritten;
- theError = PrivWinPrimitiveWrite(fFileHandle, writeNow, source, actualWritten);
-
- if(theError != 0)
- break;
-
- toWrite -= actualWritten;
-
- if(actualWritten < writeNow)
- break;
-
- source = ((const char __huge*) source) + toWrite;
- }
-
- if (toWrite != 0)
- theError = FW_CFileSystem::kDiskFull;
- #endif
-
- #ifdef FW_BUILD_WIN32
- DWORD actualWrite;
- if(!::WriteFile(fFileHandle, source, count, &actualWrite, NULL))
- theError = ::GetLastError();
- #endif
-
- #ifdef FW_BUILD_MAC
- theError = ::FSWrite(fFileHandle, &count, source);
- #endif
-
- FW_FailOnError(theError);
- }
-
-
- //----------------------------------------------------------------------------------------
- // FW_CFileRep::GetFileHandle
- //----------------------------------------------------------------------------------------
- FW_FileAccessHandle FW_CFileRep::GetFileHandle() const
- {
- return fFileHandle;
- }
-
-
- #ifdef FW_BUILD_WIN
- //----------------------------------------------------------------------------------------
- // FW_CFileRep::PrivWinMoveFilePointer
- //----------------------------------------------------------------------------------------
- FW_CFileSystem::FileError FW_CFileRep::PrivWinMoveFilePointer(long markOffset,
- FW_CFileSystem::MoveMethods positioningMode,
- long& newPosition) const
- {
- FW_CFileSystem::FileError theError = FW_CFileSystem::kNoError;
-
- #ifdef FW_BUILD_WIN16
- FW_FileAccessHandle handle = fFileHandle;
-
- __asm {
- mov ax, [positioningMode]
- mov ah, 42h
- mov bx, [handle]
- mov dx, word ptr [markOffset]
- mov cx, word ptr [markOffset+2]
- }
-
- DOS3Call();
-
- __asm {
- jc _error
- les bx, [newPosition]
- mov word ptr es:[bx], ax
- mov word ptr es:[bx+2], dx
- xor ax, ax
- }
-
- _error:
-
- __asm {
- mov theError, ax
- }
- #endif
-
- #ifdef FW_BUILD_WIN32
- newPosition = ::SetFilePointer(fFileHandle, markOffset, NULL, positioningMode);
- if (newPosition == FW_kInvalidSeek)
- theError = ::GetLastError();
- #endif
-
- return theError;
- }
- #endif
-
-
- //----------------------------------------------------------------------------------------
- // FW_CFileRep::FlushAndInvalidateBuffer
- //
- // If the buffer is "dirty", it needs to be written to disk. First, we'll get
- // all the information of the fileBuffer object, invalidate the object, and
- // then write the data to the disk. We must invalidate the fileBuffer object
- // before calling Write() as it calls FlushAndInvalidateBuffer().
- //----------------------------------------------------------------------------------------
- void FW_CFileRep::FlushAndInvalidateBuffer()
- {
- long currentPosition;
- long bufferInitialPosition;
- void * bufferAddress;
- long bytesWritten;
- FW_Boolean dirtyBuffer = fFileBuffer.IsDirty();
-
- // If the buffer is dirty, get buffer info prior to invalidating buffer
- if (dirtyBuffer)
- {
- currentPosition = GetPosition();
- bufferInitialPosition = fFileBuffer.GetInitialPosition();
- bufferAddress = fFileBuffer.GetAddress();
- bytesWritten = fFileBuffer.GetBytesWritten();
- }
-
- // Then invalidate the buffer (whether it's dirty or not)
- fFileBuffer.Invalidate();
-
- // Now write the dirty buffer. Note that Write() calls FlushAndInvalidateBuffer().
- if (dirtyBuffer)
- {
- SetPosition(FW_CFileSystem::kFromStart, bufferInitialPosition);
- PrivDoWrite(bufferAddress, bytesWritten);
- SetPosition(FW_CFileSystem::kFromStart, currentPosition);
- }
- }
-
-
-