void Doom3FileSystem::initPakFile(ArchiveLoader& archiveModule, const std::string& filename)
{
    std::string fileExt(os::getExtension(filename));
    boost::to_lower(fileExt);

    if (_allowedExtensions.find(fileExt) != _allowedExtensions.end())
    {
        // Matched extension for archive (e.g. "pk3", "pk4")
        ArchiveDescriptor entry;

        entry.name = filename;
        entry.archive = archiveModule.openArchive(filename);
        entry.is_pakfile = true;
        _archives.push_back(entry);

        rMessage() << "[vfs] pak file: " << filename << std::endl;
    }
    else if (_allowedExtensionsDir.find(fileExt) != _allowedExtensionsDir.end())
    {
        // Matched extension for archive dir (e.g. "pk3dir", "pk4dir")
        ArchiveDescriptor entry;

        std::string path = os::standardPathWithSlash(filename);
        entry.name = path;
        entry.archive = DirectoryArchivePtr(new DirectoryArchive(path));
        entry.is_pakfile = false;
        _archives.push_back(entry);

        rMessage() << "[vfs] pak dir:  " << path << std::endl;
    }
}
void TestDbView::loadFromFolder()
{
    QString filePath = QFileDialog::getExistingDirectory(this, tr("Open Directory"));

    if (!filePath.isEmpty()) {

        filePath = filePath + "/";

        setTestFolderPath(filePath);
        m_chosenFolder->setText(filePath);
        m_testBox->clear();

        QDir chosenDir(testFolderPath());
        QStringList allFiles = chosenDir.entryList(QDir::Files | QDir::NoDotAndDotDot);

        for (int i = 0; i < allFiles.count(); i++) {

            QFileInfo fileExt(allFiles.at(i));
            QString ext = fileExt.suffix().toLower();

            if (ext == ".doc" || ext == ".docx" || SqlliteDbManager::checkIfTestDb(allFiles.at(i))) {

                if (!findDumlicateFile(m_testBox, allFiles.at(i))) {

                    QListWidgetItem *newItem = new QListWidgetItem();

                    newItem->setText(allFiles.at(i));
                    m_testBox->insertItem(m_testBox->count(), newItem);
                }
            }
        }
    }
}
void TestDbView::defaulTestBoxPath(QString folderPath)
{
    if (!folderPath.isEmpty()) {

        if (folderPath.at(folderPath.count() - 1) != '/')
            folderPath = folderPath + slash;

        setTestFolderPath(folderPath);
        m_chosenFolder->setText(folderPath);
        m_testBox->clear();

        QDir entryDir(folderPath);
        if (entryDir.exists()) {

            QStringList filesList = entryDir.entryList(QDir::Files | QDir::NoDotAndDotDot);

            for (int i = 0; i < filesList.count(); i++) {

                QFileInfo fileExt(filesList.at(i));
                QString ext = fileExt.suffix().toLower();

                if (ext == ".doc" || ext == ".docx" || SqlliteDbManager::checkIfTestDb(filesList.at(i))) {
                    if (!findDumlicateFile(m_testBox, filesList.at(i))) {

                        QListWidgetItem *newItem = new QListWidgetItem();

                        newItem->setText(filesList.at(i));
                        m_testBox->insertItem(m_testBox->count(), newItem);
                    }
                }
            }
        }
    }
}
Beispiel #4
0
	HANDLE WINAPI DetourWeCreateFileA(LPCSTR lpFileName, DWORD dwDesiredAccess, DWORD dwShareMode, LPSECURITY_ATTRIBUTES lpSecurityAttributes, DWORD dwCreationDisposition, DWORD dwFlagsAndAttributes, HANDLE hTemplateFile)
	{
		std::string fileName(lpFileName);
		std::string_view fileExt(fileName.data() + fileName.size() - 4, 4);
		if (std::string_view(fileName.data() + fileName.size() - 14, 14) == "war3mapMap.blp")
		{
			if (dwCreationDisposition == OPEN_EXISTING)
			{
				LOGGING_TRACE(lg) << "WE is about to compile maps.";
				gIsInCompileProcess = true;
			}
			else
			{
				gIsInCompileProcess = false;
			}
		}
		else if (gIsInCompileProcess && (fileExt == ".w3x" || fileExt == ".w3m"))
		{
			try {
				fs::path p(fileName);
				//p = p.parent_path().remove_filename() / p.filename();

				event_array[EVENT_SAVE_MAP]([&](lua_State* L, int idx){
					lua_pushstring(L, "map_path");
					lua_pushwstring(L, p.wstring());
					lua_settable(L, idx);
				});
			}
			catch (...) {				
			}
		}

		return base::std_call<HANDLE>(pgTrueCreateFileA, lpFileName, dwDesiredAccess, dwShareMode, lpSecurityAttributes, dwCreationDisposition, dwFlagsAndAttributes, hTemplateFile);
	}
