Beispiel #1
0
AAFRESULT STDMETHODCALLTYPE
    ImplAAFRawStorage::Write
        (aafMemConstPtr_t  buf,
         aafUInt32  bufSize,
		 aafUInt32 * pNumWritten)
{
  if (! _rep)
	return AAFRESULT_NOT_INITIALIZED;

  if (! buf)
	return AAFRESULT_NULL_PARAM;

  if (! pNumWritten)
	return AAFRESULT_NULL_PARAM;

  aafBoolean_t writeable = kAAFFalse;
  AAFRESULT hr = IsWriteable (&writeable);
  if (AAFRESULT_FAILED (hr))
	return hr;
  if (! writeable)
	return AAFRESULT_NOT_WRITEABLE;

  _rep->write (buf, bufSize, *pNumWritten);

  if (*pNumWritten < bufSize)
	// Note!  This violates one tenet, that if a method fails, no
	// action is taken.  However, this failure notice is given *after*
	// some bytes have been written...
	return AAFRESULT_SMALLBUF;

  return AAFRESULT_SUCCESS;
}
Beispiel #2
0
bool HexDoc::CanReplaceAt(uint64 nIndex, uint64 nOldSize, uint64 nNewSize)
{
    if (!IsWriteable() && (nOldSize || nNewSize))
        return false; // not writeable
    if (!CanChangeSize() && nOldSize != nNewSize)
        return false; // can't change size
    if (nIndex + nOldSize > this->size)
        return false; // can't delete past EOF
    return true;
}
Beispiel #3
0
/* Put a line of text into file. */
void CTStream::PutLine_t(const char *strBuffer) // throws char *
{
  // check parameters
  ASSERT(strBuffer!=NULL);
  // check that the stream is writteable
  ASSERT(IsWriteable());
  // get string length
  INDEX iStringLength = strlen(strBuffer);
  // put line into stream
  Write_t(strBuffer, iStringLength);
  // write "\r\n" into stream
  Write_t("\r\n", 2);
}
Beispiel #4
0
BOOL CConDXSrv::Send(int fd,char *data,int data_len)
{
//	char sync4[]={(char)0xbf,(char)0x13,(char)0x97,(char)0x74};
	struct timeval timeout;

	timeout.tv_sec=5;
	timeout.tv_usec=0;

	if(!IsWriteable(fd,&timeout))
		return FALSE;
	if(write_all(fd,data,data_len)<data_len)
		return FALSE;
	return TRUE;
}
 RF_Type::Bool GenerateResource()
 {   
     RF_Type::Bool result = true;     
     auto res=RF_IO::Resource::FromUri(RF_IO::Uri("mem://1"_rfs));
     result &= res;
     if(res)
     {
         result &= res->Exists();
         result &= res->GetSize() == 0;
         result &= res->IsReadable() == false;
         result &= res->IsWriteable() == true;
         result &= res->GetStream() != 0;
     }
     return result;
 }
size_t CBufferedStreamWrap::Write( const void *buffer, size_t sElement, size_t iNumElements )
{
    // If we are not opened for writing rights, this operation should not do anything.
    if ( !IsWriteable() )
        return 0;

    WritingSliceSelectorManager sliceMan( *this );

    // Perform the complex buffered logic.
    SelectBufferedSlice(
        (const char*)buffer, this->bufOffset,
        this->fileSeek, sElement * iNumElements,
        sliceMan
    );

    return sliceMan.GetBytesWritten();
}
Beispiel #7
0
void CTStream::PutString_t(const char *strString) // throw char *
{
  // check parameters
  ASSERT(strString!=NULL);
  // check that the stream is writteable
  ASSERT(IsWriteable());
  // get string length
  INDEX iStringLength = strlen(strString);
  // put line into stream
  for( INDEX iLetter=0; iLetter<iStringLength; iLetter++)
  {
    if (*strString=='\n') {
      // write "\r\n" into stream
      Write_t("\r\n", 2);
      strString++;
    } else {
      Write_t(strString++, 1);
    }
  }
}