// Called before render is available
bool j1FileSystem::Awake(pugi::xml_node& config)
{
	LOG("Loading File System");
	bool ret = true;

	// Add all paths in configuration in order
	for(pugi::xml_node path = config.child("path"); path; path = path.next_sibling("path"))
	{
		AddPath(path.child_value());
	}

	// Ask SDL for a write dir
	char* write_path = SDL_GetPrefPath(App->GetOrganization(), App->GetTitle());

	if(PHYSFS_setWriteDir(write_path) == 0)
		LOG("File System error while creating write dir: %s\n", PHYSFS_getLastError());
	else
	{
		// We add the writing directory as a reading directory too with speacial mount point
		LOG("Writing directory is %s\n", write_path);
		AddPath(write_path, GetSaveDirectory());
	}

	SDL_free(write_path);

	return ret;
}
Beispiel #2
0
CString FindIncludeFile( const TCHAR *pszIncludeFilename, const TCHAR *pszIncludePath )
{
	CString strEnvInclude;
	CStringList strrgPathList;
	
	if( FileExists( pszIncludeFilename ) )
		return CString(pszIncludeFilename);
	
	// add current directory to path list;
	strrgPathList.AddTail( ".\\" );
	
	// add path specified in the command line (/I option)
	if( pszIncludePath )
		AddPath( strrgPathList, pszIncludePath );
	
	// add path specified in the INCLUDE variable
	if( strEnvInclude.GetEnvironmentVariable( _T("INCLUDE") ) )
		AddPath( strrgPathList, strEnvInclude );
	
	POSITION pos = strrgPathList.GetHeadPosition();
	for (int i=0;i < strrgPathList.GetCount();i++)
	{
		CString strPath = strrgPathList.GetNext(pos);
		CString tmp = strPath.Right(1);
		if( tmp != ":" && tmp != "\\" )
			strPath += '\\';
		
		strPath += pszIncludeFilename;
		
		if( FileExists( strPath ) )
			return CString(strPath);
	}

	return CString("");
}
Beispiel #3
0
j1FileSystem::j1FileSystem(const char* game_path) : j1Module()
{
	name.create("file_system");

	// need to be created before Awake so other modules can use it
	char* base_path = SDL_GetBasePath();
	PHYSFS_init(base_path);
	SDL_free(base_path);

	AddPath(".");
	AddPath(game_path);
}
void QtStylePreferencePage::Update()
{
  styleManager->RemoveStyles();

  QString paths = m_StylePref->Get(berry::QtPreferences::QT_STYLE_SEARCHPATHS, "");
  QStringList pathList = paths.split(";", QString::SkipEmptyParts);
  QStringListIterator it(pathList);
  while (it.hasNext())
  {
    AddPath(it.next(), false);
  }

  QString styleName = m_StylePref->Get(berry::QtPreferences::QT_STYLE_NAME, "");
  styleManager->SetStyle(styleName);
  oldStyle = styleManager->GetStyle();
  FillStyleCombo(oldStyle);

  QString fontName = m_StylePref->Get(berry::QtPreferences::QT_FONT_NAME, "Open Sans");
  styleManager->SetFont(fontName);

  int fontSize = m_StylePref->Get(berry::QtPreferences::QT_FONT_SIZE, "9").toInt();
  styleManager->SetFontSize(fontSize);
  controls.m_FontSizeSpinBox->setValue(fontSize);
  styleManager->UpdateWorkbenchFont();

  FillFontCombo(styleManager->GetFont());

  controls.m_ToolbarCategoryCheckBox->setChecked(
    m_StylePref->GetBool(berry::QtPreferences::QT_SHOW_TOOLBAR_CATEGORY_NAMES, true));
}
Beispiel #5
0
void CRegisterDlg::OnReceiveComplete(void)
{

	switch (m_ContextObject->InDeCompressedBuffer.GetBuffer(0)[0])
	{

	case TOKEN_REG_PATH:
		{

			AddPath((char*)(m_ContextObject->InDeCompressedBuffer.GetBuffer(1)));
			break;
		}

	case TOKEN_REG_KEY:
		{

			AddKey((char*)(m_ContextObject->InDeCompressedBuffer.GetBuffer(1)));
			break;
		}

	default:
		// 传输发生异常数据
		break;

	}
}
Beispiel #6
0
FilePath::FilePath(const FilePath &directory, const String &filename)
{
	DVASSERT(directory.IsDirectoryPathname());

    pathType = directory.pathType;
	absolutePathname = AddPath(directory, filename);
}
Beispiel #7
0
bool CTSVNPathList::LoadFromFile(const CTSVNPath& filename)
{
    Clear();
    try
    {
        CString strLine;
        CStdioFile file(filename.GetWinPath(), CFile::typeBinary | CFile::modeRead | CFile::shareDenyWrite);

        // for every selected file/folder
        CTSVNPath path;
        while (file.ReadString(strLine))
        {
            path.SetFromUnknown(strLine);
            AddPath(path);
        }
        file.Close();
    }
    catch (CFileException* pE)
    {
        std::unique_ptr<TCHAR[]> error(new TCHAR[10000]);
        pE->GetErrorMessage(error.get(), 10000);
        ::MessageBox(NULL, error.get(), L"TortoiseSVN", MB_ICONERROR);
        pE->Delete();
        return false;
    }
    return true;
}
Beispiel #8
0
bool CTGitPathList::LoadFromFile(const CTGitPath& filename)
{
	Clear();
	try
	{
		CString strLine;
		CStdioFile file(filename.GetWinPath(), CFile::typeBinary | CFile::modeRead | CFile::shareDenyWrite);

		// for every selected file/folder
		CTGitPath path;
		while (file.ReadString(strLine))
		{
			path.SetFromUnknown(strLine);
			AddPath(path);
		}
		file.Close();
	}
	catch (CFileException* pE)
	{
		CTraceToOutputDebugString::Instance()(__FUNCTION__ ": CFileException loading target file list\n");
		TCHAR error[10000] = {0};
		pE->GetErrorMessage(error, 10000);
//		CMessageBox::Show(NULL, error, _T("TortoiseGit"), MB_ICONERROR);
		pE->Delete();
		return false;
	}
	return true;
}
Beispiel #9
0
int CTGitPathList::FillUnRev(unsigned int action, CTGitPathList *list, CString *err)
{
	this->Clear();
	CTGitPath path;

	int count;
	if(list==NULL)
		count=1;
	else
		count=list->GetCount();
	for (int i = 0; i < count; ++i)
	{
		CString cmd;
		int pos = 0;

		CString ignored;
		if(action & CTGitPath::LOGACTIONS_IGNORE)
			ignored= _T(" -i");

		if(list==NULL)
		{
			cmd=_T("git.exe ls-files --exclude-standard --full-name --others -z");
			cmd+=ignored;

		}
		else
		{	cmd.Format(_T("git.exe ls-files --exclude-standard --full-name --others -z%s -- \"%s\""),
					(LPCTSTR)ignored,
					(*list)[i].GetWinPath());
		}

		BYTE_VECTOR out, errb;
		out.clear();
		if (g_Git.Run(cmd, &out, &errb))
		{
			if (err != nullptr)
				CGit::StringAppend(err, &errb[0], CP_UTF8, (int)errb.size());
			return -1;
		}

		pos=0;
		CString one;
		while (pos >= 0 && pos < (int)out.size())
		{
			one.Empty();
			CGit::StringAppend(&one, &out[pos], CP_UTF8);
			if(!one.IsEmpty())
			{
				//SetFromGit will clear all status
				path.SetFromGit(one);
				path.m_Action=action;
				AddPath(path);
			}
			pos=out.findNextString(pos);
		}

	}
	return 0;
}
Beispiel #10
0
FX_BOOL CFX_LinuxFontInfo::ParseFontCfg(const char** pUserPaths) {
  if (!pUserPaths) {
    return FALSE;
  }
  for (const char** pPath = pUserPaths; *pPath; ++pPath) {
    AddPath(*pPath);
  }
  return TRUE;
}
Beispiel #11
0
FilePath::FilePath(const String &directory, const String &filename)
{
	FilePath directoryPath(directory);
	DVASSERT(!directoryPath.IsEmpty());
	directoryPath.MakeDirectoryPathname();

    pathType = directoryPath.pathType;
	absolutePathname = AddPath(directoryPath, filename);
}
Beispiel #12
0
bool Clipper::addPolyline(const ofPolyline& polyline,
                          ClipperLib::PolyType PolyTyp,
                          bool autoClose,
                          ClipperLib::cInt scale)
{
    auto _polyline = polyline;
    if (autoClose) close(_polyline);
    return AddPath(toClipper(_polyline, scale), PolyTyp, _polyline.isClosed());
}
void
SCSIPressurePathManager::ActivatePath ( IOSCSIProtocolServices * interface )
{
	
	bool					result 	= false;
	SCSITargetDevicePath *	path	= NULL;
	
	STATUS_LOG ( ( "SCSIPressurePathManager::ActivatePath\n" ) );
	
	require_nonzero ( interface, ErrorExit );
	
	IOLockLock ( fLock );
	
	result = fInactivePathSet->member ( interface );
	if ( result == true )
	{
		
		path = fInactivePathSet->getObjectWithInterface ( interface );
		if ( path != NULL )
		{
			
			path->retain ( );
			path->Activate ( );
			fInactivePathSet->removeObject ( interface );
			fPathSet->setObject ( path );
			path->release ( );
			path = NULL;
			
		}
		
	}
	
	else
	{
		
		result = fPathSet->member ( interface );
		if ( result == false )
		{
			
			IOLockUnlock ( fLock );
			AddPath ( interface );
			goto Exit;
			
		}
		
	}
	
	IOLockUnlock ( fLock );
	
	
ErrorExit:
Exit:
	
	
	return;
	
}
Beispiel #14
0
void PyInit(const TStr& PySettings)
{
	Try
	ifstream f(PySettings.CStr());
	if (f.is_open())
	{
		std::string s;
		std::getline(f, s);
		Py_Initialize(); // инициализация интерпретатора  */
		AddPath(s);
		AddPath(s+"\\\\networkx\\\\generators");
		AddPath(s+"\\\\networkx\\\\readwrite");
		AddPath(s+"\\\\networkx\\\\classes");
	}
	return;		
	IAssert(1);
	Catch
	
}
//reads envvar, splits it by : and ; and add it to pathlist, when exists
static void GetEnv(const std::string& name, LSL::StringVector& pathlist)
{
	const char* envvar = getenv(name.c_str());
	if (envvar == NULL)
		return;
	LSL::StringVector res = LSL::Util::StringTokenize(envvar, ";:");
	for (const std::string path : res) {
		AddPath(path, pathlist);
	}
}
Beispiel #16
0
		void ZipArchiveImpl::AddFolder(const bfs::path& path, const bfs::path& archive_path)
		{
			++m_Info.folderCount;

			zip_fileinfo fileinfo;
			fileinfo.internal_fa = 0;
#ifdef _WIN32
			fileinfo.external_fa = ::GetFileAttributesW(path.native().c_str());
#else
			{
				struct stat path_stat;
				if (::stat(path.native().c_str(), &path_stat) == 0)
				{
					fileinfo.external_fa = path_stat.st_mode;
				}
			}
#endif
			fileinfo.dosDate = 0;
			// Read the time from the filesystem and convert it
			auto fsTime = bfs::last_write_time(path);
			auto posixTime = boost::posix_time::from_time_t(fsTime);
			auto tm = boost::posix_time::to_tm(posixTime);

			/* TODO: this is how to get the time for a physfs file
			boost::posix_time::ptime posixTime;
			auto milisPastEpoc = PHYSFS_getLastModTime(path.generic_string().c_str());
			if (milisPastEpoc >= 0)
			time = boost::posix_time::ptime(boost::gregorian::date(1970, 1, 1), boost::posix_time::milliseconds(milisPastEpoc));
			else
			time = boost::posix_time::second_clock::local_time();
			*/

			fileinfo.tmz_date.tm_hour = tm.tm_hour;
			fileinfo.tmz_date.tm_min = tm.tm_min;
			fileinfo.tmz_date.tm_sec = tm.tm_sec;
			fileinfo.tmz_date.tm_year = tm.tm_year;
			fileinfo.tmz_date.tm_mon = tm.tm_mon;
			fileinfo.tmz_date.tm_mday = tm.tm_mday;

			auto r = zipOpenNewFileInZip(m_File, (archive_path.generic_string() + "/").c_str(),
				&fileinfo,
				nullptr, 0,
				nullptr, 0,
				nullptr,
				Z_DEFLATED,
				Z_BEST_SPEED);

			zipCloseFileInZip(m_File);

			for (bfs::directory_iterator it(path), end = bfs::directory_iterator(); it != end; ++it)
			{
				AddPath(it->path(), archive_path / it->path().filename());
			}
		}
