Exemple #1
0
    QString preferredProfileDir(QSettings *settings)
    {
        QString lastProfileDir = settings->value("LastProfileDir", "").toString();
        QString defaultProfileDir = settings->value("DefaultProfileDir", "").toString();
        QString lookupDir;

        if (!defaultProfileDir.isEmpty())
        {
            QFileInfo dirinfo(defaultProfileDir);
            if (dirinfo.isDir() && dirinfo.isReadable())
            {
                lookupDir = defaultProfileDir;
            }
        }

        if (lookupDir.isEmpty() && !lastProfileDir.isEmpty())
        {
            QFileInfo dirinfo(lastProfileDir);
            if (dirinfo.isDir() && dirinfo.isReadable())
            {
                lookupDir = lastProfileDir;
            }
        }

        if (lookupDir.isEmpty())
        {
            lookupDir = QDir::homePath();
        }

        return lookupDir;
    }
Exemple #2
0
void CAht::Reset( void )
{
    char p[512];
    
    DisposeModel();
    
    dirinfo( p, 0x10005 );
    SetPrjDir( p );						// マイドキュメントを設定
    dirinfo( p, 1 );
    SetToolDir( p );					// 自分のディレクトリ
    SetPrjFile( "ahttmp" );
    SetPage( 0, 0 );
}
Exemple #3
0
    QString preferredProfileDir(AntiMicroSettings *settings)
    {
        QString lastProfileDir = settings->value("LastProfileDir", "").toString();
        QString defaultProfileDir = settings->value("DefaultProfileDir", "").toString();
        QString lookupDir;

        if (!defaultProfileDir.isEmpty())
        {
            QFileInfo dirinfo(defaultProfileDir);
            if (dirinfo.isDir() && dirinfo.isReadable())
            {
                lookupDir = defaultProfileDir;
            }
        }

        if (lookupDir.isEmpty() && !lastProfileDir.isEmpty())
        {
            QFileInfo dirinfo(lastProfileDir);
            if (dirinfo.isDir() && dirinfo.isReadable())
            {
                lookupDir = lastProfileDir;
            }
        }

        if (lookupDir.isEmpty())
        {
#ifdef Q_OS_WIN
    #ifdef WIN_PORTABLE_PACKAGE
            QString portableProDir = QDir::currentPath().append("/profiles");
            QFileInfo portableProDirInfo(portableProDir);
            if (portableProDirInfo.isDir() && portableProDirInfo.isReadable())
            {
                lookupDir = portableProDir;
            }
            else
            {
                lookupDir =  QStandardPaths::writableLocation(QStandardPaths::DocumentsLocation);
            }
    #else
            lookupDir =  QStandardPaths::writableLocation(QStandardPaths::DocumentsLocation);
    #endif
#else
            lookupDir = QDir::homePath();
#endif
        }

        return lookupDir;
    }
Exemple #4
0
void TokenBuilder::buildIncludeFinish()
{
	if(filename.isEmpty())
		return;

	QDir currentpath = path_stack.top();
	if(filepath.isEmpty()) {
		path_stack.push(currentpath);
	} else {
		QFileInfo dirinfo(currentpath,filepath);
		path_stack.push(dirinfo.dir());
		filepath.clear();
	}

	currentpath = path_stack.top();
	QFileInfo fileinfo(currentpath,filename);

	if(!fileinfo.exists())
		path_stack.pop();

	filename.clear();

	const char* fullpath = fileinfo.absoluteFilePath().toLocal8Bit();
	lexerinclude(fullpath);

}
Exemple #5
0
/**
 * validate()
 * Reads the file's headers and ensures it is a legitimate hpi file
 * also sets decryption key if present
 * @param n path to target hpi
 */
void hpiutil::hpifile::validate(const char *n)
{
	valid = false;
	header_hapimagic = file->readint();
	if (header_hapimagic != HAPI_MAGIC) {
		std::cerr << "File " << n << ": Invalid HAPI signature: 0x" << std::hex << header_hapimagic << std::endl;
		return;
	}
	header_bankmagic = file->readint();
	if (header_bankmagic != HAPI_VERSION_MAGIC) {
		if (header_bankmagic == BANK_MAGIC)
			std::cerr << "File " << n << ": Bank subtype signature looks like a saved game: 0x" << std::hex << header_bankmagic << std::endl;
		else if (header_bankmagic == HAPI2_VERSION_MAGIC)
			std::cerr << "File " << n << ": HAPIv2 files not supported yet" << std::endl;
		else
			std::cerr << "File " << n << ": Invalid bank subtype signature: 0x" << std::hex << header_bankmagic << std::endl;
		return;
	}
	header_offset = file->readint();
	header_key = file->readint();
	header_diroffset = file->readint();
	file->setkey(header_key);
	valid = true;
	flatlist.push_back(dirinfo("","",header_diroffset)); // <- result of dirinfo gets added twice?
}
Exemple #6
0
/**
 * dirinfo()
 * creates an hpientry object representing a given directory
 * @return hpientry object for the directory
 * @param parentname name of this object's parent (if applicable)
 * @param dirname name of this directory
 * @param offset offset in hpi file
 */
hpiutil::hpientry_ptr hpiutil::hpifile::dirinfo(std::string const &parentname, std::string const &dirname, const boost::uint32_t offset)
{
	std::vector<hpientry_ptr> listing;
	std::string newparent;
	if (parentname=="")
		newparent = dirname;
	else
		newparent = parentname+PATHSEPARATOR+dirname;
	file->seek(offset);
	boost::uint32_t entries = file->readint();
	file->readint(); // unknown dword
	for (boost::uint32_t i = 0; i < entries; i++) {
		boost::uint32_t nameoffset = file->readint();
		boost::uint32_t infooffset = file->readint();
		boost::uint8_t entrytype = file->read();
		boost::uint32_t currentpos = file->file.tellg();
		file->seek(nameoffset);
		std::string itemname = file->readstring();
		file->seek(infooffset);
		switch (entrytype) {
			case 0:
				listing.push_back( fileinfo(newparent,itemname,infooffset));
				break;
			case 1:
				listing.push_back( dirinfo(newparent,itemname,infooffset));
				break;
			default:
				throw std::runtime_error("Unknown entry type");
				break;
		}
		file->seek(currentpos);
	}
	flatlist.push_back( hpientry_ptr(new hpientry(*this,parentname,dirname,(boost::uint32_t)0,(boost::uint32_t)0)));
	flatlist.back()->directory = true;
	flatlist.back()->subdir = listing;
	return flatlist.back();
}