示例#1
0
bool CMMapFile::open(const char *szFileName, int flag, size_t length)
{
	m_szFileName = strdup(szFileName);
	if (length > 0) {
		return create(szFileName, length);
	} else if ((flag & FILE_OPEN_WRITE)) {
		return openInternal(szFileName, false);
	} else {
		return openInternal(szFileName, true);
	}
}
示例#2
0
std::pair<Float, Float> MagnumFont::doOpenFile(const std::string& filename, Float) {
    /* Open the configuration file */
    Utility::Configuration conf(filename, Utility::Configuration::Flag::ReadOnly|Utility::Configuration::Flag::SkipComments);
    if(!conf.isValid() || conf.isEmpty()) {
        Error() << "Text::MagnumFont::openFile(): cannot open file" << filename << conf.isValid();
        return {};
    }

    /* Check version */
    if(conf.value<UnsignedInt>("version") != 1) {
        Error() << "Text::MagnumFont::openFile(): unsupported file version, expected 1 but got"
                << conf.value<UnsignedInt>("version");
        return {};
    }

    /* Open and load image file */
    const std::string imageFilename = Utility::Directory::join(Utility::Directory::path(filename), conf.value("image"));
    Trade::TgaImporter importer;
    if(!importer.openFile(imageFilename)) {
        Error() << "Text::MagnumFont::openFile(): cannot open image file" << imageFilename;
        return {};
    }
    std::optional<Trade::ImageData2D> image = importer.image2D(0);
    if(!image) {
        Error() << "Text::MagnumFont::openFile(): cannot load image file";
        return {};
    }

    return openInternal(std::move(conf), std::move(*image));
}
void IDBDatabaseBackendImpl::openConnectionWithVersion(PassRefPtr<IDBCallbacks> prpCallbacks, PassRefPtr<IDBDatabaseCallbacks> prpDatabaseCallbacks, int64_t version)
{
    RefPtr<IDBCallbacks> callbacks = prpCallbacks;
    RefPtr<IDBDatabaseCallbacks> databaseCallbacks = prpDatabaseCallbacks;
    if (!m_pendingDeleteCalls.isEmpty() || m_runningVersionChangeTransaction) {
        m_pendingOpenWithVersionCalls.append(PendingOpenWithVersionCall::create(callbacks, databaseCallbacks, version));
        return;
    }
    if (m_metadata.id == InvalidId) {
        if (openInternal())
            ASSERT(m_metadata.intVersion == IDBDatabaseMetadata::NoIntVersion);
        else {
            callbacks->onError(IDBDatabaseError::create(IDBDatabaseException::UNKNOWN_ERR, "Internal error."));
            return;
        }
    }
    if (version > m_metadata.intVersion) {
        runIntVersionChangeTransaction(version, callbacks, databaseCallbacks);
        return;
    }
    if (version < m_metadata.intVersion) {
        callbacks->onError(IDBDatabaseError::create(IDBDatabaseException::VER_ERR, String::format("The requested version (%lld) is less than the existing version (%lld).", static_cast<long long>(version), static_cast<long long>(m_metadata.intVersion))));
        return;
    }
    ASSERT(version == m_metadata.intVersion);
    m_databaseCallbacksSet.add(databaseCallbacks);
    callbacks->onSuccess(this);
}
示例#4
0
IDBOpenDBRequest* IDBFactory::open(ScriptState* scriptState,
                                   const String& name,
                                   ExceptionState& exceptionState) {
  IDB_TRACE("IDBFactory::open");
  return openInternal(scriptState, name, IDBDatabaseMetadata::NoVersion,
                      exceptionState);
}
示例#5
0
bool NamedPipe::createNewPipe (const String& pipeName)
{
    close();

    ScopedWriteLock sl (lock);
    currentPipeName = pipeName;
    return openInternal (pipeName, true);
}
示例#6
0
bool NamedPipe::openExisting (const String& pipeName)
{
    close();

    ScopedWriteLock sl (lock);
    currentPipeName = pipeName;
    return openInternal (pipeName, false);
}
示例#7
0
PassRefPtr<IDBOpenDBRequest> IDBFactory::open(ScriptExecutionContext* context, const String& name, unsigned long long version, ExceptionCode& ec)
{
    LOG(StorageAPI, "IDBFactory::open");
    if (!version) {
        ec = TypeError;
        return 0;
    }
    return openInternal(context, name, version, IndexedDB::VersionNullness::NonNull, ec);
}
IDBOpenDBRequest* IDBFactory::open(ScriptState* scriptState, const String& name, unsigned long long version, ExceptionState& exceptionState)
{
    IDB_TRACE("IDBFactory::open");
    if (!version) {
        exceptionState.throwTypeError("The version provided must not be 0.");
        return nullptr;
    }
    return openInternal(scriptState, name, version, exceptionState);
}
示例#9
0
RefPtr<WebCore::IDBOpenDBRequest> IDBFactory::open(ScriptExecutionContext* context, const String& name, unsigned long long version, ExceptionCode& ec)
{
    LOG(IndexedDB, "IDBFactory::open");
    
    if (!version) {
        ec = TypeError;
        return nullptr;
    }

    return openInternal(context, name, version, ec).release();
}
示例#10
0
bool AbstractDb::openForProbing()
{
    QWriteLocker locker(&dbOperLock);
    QWriteLocker connectionLocker(&connectionStateLock);
    bool res = openInternal();
    if (!res)
        return res;

    // Implementation specific initialization
    initAfterOpen();
    return res;
}
示例#11
0
bool TinselFile::open(const Common::String &filename) {
	if (openInternal(filename))
		return true;

	if (!TinselV2)
		return false;

	// Check if the file being requested is the *1.* or *2.* files
	const char *fname = filename.c_str();
	const char *p = strchr(fname, '1');
	if (!p)
		p = strchr(fname, '2');
	if (!p || (*(p + 1) != '.'))
		return false;

	// Form a filename without the CD number character
	char newFilename[50];
	strncpy(newFilename, fname, p - fname);
	strcpy(newFilename + (p - fname), p + 1);

	return openInternal(newFilename);
}
示例#12
0
void VlcQmlVideoPlayer::setUrl(const QUrl &url)
{
    if (_media)
        delete _media;

    if(url.isLocalFile()) {
        _media = new VlcMedia(url.toLocalFile(), true, _instance);
    } else {
        _media = new VlcMedia(url.toString(), false, _instance);
    }

    openInternal();
}
示例#13
0
std::pair<Float, Float> MagnumFont::doOpenData(const std::vector<std::pair<std::string, Containers::ArrayReference<const unsigned char>>>& data, const Float) {
    /* We need just the configuration file and image file */
    if(data.size() != 2) {
        Error() << "Text::MagnumFont::openData(): wanted two files, got" << data.size();
        return {};
    }

    /* Open the configuration file */
    std::istringstream in({reinterpret_cast<const char*>(data[0].second.begin()), data[0].second.size()});
    Utility::Configuration conf(in, Utility::Configuration::Flag::SkipComments);
    if(!conf.isValid() || conf.isEmpty()) {
        Error() << "Text::MagnumFont::openData(): cannot open file" << data[0].first;
        return {};
    }

    /* Check version */
    if(conf.value<UnsignedInt>("version") != 1) {
        Error() << "Text::MagnumFont::openData(): unsupported file version, expected 1 but got"
                << conf.value<UnsignedInt>("version");
        return {};
    }

    /* Check that we have also the image file */
    if(conf.value("image") != data[1].first) {
        Error() << "Text::MagnumFont::openData(): expected file"
                << conf.value("image") << "but got" << data[1].first;
        return {};
    }

    /* Open and load image file */
    Trade::TgaImporter importer;
    if(!importer.openData(data[1].second)) {
        Error() << "Text::MagnumFont::openData(): cannot open image file";
        return {};
    }
    std::optional<Trade::ImageData2D> image = importer.image2D(0);
    if(!image) {
        Error() << "Text::MagnumFont::openData(): cannot load image file";
        return {};
    }

    return openInternal(std::move(conf), std::move(*image));
}
void IDBDatabaseBackendImpl::openConnection(PassRefPtr<IDBCallbacks> callbacks, PassRefPtr<IDBDatabaseCallbacks> databaseCallbacks)
{
    ASSERT(m_backingStore.get());
    if (!m_pendingDeleteCalls.isEmpty() || m_runningVersionChangeTransaction) {
        m_pendingOpenCalls.append(PendingOpenCall::create(callbacks, databaseCallbacks));
        return;
    }
    if (m_metadata.id == InvalidId && !openInternal()) {
        callbacks->onError(IDBDatabaseError::create(IDBDatabaseException::UNKNOWN_ERR, "Internal error."));
        return;
    }
    if (m_metadata.version == NoStringVersion && m_metadata.intVersion == IDBDatabaseMetadata::NoIntVersion) {
        // Spec says: If no version is specified and no database exists, set
        // database version to 1. We infer that the database didn't exist from
        // its lack of either type of version.
        openConnectionWithVersion(callbacks, databaseCallbacks, 1);
        return;
    }
    m_databaseCallbacksSet.add(RefPtr<IDBDatabaseCallbacks>(databaseCallbacks));
    callbacks->onSuccess(this);
}
示例#15
0
bool AbstractDb::openAndSetup()
{
    bool result = openInternal();
    if (!result)
        return result;

    // When this is an internal configuration database
    if (connOptions.contains(DB_PURE_INIT))
        return true;

    // Implementation specific initialization
    initAfterOpen();

    // Custom SQL functions
    registerAllFunctions();

    // Custom collations
    registerAllCollations();

    return result;
}
示例#16
0
bool NamedPipe::openExisting (const String& pipeName)
{
    currentPipeName = pipeName;
    return openInternal (pipeName, false);
}
示例#17
0
bool NamedPipe::createNewPipe (const String& pipeName)
{
    currentPipeName = pipeName;
    return openInternal (pipeName, true);
}
示例#18
0
RefPtr<WebCore::IDBOpenDBRequest> IDBFactory::open(ScriptExecutionContext* context, const String& name, ExceptionCode& ec)
{
    LOG(IndexedDB, "IDBFactory::open");
    
    return openInternal(context, name, 0, ec).release();
}
示例#19
0
PassRefPtr<IDBOpenDBRequest> IDBFactory::open(ScriptExecutionContext* context, const String& name, ExceptionCode& ec)
{
    LOG(StorageAPI, "IDBFactory::open");
    return openInternal(context, name, 0, IndexedDB::VersionNullness::Null, ec);
}