Beispiel #17
0
FilePath& FilePath::operator+=(const String & path)
{
    absolutePathname = AddPath(*this, path);

	if (pathType == PATH_EMPTY)
	{
		pathType = GetPathType(absolutePathname);
	}

    return (*this);
}
Beispiel #18
0
FilePath FilePath::operator+(const String &path) const
{
    FilePath pathname(AddPath(*this, path));

    pathname.pathType = this->pathType;
	if (this->pathType == PATH_EMPTY)
	{
		pathname.pathType = GetPathType(pathname.absolutePathname);
	}

    return pathname;
}
  //
  // RequestPath
  //
  // Request a new path be found.  Returns FALSE if request is invalid.
  //
  Finder::RequestResult Finder::RequestPath
  (
    U32 sx, U32 sz, U32 dx, U32 dz, U8 traction, UnitObj *unit,
    SearchType type, U32 flags, PointList *blockList
  )
  {
    // Forget any current path
    ForgetPath();

    // Is destination on the map
    if (!WorldCtrl::CellOnMap(sx, sz) || !WorldCtrl::CellOnMap(dx, dz))
    {
      LOG_DIAG(("Request position is not on the map (%u, %u)->(%u,%u)", sx, sz, dx, dz));
      return (RR_OFFMAP);
    }

    // Filter out requests to move to the same cell
    if (sx == dx && sz == dz)
    {
      return (RR_SAMECELL);
    }

    // Can this traction type move to this cell
    if (!CanMoveToCell(traction, dx, dz))
    {
      U32 xNew, zNew;

      // Find the closest location we can move to
      if (FindClosestCell(traction, dx, dz, xNew, zNew, 15))
      {
        // Use the new location
        dx = xNew;
        dz = zNew;
      }
      else

      // AStar will fail, so jump straight to trace
      if (type == ST_ASTAR)
      {
        type = ST_TRACE;
      }
    }

    // Create a new path
    path = new Path(sx, sz, dx, dz, traction, unit, type, flags, blockList);

    // Add to the system
    AddPath(path);

    // Success
    return (RR_SUBMITTED);
  }
