Пример #1
0
static void setInputFileParametersCommon (inputFileInfo *finfo, vString *const fileName,
					  const langType language,
					  stringList *holder)
{
	if (finfo->name != NULL)
		vStringDelete (finfo->name);
	finfo->name = fileName;

	if (finfo->tagPath != NULL)
	{
		if (holder)
			stringListAdd (holder, finfo->tagPath);
		else
			vStringDelete (finfo->tagPath);
	}

	if (0)
		;
	else if (  Option.tagRelative == TREL_ALWAYS )
		finfo->tagPath =
			vStringNewOwn (relativeFilename (vStringValue (fileName),
							 getTagFileDirectory ()));
	else if ( Option.tagRelative == TREL_NEVER )
		finfo->tagPath =
			vStringNewOwn (absoluteFilename (vStringValue (fileName)));
	else if ( Option.tagRelative == TREL_NO || isAbsolutePath (vStringValue (fileName)) )
		finfo->tagPath = vStringNewCopy (fileName);
	else
		finfo->tagPath =
			vStringNewOwn (relativeFilename (vStringValue (fileName),
							 getTagFileDirectory ()));

	finfo->isHeader = isIncludeFile (vStringValue (fileName));
}
Пример #2
0
QPair<QList<QNetworkRequest>, QStringList> Cache::createRequests(const QList<QUrl> &in,
																 bool refreshAll)
{
	QList<QUrl> urlsIn = in;
	QList<QNetworkRequest> requests;
	{
		QList<QUrl> urls = refreshAll ? in : getStaleUrls(in);
		requests.reserve(urls.size());
		for (const auto url : urls) {
			urlsIn.removeAll(url);
			QNetworkRequest request(url);
			const auto entryIt = findEntry(url);
			if (entryIt != m_entries.end()) {
				const auto entry = *entryIt;
				// TODO add the md5 as a header
			}
			requests.append(request);
		}
	}
	QStringList localfiles;
	{
		// loop through all urls that didn't get made into network requests
		for (const auto url : urlsIn) {
			localfiles.append(absoluteFilename(*findEntry(url)));
		}
	}
	return qMakePair(requests, localfiles);
}
Пример #3
0
void Cache::cleanCache(const QList<QUrl> &in)
{
	// purge entries that don't exist in 'in'
	{
		QList<Entry> entriesToRemove;
		for (const auto entry : m_entries) {
			if (!in.contains(entry.url)) {
				// this entry doesn't exist anymore, so remove it
				entriesToRemove += entry;
			}
		}
		for (auto entry : entriesToRemove) {
			removeEntry(entry);
		}
	}
	// remove directories, as that's not something we put there
	for (const QFileInfo &info : m_dir.entryInfoList(QDir::Dirs | QDir::NoDotAndDotDot)) {
		FS::remove(info);
	}
	// remove files that we don't know anything of
	for (const QFileInfo &info : m_dir.entryInfoList(QStringList() << "*.cache", QDir::Files)) {
		if (info.fileName() == ".cache.json") {
			continue;
		}
		bool found = false;
		for (const auto entry : m_entries) {
			if (absoluteFilename(entry) == info.absoluteFilePath()) {
				found = true;
				break;
			}
		}
		// it doesn't exist in the cache metadata, so we remove it
		if (!found) {
			FS::remove(info);
		}
	}
	// remove cache entries where the file isn't existing anymore
	{
		QMutableListIterator<Entry> it(m_entries);
		while (it.hasNext()) {
			if (!QFileInfo(absoluteFilename(it.next())).exists()) {
				it.remove();
			}
		}
	}
	writeCacheFile();
}
Пример #4
0
void Cache::addEntry(const QUrl &url, const QByteArray &data)
{
	Entry entry = getEntry(url);
	entry.md5 = QCryptographicHash::hash(data, QCryptographicHash::Md5);
	entry.updated = QDateTime::currentDateTime();

	FS::write(absoluteFilename(entry), data);

	setEntry(entry);
}
Пример #5
0
QString Cache::addEntry(QNetworkReply *reply)
{
	QUrl url = reply->request().url();
	if (url.scheme() == "file" && url.host().isEmpty()) {
		url.setHost("localhost");
	}
	// don't write to disk if the reply is empty because it's not modified
	addEntry(url, reply->readAll());

	const auto entryIt = findEntry(url);
	Q_ASSERT(entryIt != m_entries.end());
	return absoluteFilename(*entryIt);
}
Пример #6
0
PassRefPtr<AudioBus> AudioBus::loadPlatformResource(const char* name, float sampleRate)
{
    String absoluteFilename(makeString(DATA_DIR, "/webaudio/resources/", name, ".wav"));
    const WebKit::WebData& resource = WebKit::Platform::current()->loadResource(absoluteFilename.utf8().data());

    if (resource.isEmpty())
        return PassRefPtr<AudioBus>();

    // FIXME: the sampleRate parameter is ignored. It should be removed from the API.
    RefPtr<AudioBus> audioBus = decodeAudioFileData(resource.data(), resource.size(), sampleRate);

    if (!audioBus.get())
        return PassRefPtr<AudioBus>();

    // If the bus is already at the requested sample-rate then return as is.
    if (audioBus->sampleRate() == sampleRate)
        return audioBus.release();

    return AudioBus::createBySampleRateConverting(audioBus.get(), false, sampleRate);
}
Пример #7
0
extern boolean isRecursiveLink (const char* const dirName)
{
	boolean result = FALSE;
	fileStatus *status = eStat (dirName);
	if (status->isSymbolicLink)
	{
		char* const path = absoluteFilename (dirName);
		while (path [strlen (path) - 1] == PATH_SEPARATOR)
			path [strlen (path) - 1] = '\0';
		while (! result  &&  strlen (path) > (size_t) 1)
		{
			char *const separator = strrchr (path, PATH_SEPARATOR);
			if (separator == NULL)
				break;
			else if (separator == path)  /* backed up to root directory */
				*(separator + 1) = '\0';
			else
				*separator = '\0';
			result = isSameFile (path, dirName);
		}
		eFree (path);
	}
	return result;
}
Пример #8
0
void Cache::removeEntry(const Entry &entry)
{
	FS::remove(absoluteFilename(entry));
	m_entries.removeAll(entry);
}