Ejemplo n.º 1
0
VolumeList* MultiVolumeReader::read(const std::string& url)
    throw (tgt::FileException, std::bad_alloc)
{
    LINFO("Loading multi volume file " << url);
    VolumeURL urlOrigin(url);

    std::vector<VolumeURL> origins = listVolumes(url);
    if (origins.empty())
        throw tgt::FileException("No volumes listed in multi-volume file", url);

    VolumeList* volumeList = new VolumeList();

    std::string refFile = urlOrigin.getSearchParameter("file");
    if (refFile == "") {
        // no particular file specified in URL => load all listed ones
        for (size_t i=0; i<origins.size(); i++) {
            VolumeBase* handle = read(origins.at(i));
            if (handle)
                volumeList->add(handle);
        }
    }
    else {
        // load specified file
        for (size_t i=0; i<origins.size(); i++) {
            if (origins.at(i).getSearchParameter("file") == refFile) {
                VolumeBase* handle = read(origins.at(i));
                if (handle) {
                    volumeList->add(handle);
                    break;
                }
            }
        }

        if (volumeList->empty()) {
            delete volumeList;
            throw tgt::FileException("File '" + refFile + "' not listed in multi-volume file", urlOrigin.getPath());
        }
    }

    return volumeList;
}
Ejemplo n.º 2
0
bool AmigaOSFilesystemNode::getChildren(AbstractFSList &myList, ListMode mode, bool hidden) const {
	ENTER();
	bool ret = false;

	// TODO: Honor the hidden flag
	// There is no such thing as a hidden flag in AmigaOS...

	if (!_bIsValid) {
		debug(6, "Invalid node");
		LEAVE();
		return false; // Empty list
	}

	if (!_bIsDirectory) {
		debug(6, "Not a directory");
		LEAVE();
		return false; // Empty list
	}

	if (isRootNode()) {
		debug(6, "Root node");
		LEAVE();
		myList = listVolumes();
		return true;
	}

	APTR context = IDOS->ObtainDirContextTags(  EX_FileLockInput,	_pFileLock,
												EX_DoCurrentDir,	TRUE,  /* for softlinks */
												EX_DataFields,		(EXF_NAME|EXF_LINK|EXF_TYPE),
												TAG_END);
	if (context) {
		struct ExamineData * pExd = NULL; // NB: No need to free the value after usage, everything will be dealt with by the DirContext release

		AmigaOSFilesystemNode *entry ;
		while ( (pExd = IDOS->ExamineDir(context)) ) {
			if (     (EXD_IS_FILE(pExd) && ( Common::FSNode::kListFilesOnly == mode ))
				||  (EXD_IS_DIRECTORY(pExd) && ( Common::FSNode::kListDirectoriesOnly == mode ))
				||  Common::FSNode::kListAll == mode
				)
			{
				BPTR pLock = IDOS->Lock( pExd->Name, SHARED_LOCK );
				if (pLock) {
					entry = new AmigaOSFilesystemNode( pLock, pExd->Name );
					if (entry) {
						myList.push_back(entry);
					}

					IDOS->UnLock(pLock);
				}
			}
		}

		if (ERROR_NO_MORE_ENTRIES != IDOS->IoErr() ) {
			debug(6, "An error occurred during ExamineDir");
			ret = false;
		} else {
			ret = true;
		}


		IDOS->ReleaseDirContext(context);
	} else {
		debug(6, "Unable to ObtainDirContext");
		ret = false;
	}

	LEAVE();

	return ret;
}