Beispiel #20
0
BOOL CAddListDlg::EnumerateFiles()
{
	m_AddFileCount=0;
	BOOL success=TRUE;

	// Recurse any directories in files list, placing enumerated files into 
	// the 'files' list
	POSITION pos=m_pStrList->GetHeadPosition();
	for( int i=0; pos != NULL && success; i++)
		success=AddPath(&m_EnumeratedList, m_pStrList->GetNext(pos));

	return success;
}
void C4Reloc::Init()
{
	Paths.clear();

	// The system folder (i.e. installation path) has higher priority than the user path
	// Although this is counter-intuitive (the user may want to overload system files in the user path),
	// people had trouble when they downloaded e.g. an Objects.ocd file in a network lobby and that copy permanently
	// ruined their OpenClonk installation with no obvious way to fix it.
	// Not even reinstalling would fix the problem because reinstallation does not overwrite user data.
	// We currently don't have any valid case where overloading system files would make sense so just give higher priority to the system path for now.
#ifndef __APPLE__
	// Add planet subfolder with highest priority because it's used when starting directly from the repository with binaries in the root folder
	StdCopyStrBuf planet(Config.General.ExePath);
	planet.AppendBackslash();
	planet.Append("planet");
	AddPath(planet.getData());
#endif
	// Add main system path
	AddPath(Config.General.SystemDataPath);
	// Add user path for additional data (player files, user scenarios, etc.)
	AddPath(Config.General.UserDataPath, PATH_PreferredInstallationLocation);
}
j1FileSystem::j1FileSystem() : j1Module()
{
	name.create("file_system");

	// need to be created before Awake so other modules can use it
	char* base_path = SDL_GetBasePath();
	PHYSFS_init(base_path);
	SDL_free(base_path);

	// By default we include executable's own directory
	// without this we won't be able to find config.xml :-(
	AddPath(".");
}
Beispiel #23
0
void CTGitPathList::LoadFromAsteriskSeparatedString(const CString& sPathString)
{
	int pos = 0;
	CString temp;
	for(;;)
	{
		temp = sPathString.Tokenize(_T("*"),pos);
		if(temp.IsEmpty())
		{
			break;
		}
		AddPath(CTGitPath(CPathUtils::GetLongPathname(temp)));
	}
}
Beispiel #24
0
void wxGraphicsPathData::AddEllipse( wxDouble x, wxDouble y, wxDouble w, wxDouble h)
{
    wxDouble rw = w/2;
    wxDouble rh = h/2;
    wxDouble xc = x + rw;
    wxDouble yc = y + rh;
    wxGraphicsMatrix m = GetRenderer()->CreateMatrix();
    m.Translate(xc,yc);
    m.Scale(rw/rh,1.0);
    wxGraphicsPath p = GetRenderer()->CreatePath();
    p.AddCircle(0,0,rh);
    p.Transform(m);
    AddPath(p.GetPathData());
}
Beispiel #25
0
void cTerrainGen3D::BuildPath(const tVector& origin, const tVector& ground_size, const Eigen::VectorXd& params, cRand& rand, 
								std::vector<float>& out_data, std::vector<int>& out_flags)
{
	double w = params[eParamsPathWidth0];
	double len = params[eParamsPathLength];
	double turn_len = params[eParamsPathTurnLength];
	double h0 = params[eParamsPathHeight0];
	double h1 = params[eParamsPathHeight1];

	Eigen::Vector2i start_coord = Eigen::Vector2i::Zero();
	Eigen::Vector2i out_res = Eigen::Vector2i::Zero();
	out_res[0] = CalcResX(ground_size[0]);
	out_res[1] = CalcResZ(ground_size[1]);
	return AddPath(origin, start_coord, ground_size, out_res, w, len, turn_len, h0, h1, out_data, out_flags);
}
Beispiel #26
0
void
GLRendererRoster::AddDefaultPaths()
{
	// add user directories first, so that they can override system renderers
	const directory_which paths[] = {
		B_USER_ADDONS_DIRECTORY,
		B_COMMON_ADDONS_DIRECTORY,
		B_BEOS_ADDONS_DIRECTORY,
	};

	for (uint32 i = fSafeMode ? 2 : 0; i < sizeof(paths) / sizeof(paths[0]); i++) {
		BPath path;
		status_t status = find_directory(paths[i], &path, true);
		if (status == B_OK && path.Append("opengl") == B_OK)
			AddPath(path.Path());
	}
}
Beispiel #27
0
void CTSVNPathList::LoadFromAsteriskSeparatedString(const CString& sPathString)
{
    if (GetCount() > 0)
        Clear();

    int pos = 0;
    CString temp;
    for(;;)
    {
        temp = sPathString.Tokenize(L"*",pos);
        if(temp.IsEmpty())
        {
            break;
        }
        AddPath(CTSVNPath(CPathUtils::GetLongPathname(temp)));
    }
}
Beispiel #28
0
Prefs_Fonts::Prefs_Fonts(QWidget* parent, ScribusDoc* doc)
	: Prefs_Pane(parent),
	m_doc(doc)
{
	setupUi(this);

	RList = PrefsManager::instance()->appPrefs.fontPrefs.GFontSub;
	UsedFonts.clear();
	CurrentPath = "";
	m_askBeforeSubstitute = true;

	setMinimumSize(fontMetrics().width( tr( "Available Fonts" )+ tr( "Font Substitutions" )+ tr( "Additional Paths" ))+180, 200);

	fontListTableView->setModel(new FontListModel(fontListTableView, m_doc));

	fontSubstitutionsTableWidget->setRowCount(RList.count());
	fontSubstitutionsTableWidget->setColumnCount(2);
	fontSubstitutionsTableWidget->setHorizontalHeaderItem(0, new QTableWidgetItem( tr("Font Name")));
	fontSubstitutionsTableWidget->setHorizontalHeaderItem(1, new QTableWidgetItem( tr("Replacement")));
	fontSubstitutionsTableWidget->setSortingEnabled(false);
	fontSubstitutionsTableWidget->setSelectionBehavior( QAbstractItemView::SelectRows );
	QHeaderView *header = fontSubstitutionsTableWidget->horizontalHeader();
	header->setSectionsMovable(false);
	header->setSectionsClickable(false);
	header->setSectionResizeMode(QHeaderView::Stretch);
	fontSubstitutionsTableWidget->verticalHeader()->hide();
	fontSubstitutionsTableWidget->setSizePolicy(QSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding));


	// If we're being called for global application preferences, not document
	// preferences, we let the user customize font search paths. Because things
	// go rather badly if paths are changed/removed while a doc is open, the
	// control is also not displayed if there is a document open.
	if (m_doc==0 && !ScCore->primaryMainWindow()->HaveDoc)
	{
		whyBlankLabel->resize(0,0);
		whyBlankLabel->hide();
		readPaths();
		changeButton->setEnabled(false);
		removeButton->setEnabled(false);
		connect(pathListWidget, SIGNAL(itemClicked(QListWidgetItem*)), this, SLOT(SelectPath(QListWidgetItem*)));
		connect(addButton, SIGNAL(clicked()), this, SLOT(AddPath()));
		connect(changeButton, SIGNAL(clicked()), this, SLOT(ChangePath()));
		connect(removeButton, SIGNAL(clicked()), this, SLOT(DelPath()));
	}
