本文整理汇总了C++中IsOpen函数的典型用法代码示例。如果您正苦于以下问题:C++ IsOpen函数的具体用法?C++ IsOpen怎么用?C++ IsOpen使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了IsOpen函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: open
void
MTfile::Create (const char *filename)
{
if (IsOpen()) {
return;
}
fileHandle = open (filename, O_RDWR|O_BINARY);
if (fileHandle >= 0) {
close (fileHandle);
return;
}
fileHandle = open (filename, O_BINARY|O_RDWR|O_CREAT|O_TRUNC, S_IREAD|S_IWRITE);
if (fileHandle < 0) {
return;
}
SetOpen (1);
/* Reserve page 0 */
char *page = new char[PageSize()];
memset (page, 0, PageSize());
memcpy (page, magic, sizeof(magic));
write (fileHandle, page, PageSize());
delete []page;
}
示例2: _ASSERTE
BOOL CSqlite3Recordset::GetField(short iIndex, CString& Data)
{
_ASSERTE(IsOpen());
_ASSERTE(iIndex>=0 && iIndex<m_nCols);
if( IsEOF() ) return FALSE;
if( iIndex < 0 || iIndex >= m_nCols ) return FALSE;
if( m_lType == DB_OPEN_TYPE_FORWARD_ONLY ) {
#if !defined(UNICODE)
Data = (char*) ::sqlite3_column_text(m_pVm, iIndex);
#else // UNICODE
Data = ::sqlite3_column_text16(m_pVm, iIndex);
#endif // UNICODE
}
else {
LPSTR pstr = m_ppSnapshot[ ((m_iPos + 1) * m_nCols) + iIndex ];
if( pstr == NULL ) {
Data = _T("");
}
else {
Data = pstr;
}
}
return TRUE;
}
示例3: USRLOG
bool Ctrl::SetFocus0(bool activate)
{
GuiLock __;
USRLOG(" SETFOCUS " << Desc(this));
LLOG("Ctrl::SetFocus " << Desc(this));
LLOG("focusCtrlWnd " << UPP::Name(focusCtrlWnd));
LLOG("Ctrl::SetFocus0 -> deferredSetFocus = NULL; was: " << UPP::Name(defferedSetFocus));
defferedSetFocus = NULL;
if(focusCtrl == this) return true;
if(!IsOpen() || !IsEnabled() || !IsVisible()) return false;
Ptr<Ctrl> pfocusCtrl = focusCtrl;
Ptr<Ctrl> topwindow = GetTopWindow();
Ptr<Ctrl> topctrl = GetTopCtrl();
Ptr<Ctrl> _this = this;
if(!topwindow) topwindow = topctrl;
LLOG("SetFocus -> SetWndFocus: topwindow = " << UPP::Name(topwindow) << ", focusCtrlWnd = " << UPP::Name(focusCtrlWnd));
if(!topwindow->HasWndFocus() && !topwindow->SetWndFocus()) return false;// cxl 31.1.2004
#ifdef PLATFORM_OSX11 // ugly temporary hack - popups not behaving right in MacOS
// before 2012-9-2 was #ifdef GUI_X11, but that caused issues in most linux distros (cxl)
// as parent window of popup always manages focus/keyboard for popup in X11
if(activate) // Dolik/fudadmin 2011-5-1
topctrl->SetWndForeground();
#else
topwindow->SetWndForeground(); // cxl 2007-4-27
#endif
LLOG("SetFocus -> focusCtrl = this: " << FormatIntHex(this) << ", _this = " << FormatIntHex(~_this) << ", " << UPP::Name(_this));
focusCtrl = _this;
focusCtrlWnd = topwindow;
DoKillFocus(pfocusCtrl, _this);
LLOG("SetFocus 2");
DoDeactivate(pfocusCtrl, _this);
DoSetFocus(pfocusCtrl, _this, activate);
if(topwindow)
lastActiveWnd = topwindow;
return true;
}
示例4: SPFSException
void
SPFS::LoadFileAsString(LPCSTR spfsFileName,string& sResultStr)
{
if( !IsOpen() )
throw new SPFSException(_T("pack file isn't opened !"),SPFS_FILE_IS_NOT_OPENED);
DWORD offset = 0; // offset of file.
DWORD size = 0; // size of file.
DWORD written = 0; // size of written bytes.
// find file in pack file.
if( !FindFile(spfsFileName,offset,size) )
throw new SPFSException(_T("not found file in pack !"),SPFS_FILE_IS_NOT_OPENED);
char* lpBuff = (char*)malloc(size+1);
if( ReadFileData(offset,size,lpBuff,size,written) && written == size )
{
lpBuff[size] = 0x00;
sResultStr = lpBuff;
}
else
throw new SPFSException(_T("can't read file data !"),SPFS_FILE_CANT_READ);
free(lpBuff);
}
示例5: open
void
GiSTfile::Open(const char *filename)
{
char *page;
if (IsOpen())
return;
fileHandle = open(filename, O_RDWR | O_BINARY);
if (fileHandle < 0)
return;
// Verify that the magic words are there
page = new char[PageSize()];
read(fileHandle, page, PageSize());
if (memcmp(page, magic, sizeof(magic))) {
close(fileHandle);
delete page;
return;
}
delete page;
SetOpen(1);
}
示例6: logic_error
bool
File::Open(const String &sFilename, OpenType ot)
{
if (IsOpen())
{
// The file should be closed, before we
// try to open it again...
throw std::logic_error(Formatter::FormatAsAnsi("The file {0} is already open.", sFilename));
}
std::wstring open_mode;
switch (ot)
{
case OTReadOnly:
open_mode = _T("rb");
break;
case OTCreate:
open_mode = _T("wb");
break;
case OTAppend:
open_mode = _T("ab");
break;
}
file_ = _wfsopen(sFilename.c_str(), open_mode.c_str(), _SH_DENYNO);
if (file_ == nullptr)
{
return false;
}
name_ = sFilename;
return true;
}
示例7: LOGGER_WARNING
bool FileInputSource::Close(CFErrorRef *error)
{
if(!IsOpen()) {
LOGGER_WARNING("org.sbooth.AudioEngine.InputSource.File", "Close() called on an InputSource that hasn't been opened");
return true;
}
memset(&mFilestats, 0, sizeof(mFilestats));
if(nullptr != mFile) {
int result = fclose(mFile);
mFile = nullptr;
if(-1 == result) {
if(error)
*error = CFErrorCreate(kCFAllocatorDefault, kCFErrorDomainPOSIX, errno, nullptr);
return false;
}
}
mIsOpen = false;
return true;
}
示例8: ASSERT
void CNamedPipe::SetMode(BOOL bByteMode, BOOL bBlockingMode)
{
//Validate our parameters
ASSERT(IsOpen()); //Pipe must be open
DWORD dwMode;
if (bByteMode)
{
if (bBlockingMode)
dwMode = PIPE_READMODE_BYTE | PIPE_WAIT;
else
dwMode = PIPE_READMODE_BYTE | PIPE_NOWAIT;
}
else
{
if (bBlockingMode)
dwMode = PIPE_READMODE_MESSAGE | PIPE_WAIT;
else
dwMode = PIPE_READMODE_MESSAGE | PIPE_NOWAIT;
}
if (!::SetNamedPipeHandleState(m_hPipe, &dwMode, NULL, NULL))
ThrowNamedPipeException();
}
示例9: mxAssert
/* MX_OVERRIDDEN */ mx::Size mx::FileStream::PrintfV(
const Char * const sFormat, va_list pArguments)
{
mxAssert(IsOpen());
mxAssert(sFormat != NULL);
int iCharsWritten;
if ((iCharsWritten =
#ifndef MXCPP_UNICODE
::vfprintf
#else
::vfwprintf
#endif
(m_hFileDescriptor, sFormat, pArguments))
< 0)
{
// We cannot reach eof during write (check it).
mxAssert(!feof(m_hFileDescriptor));
// File I/O error other than EOF.
mxThrow(GenericIOException(ferror(m_hFileDescriptor)));
}
return iCharsWritten;
}
示例10: CoreAssert
int CoreIOWriter::WriteU32(uint32_t _data)
{
CoreAssert(this != NULL);
if (!IsOpen()) return 0;
#ifndef __GNUC__
MutexHolder mh(&m_ioMutex);
#endif
switch (m_endianness)
{
case CC_ENDIAN_LITTLE:
_data = CC_SwapBE32(_data);
break;
case CC_ENDIAN_BIG:
_data = CC_SwapLE32(_data);
break;
case CC_ENDIAN_NATIVE:
/* Do nothing */
break;
}
size_t ret = fwrite(&_data, sizeof(uint32_t), 1, m_fileOutputPointer);
return ret;
}
示例11: Read
////////////////////////////////////////////////////////////////////////////////
/// Lecture dans le fichier
///
/// Parametres :
/// \param buffer [out]buffer dans lequel a ete ecrit le contenu du fichier
/// \param count [in]nombre max d'octets a lire
///
/// \return taille du fichier ou -1 si probleme de lecture
////////////////////////////////////////////////////////////////////////////////
int CAdeReadOnlyBinaryFileWithCRC::Read(void* buffer, unsigned int count)
{
if (IsOpen() == false)
{
// fichier non ouvert
return -1;
}
if (m_currPos >= m_lengthWithoutCRC)
{
// fin de fichier
return 0;
}
// On limite eventuellement si ce qui reste a lire dans le fichier est inferieur a ce qui est demande
if (count > static_cast<unsigned int>(m_lengthWithoutCRC - m_currPos))
{
count = m_lengthWithoutCRC - m_currPos;
}
// On copie les donnees
memcpy(buffer, &m_fileContent[m_currPos], count);
// On "avance" dans le fichier
m_currPos += count;
// On renvoie le nombre d'octets effectivement lus
return count;
}
示例12: sizeof
GiSTpage
MTfile::Allocate()
{
GiSTpage page;
char *buf;
if(!IsOpen()) return (0);
// See if there's a deleted page
buf=new char[PageSize()];
Read(0, buf);
memcpy(&page, buf+sizeof(magic), sizeof(GiSTpage));
if(page) {
// Reclaim this page
Read(page, buf);
Write(0, buf);
}
else {
page=lseek(fileHandle, 0, SEEK_END)/PageSize();
memset(buf, 0, PageSize());
write(fileHandle, buf, PageSize());
}
delete buf;
return page;
}
示例13: ASSERT
ALERROR CDataFile::AddEntry (const CString &sData, int *retiEntry)
// AddEntry
//
// Does some stuff
{
ALERROR error;
int i, iEntry;
DWORD dwStartingBlock;
DWORD dwBlockCount;
ASSERT(IsOpen());
ASSERT(!m_fReadOnly);
// Look for a free entry
for (i = 0; i < m_iEntryTableCount; i++)
if (m_pEntryTable[i].dwBlock == FREE_ENTRY)
break;
// If we could not find a free entry, grow the entry table
if (i == m_iEntryTableCount)
{
if ((error = GrowEntryTable(&iEntry)))
goto Fail;
}
else
iEntry = i;
// Figure out how many blocks we need
dwBlockCount = (sData.GetLength() / m_iBlockSize) + 1;
// Allocate a block chain large enough to contain the entry
if ((error = AllocBlockChain(dwBlockCount, &dwStartingBlock)))
goto Fail;
// Write the block chain
if ((error = WriteBlockChain(dwStartingBlock, sData.GetPointer(), sData.GetLength())))
{
FreeBlockChain(dwStartingBlock, dwBlockCount);
goto Fail;
}
// Set the entry
m_pEntryTable[iEntry].dwBlock = dwStartingBlock;
m_pEntryTable[iEntry].dwBlockCount = dwBlockCount;
m_pEntryTable[iEntry].dwSize = (DWORD)sData.GetLength();
m_pEntryTable[iEntry].dwFlags = 0;
m_fEntryTableModified = TRUE;
// Flush
if ((error = Flush()))
goto Fail;
// Done
*retiEntry = iEntry;
return NOERROR;
Fail:
return error;
}
示例14: LOGGER_WARNING
bool OggSpeexDecoder::Open(CFErrorRef *error)
{
if(IsOpen()) {
LOGGER_WARNING("org.sbooth.AudioEngine.AudioDecoder.OggSpeex", "Open() called on an AudioDecoder that is already open");
return true;
}
// Ensure the input source is open
if(!mInputSource->IsOpen() && !mInputSource->Open(error))
return false;
// Initialize Ogg data struct
ogg_sync_init(&mOggSyncState);
// Get the ogg buffer for writing
char *data = ogg_sync_buffer(&mOggSyncState, READ_SIZE_BYTES);
// Read bitstream from input file
ssize_t bytesRead = GetInputSource()->Read(data, READ_SIZE_BYTES);
if(-1 == bytesRead) {
if(error) {
CFMutableDictionaryRef errorDictionary = CFDictionaryCreateMutable(kCFAllocatorDefault,
0,
&kCFTypeDictionaryKeyCallBacks,
&kCFTypeDictionaryValueCallBacks);
CFStringRef displayName = CreateDisplayNameForURL(mInputSource->GetURL());
CFStringRef errorString = CFStringCreateWithFormat(kCFAllocatorDefault,
NULL,
CFCopyLocalizedString(CFSTR("The file “%@” could not be read."), ""),
displayName);
CFDictionarySetValue(errorDictionary,
kCFErrorLocalizedDescriptionKey,
errorString);
CFDictionarySetValue(errorDictionary,
kCFErrorLocalizedFailureReasonKey,
CFCopyLocalizedString(CFSTR("Read error"), ""));
CFDictionarySetValue(errorDictionary,
kCFErrorLocalizedRecoverySuggestionKey,
CFCopyLocalizedString(CFSTR("Unable to read from the input file."), ""));
CFRelease(errorString), errorString = NULL;
CFRelease(displayName), displayName = NULL;
*error = CFErrorCreate(kCFAllocatorDefault,
AudioDecoderErrorDomain,
AudioDecoderInputOutputError,
errorDictionary);
CFRelease(errorDictionary), errorDictionary = NULL;
}
ogg_sync_destroy(&mOggSyncState);
return false;
}
// Tell the sync layer how many bytes were written to its internal buffer
int result = ogg_sync_wrote(&mOggSyncState, bytesRead);
if(-1 == result) {
if(error) {
CFMutableDictionaryRef errorDictionary = CFDictionaryCreateMutable(kCFAllocatorDefault,
0,
&kCFTypeDictionaryKeyCallBacks,
&kCFTypeDictionaryValueCallBacks);
CFStringRef displayName = CreateDisplayNameForURL(mInputSource->GetURL());
CFStringRef errorString = CFStringCreateWithFormat(kCFAllocatorDefault,
NULL,
CFCopyLocalizedString(CFSTR("The file “%@” does not appear to be an Ogg file."), ""),
displayName);
CFDictionarySetValue(errorDictionary,
kCFErrorLocalizedDescriptionKey,
errorString);
CFDictionarySetValue(errorDictionary,
kCFErrorLocalizedFailureReasonKey,
CFCopyLocalizedString(CFSTR("Not an Ogg file"), ""));
CFDictionarySetValue(errorDictionary,
kCFErrorLocalizedRecoverySuggestionKey,
CFCopyLocalizedString(CFSTR("The file's extension may not match the file's type."), ""));
CFRelease(errorString), errorString = NULL;
CFRelease(displayName), displayName = NULL;
*error = CFErrorCreate(kCFAllocatorDefault,
AudioDecoderErrorDomain,
AudioDecoderFileFormatNotRecognizedError,
errorDictionary);
CFRelease(errorDictionary), errorDictionary = NULL;
}
ogg_sync_destroy(&mOggSyncState);
return false;
}
//.........这里部分代码省略.........
示例15:
OggSpeexDecoder::~OggSpeexDecoder()
{
if(IsOpen())
Close();
}