コード例 #1
0
void *
MMTT_SharedMem::getMemory()
{
	if (!checkInfo())
	{
		return NULL;
	}

    if( myMemory == 0 )
    {
		if ((myAmOwner && createSharedMem()) || (!myAmOwner && openSharedMem()))
		{
#ifdef WIN32 
		    myMemory = MapViewOfFile(myMapping, FILE_MAP_ALL_ACCESS, 0, 0, 0);
#else
		    assert(false);
		    myMemory = NULL;
#endif 
		    if (!myMemory)
				myErrorState = MMTT_SHM_ERR_UNABLE_TO_MAP;
		}
    }
    if (myMemory)
    {
		myErrorState = MMTT_SHM_ERR_NONE;
    }
    return myMemory;
}
コード例 #2
0
shared_ptr<Book> BooksDBUtil::getBook(const std::string &filePath, bool checkFile) {
	const std::string physicalFilePath = ZLFile(filePath).physicalFilePath();

	ZLFile file(physicalFilePath);
	if (checkFile && !file.exists()) {
		return 0;
	}

	if (!checkFile || checkInfo(file)) {
		shared_ptr<Book> book = loadFromDB(filePath);
		if (!book.isNull() && isBookFull(*book)) {
			return book;
		}
	} else {
		if (physicalFilePath != filePath) {
			resetZipInfo(file);
		}
		saveInfo(file);
	}

	shared_ptr<Book> book = Book::loadFromFile(filePath);
	if (book.isNull()) {
		return 0;
	}
	BooksDB::Instance().saveBook(book);
	return book;
}
コード例 #3
0
bool BooksDBUtil::getBooks(std::map<std::string, shared_ptr<Book> > &booksmap, bool checkFile) {
	BookList books;
	if (!BooksDB::Instance().loadBooks(books)) {
		return false;
	}
	for (BookList::iterator it = books.begin(); it != books.end(); ++it) {
		Book &book = **it;
		const std::string &filePath = book.filePath();
		const std::string physicalFilePath = ZLFile(filePath).physicalFilePath();
		ZLFile file(physicalFilePath);
		if (!checkFile || file.exists()) {
			if (!checkFile || checkInfo(file)) {
				if (isBookFull(book)) {
					booksmap.insert(std::make_pair(filePath, *it));
					continue;
				}
			} else {
				if (physicalFilePath != filePath) {
					resetZipInfo(file);
				}
				saveInfo(file);
			}
			shared_ptr<Book> bookptr = Book::loadFromFile(filePath);
			if (!bookptr.isNull()) {
				BooksDB::Instance().saveBook(bookptr);
				booksmap.insert(std::make_pair(filePath, bookptr));
			}
		}
	}
	return true;
}
コード例 #4
0
ファイル: filter.c プロジェクト: piratla/tomahawk
static void filter_bitmap(JNIEnv* env, jobject obj, jobject bitmap,
    float intensity, Filter t)
{
    AndroidBitmapInfo info;
    int ret = checkInfo(env, bitmap, &info);

    if (ret < 0) {
        return;
    }

    void* pixels;

    if ((ret = AndroidBitmap_lockPixels(env, bitmap, &pixels)) < 0) {
        LOGE("AndroidBitmap_lockPixels() failed ! error=%d", ret);
    }

    do_filter(&info, pixels, intensity, t);

    AndroidBitmap_unlockPixels(env, bitmap);
}