Beispiel #29
0
	void LoadPaths(const char *pArgv0)
	{
		// check current directory
		IOHANDLE File = io_open("storage.cfg", IOFLAG_READ);
		if(!File)
		{
			// check usable path in argv[0]
			unsigned int Pos = ~0U;
			for(unsigned i = 0; pArgv0[i]; i++)
				if(pArgv0[i] == '/' || pArgv0[i] == '\\')
					Pos = i;
			if(Pos < MAX_PATH_LENGTH)
			{
				char aBuffer[MAX_PATH_LENGTH];
				str_copy(aBuffer, pArgv0, Pos+1);
				str_append(aBuffer, "/storage.cfg", sizeof(aBuffer));
				File = io_open(aBuffer, IOFLAG_READ);
			}

			if(Pos >= MAX_PATH_LENGTH || !File)
			{
				dbg_msg("storage", "couldn't open storage.cfg");
				return;
			}
		}

		char *pLine;
		CLineReader LineReader;
		LineReader.Init(File);

		while((pLine = LineReader.Get()))
		{
			const char *pLineWithoutPrefix = str_startswith(pLine, "add_path ");
			if(pLineWithoutPrefix)
			{
				AddPath(pLineWithoutPrefix);
			}
		}

		io_close(File);

		if(!m_NumPaths)
			dbg_msg("storage", "no paths found in storage.cfg");
	}