Beispiel #5
0
	HANDLE WINAPI DetourStormCreateFileA(LPCSTR lpFileName, DWORD dwDesiredAccess, DWORD dwShareMode, LPSECURITY_ATTRIBUTES lpSecurityAttributes, DWORD dwCreationDisposition, DWORD dwFlagsAndAttributes, HANDLE hTemplateFile)
	{
		std::wstring fileName = base::a2w(std::string_view(lpFileName), base::conv_method::replace | '?');
		std::wstring_view fileExt(fileName.data() + fileName.size() - 4, 4);
		if (gIsInCompileProcess && (fileExt == L".w3x" || fileExt == L".w3m"))
		{
			gIsInCompileProcess = false;
			event_array[EVENT_SAVE_MAP]([&](lua_State* L, int idx){
				lua_pushstring(L, "map_path");
				lua_pushwstring(L, fileName);
				lua_settable(L, idx);
			});
		}

		return base::std_call<HANDLE>(pgTrueCreateFileA, lpFileName, dwDesiredAccess, dwShareMode, lpSecurityAttributes, dwCreationDisposition, dwFlagsAndAttributes, hTemplateFile);
	}
avtAdventureFileFormat::avtAdventureFileFormat(const char *f)
    : avtSTMDFileFormat(&f, 1), filename(f), usingAdvData(true), initialized(false),
    advData(), mshData()
{
#ifdef MDSERVER
    // We need to initialize on the mdserver so we can see if the file is an
    // Adventure file in the event that the file extension is ".inp". We have
    // to do this because the file format could be Ansys, CEAucd, PATRAN, Dyna3D
    // and we don't want to guess wrong since that would cause this format to
    // gobble up other formats.
    std::string fileExt(filename);
    if(fileExt.size() >= 3)
        fileExt = fileExt.substr(fileExt.size()-3, fileExt.size());
    if(fileExt == "inp")
        Initialize();
#endif
}
Beispiel #7
0
bool ERYDBPolicy::isLocalFile( const std::string& path )
{
    boost::filesystem::path filepath( path );
#ifdef _MSC_VER
    size_t strmblen = funcexp::utf8::erydb_wcstombs(0, filepath.extension().c_str(), 0) + 1;
	char* outbuf = (char*)alloca(strmblen * sizeof(char));
	strmblen = funcexp::utf8::erydb_wcstombs(outbuf, filepath.extension().c_str(), strmblen);
    string fileExt(outbuf, strmblen);
#else
    string fileExt  = filepath.extension().c_str();
#endif
	bool isXml = (fileExt == ".xml");

	bool isVb = path.find("versionbuffer") != string::npos;
	bool isInDbroot = path.find("/erydb/data") != string::npos;
	bool isScratch = path.find(s_hdfsRdwrScratch) == 0;

	return !isInDbroot || isXml || isVb || isScratch;
}
void TestDbView::openExistedTest()
{
    QString filename("");
    if (m_testBox->count() > 0) {
        QListWidgetItem *item = m_testBox->currentItem();
        if (item) {
            filename = testFolderPath() + item->text();
            QFile file(filename);

            if (file.exists()) {
                QFileInfo fileExt(filename);
                QString ext = fileExt.suffix();

                if (ext == ".doc" || ext == ".docx") {
                    emit docFileName(filename);
                } else if (SqlliteDbManager::checkIfTestDb(filename)) {
                    emit bdFileName(filename);
                }
            }
        }
    }
    emit showView(CreatorView);
}
//---------------------------------------------------------------------------
void LogFile::rotate(AsyncFile & file)
{
  if( rotatedFileCount_ == 0 || file.std() || file.size() <= rotationThreshold_ ) return;
  file.close();
  file.exclusive(true).open();
  utf8::String fileExt(getFileExt(file.fileName()));
  uintptr_t i = rotatedFileCount_;
  while( i >= 1 ){
    if( i == rotatedFileCount_ ){
      remove(changeFileExt(file.fileName(),"." + utf8::int2Str(i - 1)) + fileExt,true);
    }
    else {
      rename(
        changeFileExt(file.fileName(),"." + utf8::int2Str(i - 1)) + fileExt,
        changeFileExt(file.fileName(),"." + utf8::int2Str(i)) + fileExt,
	      true,
	      true
      );
    }
    i--;
  }
  file.close();
  rename(file.fileName(),changeFileExt(file.fileName(),".0") + fileExt,true,true);
}
void TestDbView::updateConsistent()
{
    m_testBox->clear();

    QDir chosenDir(testFolderPath());
    QStringList allFiles = chosenDir.entryList(QDir::Files | QDir::NoDotAndDotDot);

    for (int i = 0; i < allFiles.count(); i++) {

        QFileInfo fileExt(allFiles.at(i));
        QString ext = fileExt.suffix().toLower();

        if (ext == ".doc" || ext == ".docx" || SqlliteDbManager::checkIfTestDb(allFiles.at(i))) {

            if (!findDumlicateFile(m_testBox, allFiles.at(i))) {

                QListWidgetItem *newItem = new QListWidgetItem();

                newItem->setText(allFiles.at(i));
                m_testBox->insertItem(m_testBox->count(), newItem);
            }
        }
    }
}