void Ps2SaveFileManager::checkMainDirectory(void) { // verify that the main directory (scummvm config + icon) exists int ret, fd; _mcNeedsUpdate = true; ret = _mc->getDir("/ScummVM/*", 0, MAX_MC_ENTRIES, _mcDirList); printf("/ScummVM/* res = %d\n", ret); if (ret <= 0) { // assume directory doesn't exist printf("Dir doesn't exist\n"); ret = _mc->mkDir("/ScummVM"); if (ret >= 0) { fd = _mc->open("/ScummVM/scummvm.icn", O_WRONLY | O_CREAT); if (fd >= 0) { uint16 icoSize; uint16 *icoBuf = decompressIconData(&icoSize); ret = _mc->write(fd, icoBuf, icoSize * 2); _mc->close(fd); free(icoBuf); printf(".icn written\n"); setupIcon("/ScummVM/icon.sys", "scummvm.icn", "ScummVM", "Configuration"); } else printf("Can't create icon file: %d\n", fd); } else printf("can't create scummvm directory: %d\n", ret); } }
bool QIcnsIconEnginePrivate::loadIcnsData(QIODevice *dev, QIcon::Mode mode, QIcon::State state) { QByteArray id, data; qint32 length; QDataStream ds(dev); ds.setByteOrder(QDataStream::BigEndian); id = dev->read(4); if (!id.startsWith("icns")) return false; ds >> length; if (dev->isSequential() && length != dev->size()) return false; while (! dev->atEnd()) { int npixels = 0; id = dev->read(4); ds >> length; data = dev->read(length - 8); if (id == "ic09") /* 512x512 JPEG2000 */ npixels = 512; else if (id == "ic08") /* 256x256 JPEG2000 */ npixels = 256; else if (id == "it32") /* 128x128 24-bit RGB */ npixels = 128; else if (id == "ih32") /* 48x48 24-bit RGB */ npixels = 48; else if (id == "il32") /* 32x32 24-bit RGB */ npixels = 32; else if (id == "is32") /* 16x16 24-bit RGB */ npixels = 16; else continue; /* * JPEG2000-based icons. */ if (npixels > 128) { QList<QByteArray> formats = QImageReader::supportedImageFormats(); if (!formats.contains(QByteArray("jp2"))) continue; } else { /* * Apparently, the 128x128 image can have 4 extra bytes prepended * to them. GDK-pixbuf does this, too. */ if (npixels == 128) { if (data.startsWith("\0\0\0\0")) { data.remove(0, 4); } } QByteArray rgb = decompressIconData(data, npixels); /* * Determine if there is an alpha channel for this image in * the stream. */ id = dev->peek(4); if (id == "t8mk" || id == "h8mk" || id == "l8mk" || id == "s8mk") { id = dev->read(4); ds >> length; data = dev->read(length - 8); int length = data.length(); if (length != npixels*npixels) { qWarning("QIcnsIconEnginePrivate::loadIcnsData: mask" " size mismatch"); continue; } for (int i = 0; i < length; i++) rgb[i*4 + 3] = data[i]; } imageBuffers.insert(hashKey(mode, state, QSize(npixels, npixels)), rgb); iconSizes.insert(hashKey(mode, state), QSize(npixels, npixels)); } }