Beispiel #30
0
int CTGitPathList::FillBasedOnIndexFlags(unsigned short flag, CTGitPathList* list /*nullptr*/)
{
	Clear();
	CTGitPath path;

	CAutoRepository repository(g_Git.GetGitRepository());
	if (!repository)
		return -1;

	CAutoIndex index;
	if (git_repository_index(index.GetPointer(), repository))
		return -1;

	int count;
	if (list == nullptr)
		count = 1;
	else
		count = list->GetCount();
	for (int j = 0; j < count; ++j)
	{
		for (size_t i = 0, ecount = git_index_entrycount(index); i < ecount; ++i)
		{
			const git_index_entry *e = git_index_get_byindex(index, i);

			if (!e || !((e->flags | e->flags_extended) & flag) || !e->path)
				continue;

			CString one = CUnicodeUtils::GetUnicode(e->path);

			if (!(!list || (*list)[j].GetWinPathString().IsEmpty() || one == (*list)[j].GetGitPathString() || (PathIsDirectory(g_Git.CombinePath((*list)[j].GetWinPathString())) && one.Find((*list)[j].GetGitPathString() + _T("/")) == 0)))
				continue;

			//SetFromGit will clear all status
			path.SetFromGit(one);
			if ((e->flags | e->flags_extended) & GIT_IDXENTRY_SKIP_WORKTREE)
				path.m_Action = CTGitPath::LOGACTIONS_SKIPWORKTREE;
			else if ((e->flags | e->flags_extended) & GIT_IDXENTRY_VALID)
				path.m_Action = CTGitPath::LOGACTIONS_ASSUMEVALID;
			AddPath(path);
		}
	}
	RemoveDuplicates();
	return 0;
}