Example #1
0
		ui->lwjglDirTextBox->setText(cooked_dir);
	}
}

void SettingsDialog::on_jsonEditorBrowseBtn_clicked()
{
	QString raw_file = QFileDialog::getOpenFileName(
		this, tr("JSON Editor"),
		ui->jsonEditorTextBox->text().isEmpty()
#if defined(Q_OS_LINUX)
				? QString("/usr/bin")
#else
			? QStandardPaths::standardLocations(QStandardPaths::ApplicationsLocation).first()
#endif
			: ui->jsonEditorTextBox->text());
	QString cooked_file = NormalizePath(raw_file);

	if (cooked_file.isEmpty())
	{
		return;
	}

	// it has to exist and be an executable
	if (QFileInfo(cooked_file).exists() && QFileInfo(cooked_file).isExecutable())
	{
		ui->jsonEditorTextBox->setText(cooked_file);
	}
	else
	{
		QMessageBox::warning(this, tr("Invalid"),
							 tr("The file chosen does not seem to be an executable"));
Example #2
0
bool IsSameFile(const String& f1, const String& f2)
{
	return NormalizePath(f1) == NormalizePath(f2);
}
Example #3
0
void PathInfo::BuildPointPath(const float* startPoint, const float* endPoint)
{
    float pathPoints[MAX_POINT_PATH_LENGTH * VERTEX_SIZE];
    uint32 pointCount = 0;
    dtStatus dtResult = DT_FAILURE;
    if (m_useStraightPath)
    {
        dtResult = m_navMeshQuery->findStraightPath(
                       startPoint,         // start position
                       endPoint,           // end position
                       m_pathPolyRefs,     // current path
                       m_polyLength,       // lenth of current path
                       pathPoints,         // [out] path corner points
                       NULL,               // [out] flags
                       NULL,               // [out] shortened path
                       (int*)&pointCount,
                       m_pointPathLimit);   // maximum number of points/polygons to use
    }
    else
    {
        dtResult = findSmoothPath(
                       startPoint,         // start position
                       endPoint,           // end position
                       m_pathPolyRefs,     // current path
                       m_polyLength,       // length of current path
                       pathPoints,         // [out] path corner points
                       (int*)&pointCount,
                       m_pointPathLimit);    // maximum number of points
    }

    if (pointCount < 2 || dtStatusFailed(dtResult))
    {
        // only happens if pass bad data to findStraightPath or navmesh is broken
        // single point paths can be generated here
        // TODO : check the exact cases
        sLog.outMMap("PathInfo::BuildPointPath FAILED! path sized %d returned\n", pointCount);
        BuildShortcut();
        m_type = PATHFIND_NOPATH;
        return;
    }
    else if (pointCount == m_pointPathLimit)
    {
        sLog.outMMap("PathInfo::BuildPointPath pointCount %u == m_pointPathLimit\n", pointCount);
        BuildShortcut();
        m_type = PATHFIND_SHORT;
        return;
    }

    m_pathPoints.resize(pointCount);
    for (uint32 i = 0; i < pointCount; ++i)
        m_pathPoints[i] = Vector3(pathPoints[i * VERTEX_SIZE + 2], pathPoints[i * VERTEX_SIZE], pathPoints[i * VERTEX_SIZE + 1]);

    NormalizePath();

    // first point is always our current location - we need the next one
    setNextPosition(m_pathPoints[1]);
    setActualEndPosition(m_pathPoints[pointCount - 1]);

    // force the given destination, if needed
    if (m_forceDestination &&
        (!(m_type & PATHFIND_NORMAL) || !inRange(getEndPosition(), getActualEndPosition(), 1.0f, 1.0f)))
    {
        // we may want to keep partial subpath
        if (dist3DSqr(getActualEndPosition(), getEndPosition()) <
            0.3f * dist3DSqr(getStartPosition(), getEndPosition()))
        {
            setActualEndPosition(getEndPosition());
            m_pathPoints[m_pathPoints.size() - 1] = getEndPosition();
        }
        else
        {
            setActualEndPosition(getEndPosition());
            BuildShortcut();
        }

        m_type = PathType(PATHFIND_NORMAL | PATHFIND_NOT_USING_PATH);
    }

    //DEBUG_FILTER_LOG(LOG_FILTER_PATHFINDING, "++ PathInfo::BuildPointPath path type %d size %d poly-size %d\n", m_type, pointCount, m_polyLength);
}
Example #4
0
void PathGenerator::BuildPointPath(const float *startPoint, const float *endPoint)
{
    float pathPoints[MAX_POINT_PATH_LENGTH*VERTEX_SIZE];
    uint32 pointCount = 0;
    dtStatus dtResult = DT_FAILURE;
    if (_straightLine)
    {
        dtResult = DT_SUCCESS;
        pointCount = 1;
        memcpy(&pathPoints[VERTEX_SIZE * 0], startPoint, sizeof(float)* 3); // first point

        // path has to be split into polygons with dist SMOOTH_PATH_STEP_SIZE between them
        G3D::Vector3 startVec = G3D::Vector3(startPoint[0], startPoint[1], startPoint[2]);
        G3D::Vector3 endVec = G3D::Vector3(endPoint[0], endPoint[1], endPoint[2]);
        G3D::Vector3 diffVec = (endVec - startVec);
        G3D::Vector3 prevVec = startVec;
        float len = diffVec.length();
        diffVec *= SMOOTH_PATH_STEP_SIZE / len;
        while (len > SMOOTH_PATH_STEP_SIZE)
        {
            len -= SMOOTH_PATH_STEP_SIZE;
            prevVec += diffVec;
            pathPoints[VERTEX_SIZE * pointCount + 0] = prevVec.x;
            pathPoints[VERTEX_SIZE * pointCount + 1] = prevVec.y;
            pathPoints[VERTEX_SIZE * pointCount + 2] = prevVec.z;
            ++pointCount;
        }

        memcpy(&pathPoints[VERTEX_SIZE * pointCount], endPoint, sizeof(float)* 3); // last point
        ++pointCount;
    }
    else if (_useStraightPath)
    {
        dtResult = _navMeshQuery->findStraightPath(
                startPoint,         // start position
                endPoint,           // end position
                _pathPolyRefs,     // current path
                _polyLength,       // lenth of current path
                pathPoints,         // [out] path corner points
                NULL,               // [out] flags
                NULL,               // [out] shortened path
                (int*)&pointCount,
                _pointPathLimit);   // maximum number of points/polygons to use
    }
    else
    {
        dtResult = FindSmoothPath(
                startPoint,         // start position
                endPoint,           // end position
                _pathPolyRefs,     // current path
                _polyLength,       // length of current path
                pathPoints,         // [out] path corner points
                (int*)&pointCount,
                _pointPathLimit);    // maximum number of points
    }

    if (pointCount < 2 || dtStatusFailed(dtResult))
    {
        // only happens if pass bad data to findStraightPath or navmesh is broken
        // single point paths can be generated here
        /// @todo check the exact cases
        TC_LOG_DEBUG("maps", "++ PathGenerator::BuildPointPath FAILED! path sized %d returned\n", pointCount);
        BuildShortcut();
        _type = PATHFIND_NOPATH;
        return;
    }
    else if (pointCount == _pointPathLimit)
    {
        TC_LOG_DEBUG("maps", "++ PathGenerator::BuildPointPath FAILED! path sized %d returned, lower than limit set to %d\n", pointCount, _pointPathLimit);
        BuildShortcut();
        _type = PATHFIND_SHORT;
        return;
    }

    _pathPoints.resize(pointCount);
    for (uint32 i = 0; i < pointCount; ++i)
        _pathPoints[i] = G3D::Vector3(pathPoints[i*VERTEX_SIZE+2], pathPoints[i*VERTEX_SIZE], pathPoints[i*VERTEX_SIZE+1]);

    NormalizePath();

    // first point is always our current location - we need the next one
    SetActualEndPosition(_pathPoints[pointCount-1]);

    // force the given destination, if needed
    if (_forceDestination &&
        (!(_type & PATHFIND_NORMAL) || !InRange(GetEndPosition(), GetActualEndPosition(), 1.0f, 1.0f)))
    {
        // we may want to keep partial subpath
        if (Dist3DSqr(GetActualEndPosition(), GetEndPosition()) < 0.3f * Dist3DSqr(GetStartPosition(), GetEndPosition()))
        {
            SetActualEndPosition(GetEndPosition());
            _pathPoints[_pathPoints.size()-1] = GetEndPosition();
        }
        else
        {
            SetActualEndPosition(GetEndPosition());
            BuildShortcut();
        }

        _type = PathType(PATHFIND_NORMAL | PATHFIND_NOT_USING_PATH);
    }

    TC_LOG_DEBUG("maps", "++ PathGenerator::BuildPointPath path type %d size %d poly-size %d\n", _type, pointCount, _polyLength);
}
Example #5
0
bool MakeBuild::BuildPackage(const Workspace& wspc, int pkindex, int pknumber, int pkcount,
	String mainparam, String outfile, Vector<String>& linkfile, String& linkopt, bool link)
{
	String package = wspc[pkindex];
	String mainpackage = wspc[0];
	const Package& pkg = wspc.package[pkindex];
	VectorMap<String, String> bm = GetMethodVars(method);
	if(bm.GetCount() == 0) {
		PutConsole("Invalid build method");
		ConsoleShow();
		return false;
	}
	One<Host> host = CreateHost(false);
	if(!IsNull(onefile)) {
		OneFileHost *h = new OneFileHost;
		h->host = host;
		h->onefile = onefile;
		host = h;
	}
	One<Builder> b = CreateBuilder(~host);
	if(!b)
		return false;
	b->config = PackageConfig(wspc, pkindex, bm, mainparam, *host, *b);
	const TargetMode& m = targetmode == 0 ? debug : release;
	b->version = m.version;
	b->method = method;
	b->outdir = OutDir(b->config, package, bm);
	host->RealizeDir(b->outdir);
	String mainfn = Null;
	Index<String> mcfg = PackageConfig(wspc, 0, bm, mainparam, *host, *b, &mainfn);
	HdependClearDependencies();
	for(int i = 0; i < pkg.GetCount(); i++) {
		const Array<OptItem>& f = pkg[i].depends;
		for(int j = 0; j < f.GetCount(); j++)
			if(MatchWhen(f[j].when, mcfg.GetKeys()))
				HdependAddDependency(SourcePath(package, pkg[i]), SourcePath(package, f[j].text));
	}
	String tout = OutDir(mcfg, mainpackage, bm, use_target);
	host->RealizeDir(tout);
	if(IsNull(mainfn))
		mainfn = GetFileTitle(mainpackage) + b->GetTargetExt();
	if(!IsNull(outfile))
		target = NormalizePath(outfile, tout);
	else {
		if(m.target_override && !IsNull(m.target) && IsFolder(m.target))
			target = host->NormalizePath(AppendFileName(m.target, mainfn));
		else
		if(m.target_override && (IsFullPath(m.target) || *m.target == '/' || *m.target == '\\'))
			target = m.target;
		else
		if(m.target_override && !IsNull(m.target))
			target = host->NormalizePath(AppendFileName(tout, m.target));
		else
		if(IsFullPath(mainfn))
			target = mainfn;
		else
			target = host->NormalizePath(AppendFileName(tout, mainfn));
	}
	b->target = target;
	b->mainpackage = mainpackage;
	if(IsNull(onefile)) {
		String out;
		out << "----- " << package << " ( " << Join(b->config.GetKeys(), " ") << " )";
		if(pkcount > 1)
			out << " (" << (pknumber + 1) << " / " << pkcount << ')';
		PutConsole(out);
	}
	else
		b->config.FindAdd("NOLIB");
	bool ok = b->BuildPackage(package, linkfile, linkopt,
		                      GetAllUses(wspc, pkindex),
		                      GetAllLibraries(wspc, pkindex, bm, mainparam, *host, *b),
		                      targetmode - 1);
	Vector<String> errors = PickErrors();
	host->DeleteFile(errors);
	if(!ok || !errors.IsEmpty())
		return false;
	if(link) {
		ok = b->Link(linkfile, linkopt, GetTargetMode().createmap);
		errors = PickErrors();
		host->DeleteFile(errors);
		if(!ok || !errors.IsEmpty())
			return false;
	}
	return true;
}
Example #6
0
int PluginClass::ReadArchive(char *Name)
{
  bGOPIFirstCall=true;
  FreeArcData();
  DizPresent=FALSE;

  HANDLE ArcFindHandle;
  ArcFindHandle=FindFirstFile(ArcName,&ArcFindData);
  FindClose(ArcFindHandle);

  if (ArcFindHandle==INVALID_HANDLE_VALUE)
    return FALSE;

  if (!ArcPlugin->OpenArchive(ArcPluginNumber,Name,&ArcPluginType))
    return FALSE;

  memset(&ItemsInfo,0,sizeof(ItemsInfo));
  memset(&CurArcInfo,0,sizeof(CurArcInfo));
  TotalSize=PackedSize=0;

  HANDLE hScreen=Info.SaveScreen(0,0,-1,-1);

  DWORD StartTime=GetTickCount();//clock();
  int WaitMessage=FALSE;
  int AllocatedCount=0;
  int GetItemCode;

  while (1)
  {
    struct PluginPanelItem CurArcData;
    struct ArcItemInfo CurItemInfo;
    memset(&CurArcData,0,sizeof(CurArcData));
    memset(&CurItemInfo,0,sizeof(CurItemInfo));
    GetItemCode=ArcPlugin->GetArcItem(ArcPluginNumber,&CurArcData,&CurItemInfo);

    if (GetItemCode!=GETARC_SUCCESS)
      break;

    if ((ArcDataCount & 0x1f)==0)
    {
      if (CheckForEsc())
      {
        FreeArcData();
        ArcPlugin->CloseArchive(ArcPluginNumber,&CurArcInfo);
        Info.RestoreScreen(NULL);
        Info.RestoreScreen(hScreen);
        return -1;
      }

      if (GetTickCount()-StartTime>1000)
      {
        char FilesMsg[100];
        char NameMsg[NM];
        FSF.sprintf(FilesMsg,GetMsg(MArcReadFiles),ArcDataCount);
        const char *MsgItems[]={GetMsg(MArcReadTitle),GetMsg(MArcReading),NameMsg,FilesMsg};
        FSF.TruncPathStr(lstrcpyn(NameMsg,Name,sizeof(NameMsg)),MAX_WIDTH_MESSAGE);
        Info.Message(Info.ModuleNumber,WaitMessage ? FMSG_KEEPBACKGROUND:0,NULL,MsgItems,
                   ARRAYSIZE(MsgItems),0);
        WaitMessage=TRUE;
      }
    }

    if (*CurItemInfo.Description)
    {
      CurArcData.Description=new char[lstrlen(CurItemInfo.Description)+1];
      if (CurArcData.Description)
        lstrcpy(CurArcData.Description,CurItemInfo.Description);
      DizPresent=TRUE;
    }

    if (lstrcmp(ItemsInfo.HostOS,CurItemInfo.HostOS)!=0)
      lstrcpy(ItemsInfo.HostOS,(*ItemsInfo.HostOS?GetMsg(MSeveralOS):CurItemInfo.HostOS));

    ItemsInfo.Solid|=CurItemInfo.Solid;
    ItemsInfo.Comment|=CurItemInfo.Comment;
    ItemsInfo.Encrypted|=CurItemInfo.Encrypted;

    if (CurItemInfo.Encrypted)
      CurArcData.Flags|=F_ENCRYPTED;

    if (CurItemInfo.DictSize>ItemsInfo.DictSize)
      ItemsInfo.DictSize=CurItemInfo.DictSize;

    if (CurItemInfo.UnpVer>ItemsInfo.UnpVer)
      ItemsInfo.UnpVer=CurItemInfo.UnpVer;

    CurArcData.NumberOfLinks=1;

    *CurArcData.FindData.cAlternateFileName=0;

    NormalizePath(CurArcData.FindData.cFileName,CurArcData.FindData.cFileName);

    char *NamePtr=CurArcData.FindData.cFileName;
    for (int I=0; *NamePtr ;I++, NamePtr++)
      if (*NamePtr=='/')
        *NamePtr='\\';

    struct ArcItemUserData *aud=NULL;
    char *Pref=NULL;

    NamePtr=CurArcData.FindData.cFileName;
    char *EndPos=NamePtr;
    while(*EndPos == '.') EndPos++;
    if(*EndPos == '\\')
      while(*EndPos == '\\') EndPos++;
    else
      EndPos=NamePtr;
    if(EndPos != NamePtr)
    {
      Pref=(char *)malloc((int)(EndPos-NamePtr)+1);
      if(Pref)
      {
        memcpy(Pref,NamePtr,(int)(EndPos-NamePtr));
        Pref[(int)(EndPos-NamePtr)]=0;
      }
    }

    if(CurArcData.UserData || Pref)
    {
       if((aud=(struct ArcItemUserData*)malloc(sizeof(struct ArcItemUserData))) != NULL)
       {
         CurArcData.Flags |= PPIF_USERDATA;
         aud->SizeStruct=sizeof(struct ArcItemUserData);
         aud->Prefix=Pref;
         aud->LinkName=CurArcData.UserData?(char *)CurArcData.UserData:NULL;
         CurArcData.UserData=(DWORD_PTR)aud;
       }
       else
         CurArcData.UserData=0;
    }
    if(!CurArcData.UserData && Pref)
      free(Pref);


    if (EndPos!=CurArcData.FindData.cFileName)
      memmove(CurArcData.FindData.cFileName,EndPos,lstrlen(EndPos)+1);

    int Length=lstrlen(CurArcData.FindData.cFileName);

    if (Length>0 && (CurArcData.FindData.cFileName[Length-1]=='\\'))
    {
      CurArcData.FindData.cFileName[Length-1]=0;
      CurArcData.FindData.dwFileAttributes|=FILE_ATTRIBUTE_DIRECTORY;
    }

    struct PluginPanelItem *NewArcData=ArcData;

    if (ArcDataCount>=AllocatedCount)
    {
      AllocatedCount=AllocatedCount+256+AllocatedCount/4;
      NewArcData=(PluginPanelItem *)realloc(ArcData,AllocatedCount*sizeof(*ArcData));
    }

    if (NewArcData==NULL)
      break;

    TotalSize+=(((__int64)CurArcData.FindData.nFileSizeHigh)<<32)|(__int64)CurArcData.FindData.nFileSizeLow;
    PackedSize+=(((__int64)CurArcData.PackSizeHigh)<<32)|(__int64)CurArcData.PackSize;


    ArcData=NewArcData;
    ArcData[ArcDataCount]=CurArcData;
    ArcDataCount++;
  }

  Info.RestoreScreen(NULL);
  Info.RestoreScreen(hScreen);

  if (ArcDataCount>0)
    ArcData=(PluginPanelItem *)realloc(ArcData,ArcDataCount*sizeof(*ArcData));

  ArcPlugin->CloseArchive(ArcPluginNumber,&CurArcInfo);

  if(GetItemCode != GETARC_EOF && GetItemCode != GETARC_SUCCESS)
  {
    switch(GetItemCode)
    {
      case GETARC_BROKEN:
        GetItemCode=MBadArchive;
        break;

      case GETARC_UNEXPEOF:
        GetItemCode=MUnexpEOF;
        break;

      case GETARC_READERROR:
        GetItemCode=MReadError;
        break;
    }

    char NameMsg[NM];
    const char *MsgItems[]={GetMsg(MError),NameMsg,GetMsg(GetItemCode),GetMsg(MOk)};
    FSF.TruncPathStr(lstrcpyn(NameMsg,Name,sizeof(NameMsg)),MAX_WIDTH_MESSAGE);
    Info.Message(Info.ModuleNumber,FMSG_WARNING,NULL,MsgItems,ARRAYSIZE(MsgItems),1);
    return FALSE; // Mantis#0001241
  }

  //Info.RestoreScreen(NULL);
  //Info.RestoreScreen(hScreen);
  return TRUE;
}
Example #7
0
File: Path.c Project: etiago/vbox
/** Parse a path producing the target device, device instance, and file path.

    It is the caller's responsibility to free() FullPath and MapPath when they
    are no longer needed.

    @param[in]    path
    @param[out]   FullPath
    @param[out]   DevNode
    @param[out]   Which
    @param[out]   MapPath       OPTIONAL.  If not NULL, it points to the place to save a pointer
                                to the extracted map name.  If the path didn't have a map name,
                                then *MapPath is set to NULL.

    @retval   RETURN_SUCCESS              The path was parsed successfully.
    @retval   RETURN_NOT_FOUND            The path does not map to a valid device.
    @retval   RETURN_OUT_OF_RESOURCES     Insufficient memory to calloc a MapName buffer.
                                          The errno variable is set to ENOMEM.
    @retval   RETURN_INVALID_PARAMETER    The path parameter is not valid.
                                          The errno variable is set to EINVAL.
**/
RETURN_STATUS
EFIAPI
ParsePath(
  IN    const char   *path,
  OUT   wchar_t     **FullPath,
  OUT   DeviceNode  **DevNode,
  OUT   int          *Which,
  OUT   wchar_t     **MapPath
  )
{
  int                 MapLen;
  PATH_CLASS          PathClass;
  wchar_t            *NewPath;
  wchar_t            *WPath     = NULL;
  wchar_t            *MPath     = NULL;
  DeviceNode         *Node      = NULL;
  RETURN_STATUS       Status    = RETURN_NOT_FOUND;
  int                 Instance  = 0;
  BOOLEAN             ReMapped;

  ReMapped  = FALSE;

  // Convert name from MBCS to WCS and change '/' to '\\'
  WPath = NormalizePath( path);
  PathClass = ClassifyPath(WPath, &NewPath, &MapLen);

reclassify:
  switch(PathClass) {
    case PathMapping:
      if(!ReMapped) {
        if((NewPath == NULL) || (*NewPath == L'\0')) { /* Nothing after the ':' */
          PathClass = PathAbsolute;
        }
        else {
          Instance = PathInstance(WPath, MapLen);
          PathClass = ClassifyPath(NewPath, NULL, NULL);
        }
        ReMapped = TRUE;
        if(WPath[MapLen] == L':') {
          // Get the Map Name, including the trailing ':'. */
          MPath = calloc(MapLen+2, sizeof(wchar_t));
          if(MPath != NULL) {
            wmemcpy(MPath, WPath, MapLen+1);
          }
          else {
            errno = ENOMEM;
            Status = RETURN_OUT_OF_RESOURCES;
            break;    // Exit the switch(PathClass) statement.
          }
        }
        if(WPath != NewPath) {
          /* Shift the RHS of the path down to the start of the buffer. */
          wmemmove(WPath, NewPath, wcslen(NewPath)+1);
          NewPath = WPath;
        }
        goto reclassify;
      }
      /*  Fall through to PathError if Remapped.
          This means that the path looked like "foo:bar:something".
      */

    case PathError:
      errno = EINVAL;
      Status = RETURN_INVALID_PARAMETER;
      break;

    case PathRelative:
      /*  Transform a relative path into an Absolute path.
          Prepends CWD and handles ./ and ../ entries.
          It is the caller's responsibility to free the space
          allocated to WPath.
      */
      WPath = PathAdjust(NewPath);    // WPath was malloc()ed by PathAdjust

    case PathAbsolute:
      /*  Perform any path aliasing.  For example: /dev/foo -> { node.foo, "" }
          The current volume and directory are updated in the path as needed.
          It is the caller's responsibility to free the space
          allocated to WPath.
      */
    Status = RETURN_SUCCESS;
      WPath = PathAlias(WPath, &Node);       // PathAlias frees its argument and malloc()s a new one.
      break;
  }
  if(!RETURN_ERROR(Status)) {
    *FullPath = WPath;
    *Which    = Instance;
    if(MapPath != NULL) {
      *MapPath  = MPath;
    }
    else if(MPath != NULL) {
      free(MPath);    /* Caller doesn't want it so let MPath go free */
    }

    /*  At this point, WPath is an absolute path,
        MPath is either NULL or points to the Map Name,
        and Instance is the instance number.
    */
    if(MPath == NULL) {
      /* This is NOT a mapped path. */
      if(Node == NULL) {
        Node = daDefaultDevice;
      }
      if(Node != NULL) {
        Status = RETURN_SUCCESS;
      }
      else {
        Status = RETURN_NOT_FOUND;
      }
    }
    else {
      /* This is a mapped path. */
      Status = __DevSearch( MPath, NULL, &Node);
      if(Status == RETURN_NOT_FOUND) {
        Node = daDefaultDevice;

        if(Node != NULL) {
          Status = RETURN_SUCCESS;
        }
      }
    }
    if(DevNode != NULL) {
      *DevNode = Node;
    }
  }
  return Status;
}
Example #8
0
bool   PathIsEqual(const char *p1, const char *p2)
{
	return NormalizePath(p1) == NormalizePath(p2);
}
Example #9
0
void SelectPackageDlg::Load()
{
	if(selectvars && !base.IsCursor())
		return;
	if(loading) { // If we are called recursively from ProcessEvents, stop current loading and change loadi
		loadi++;
		loading = false;
		return;
	}
	int current_loadi = -1;
	while(current_loadi != loadi) {
		current_loadi = loadi;
		if(selectvars) {
			String assembly = (String)base.Get(0);
			list.Enable(base.IsCursor());
			if(!base.IsCursor())
				return;
			LoadVars(assembly);
		}
		Vector<String> upp = GetUppDirs();
		packages.Clear();
		description.Hide();
		progress.Show();
		loading = true;
		data.Clear();
		Index<String> dir_exists;
		String cache_path = CachePath(GetVarsName());
		LoadFromFile(data, cache_path);
		data.SetCount(upp.GetCount());
		for(int i = 0; i < upp.GetCount(); i++) // Scan nest folders for subfolders (additional package candidates)
			ScanFolder(upp[i], data[i], GetFileName(upp[i]), dir_exists, Null);
		int update = msecs();
		for(int i = 0; i < data.GetCount() && loading; i++) { // Now investigate individual sub folders
			ArrayMap<String, PkData>& nest = data[i];
			String nest_dir = NormalizePath(upp[i]);
			for(int i = 0; i < nest.GetCount() && loading; i++) {
				if(msecs(update) >= 100) { // each 100 ms update the list (and open select dialog after splash screen is closed)
					if(!IsSplashOpen() && !IsOpen())
						Open();
					progress++;
					SyncList();
					update = msecs();
				}
				ProcessEvents(); // keep GUI running

				PkData& d = nest[i];
				String path = nest.GetKey(i);
				if(NormalizePath(path).StartsWith(nest_dir) && DirectoryExists(path)) {
					String upp_path = AppendFileName(path, GetFileName(d.package) + ".upp");
					LSLOW();
					Time tm = FileGetTime(upp_path);
					if(IsNull(tm)) // .upp file does not exist - not a package
						d.ispackage = false;
					else
					if(tm != d.tm) { // cached info is outdated
						Package p;
						if(p.Load(upp_path)) {
							d.description = p.description;
							d.main = p.config.GetCount();
							d.tm = tm;
							d.ispackage = true;
						}
						else
							d.ispackage = false;
					}
					else
						d.ispackage = true;
					if(d.ispackage) {
						String icon_path = AppendFileName(path, "icon16x16.png");
						tm = FileGetTime(icon_path);
						if(IsNull(tm)) // package icon does not exist
							d.icon = Null;
						else
						if(tm != d.itm) { // chached package icon outdated
							d.icon = StreamRaster::LoadFileAny(icon_path);
							d.itm = tm;
						}
					}
					ScanFolder(path, nest, d.nest, dir_exists, d.package + '/');
				}
				else
					nest.Unlink(i); // cached folder was deleted or is not in nest dir
			}
			nest.Sweep();
		}
	
		StoreToFile(data, cache_path);
		progress.Hide();
		while(IsSplashOpen())
			ProcessEvents();
		if(!IsOpen())
			Open();
		description.Show();
		if(loading) {
			loading = false;
			SyncList();
		}
	}
}
Example #10
0
VSIVirtualHandle *
VSIMemFilesystemHandler::Open( const char *pszFilename, 
                               const char *pszAccess )

{
    CPLMutexHolder oHolder( &hMutex );
    VSIMemFile *poFile;
    CPLString osFilename = pszFilename;
    NormalizePath( osFilename );

/* -------------------------------------------------------------------- */
/*      Get the filename we are opening, create if needed.              */
/* -------------------------------------------------------------------- */
    if( oFileList.find(osFilename) == oFileList.end() )
        poFile = NULL;
    else
        poFile = oFileList[osFilename];

    if( strstr(pszAccess,"w") == NULL && poFile == NULL )
    {
        errno = ENOENT;
        return NULL;
    }

    if( strstr(pszAccess,"w") )
    {
        if( poFile )
            poFile->SetLength( 0 );
        else
        {
            poFile = new VSIMemFile;
            poFile->osFilename = osFilename;
            oFileList[poFile->osFilename] = poFile;
            poFile->nRefCount++; // for file list
        }
    }

    if( poFile->bIsDirectory )
    {
        errno = EISDIR;
        return NULL;
    }

/* -------------------------------------------------------------------- */
/*      Setup the file handle on this file.                             */
/* -------------------------------------------------------------------- */
    VSIMemHandle *poHandle = new VSIMemHandle;

    poHandle->poFile = poFile;
    poHandle->nOffset = 0;
    if( strstr(pszAccess,"w") || strstr(pszAccess,"+") 
        || strstr(pszAccess,"a") )
        poHandle->bUpdate = TRUE;
    else
        poHandle->bUpdate = FALSE;

    poFile->nRefCount++;

    if( strstr(pszAccess,"a") )
        poHandle->nOffset = poFile->nLength;

    return poHandle;
}
Example #11
0
bool   PathIsEqual(const char *p1, const char *p2)
{
	return ToLower(NormalizePath(p1)) == ToLower(NormalizePath(p2));
}
Example #12
0
void PathFinder::BuildPointPath(const float* startPoint, const float* endPoint)
{
    float pathPoints[MAX_POINT_PATH_LENGTH * VERTEX_SIZE];
    uint32 pointCount = 0;
    dtStatus dtResult;

    if (m_useStraightPath)
    {
        dtResult = m_navMeshQuery->findStraightPath(
                       startPoint,         // start position
                       endPoint,           // end position
                       m_pathPolyRefs,     // current path
                       m_polyLength,       // lenth of current path
                       pathPoints,         // [out] path corner points
                       nullptr,               // [out] flags
                       nullptr,               // [out] shortened path
                       (int*)&pointCount,
                       m_pointPathLimit);   // maximum number of points/polygons to use
    }
    else
    {
        dtResult = findSmoothPath(
                       startPoint,         // start position
                       endPoint,           // end position
                       m_pathPolyRefs,     // current path
                       m_polyLength,       // length of current path
                       pathPoints,         // [out] path corner points
                       (int*)&pointCount,
                       m_pointPathLimit);    // maximum number of points
    }

    if (pointCount < 2 || dtStatusFailed(dtResult))
    {
        // only happens if pass bad data to findStraightPath or navmesh is broken
        // single point paths can be generated here
        // TODO : check the exact cases
        DEBUG_FILTER_LOG(LOG_FILTER_PATHFINDING, "++ PathFinder::BuildPointPath FAILED! path sized %d returned\n", pointCount);
        BuildShortcut();
        m_type = PATHFIND_NOPATH;
        return;
    }

    if (pointCount == m_pointPathLimit)
    {
        DEBUG_FILTER_LOG(LOG_FILTER_PATHFINDING, "++ PathFinder::BuildPointPath FAILED! path sized %d returned, lower than limit set to %d\n", pointCount, m_pointPathLimit);
        BuildShortcut();
        m_type = PATHFIND_SHORT;
        return;
    }

    if (pointCount > 2 && sWorld.getConfig(CONFIG_BOOL_PATH_FIND_OPTIMIZE))
    {
        uint32 tempPointCounter = 2;

        PointsArray tempPathPoints;
        tempPathPoints.resize(pointCount);

        for (uint32 i = 0; i < pointCount; ++i)      // y, z, x  expected here
        {
            uint32 pointPos = i * VERTEX_SIZE;
            tempPathPoints[i] = Vector3(pathPoints[pointPos + 2], pathPoints[pointPos], pathPoints[pointPos + 1]);
        }

        // Optimize points
        Vector3 emptyVec = { 0.0f, 0.0f, 0.0f };

        uint8 cutLimit = 0;
        for (uint32 i = 1; i < pointCount - 1; ++i)
        {
            G3D::Vector3 p  = tempPathPoints[i];     // Point
            G3D::Vector3 p1 = tempPathPoints[i - 1]; // PrevPoint
            G3D::Vector3 p2 = tempPathPoints[i + 1]; // NextPoint

            float lineLen = (p1.y - p2.y) * p.x + (p2.x - p1.x) * p.y + (p1.x * p2.y - p2.x * p1.y);

            if (fabs(lineLen) < LINE_FAULT && cutLimit < SKIP_POINT_LIMIT)
            {
                tempPathPoints[i] = emptyVec;
                cutLimit++;
            }
            else
            {
                tempPointCounter++;
                cutLimit = 0;
            }
        }

        m_pathPoints.resize(tempPointCounter);

        uint32 pointPos = 0;
        for (uint32 i = 0; i < pointCount; ++i)
        {
            if (tempPathPoints[i] != emptyVec)
            {
                m_pathPoints[pointPos] = tempPathPoints[i];
                pointPos++;
            }
        }

        pointCount = tempPointCounter;
    }
    else
    {
        m_pathPoints.resize(pointCount);
        for (uint32 i = 0; i < pointCount; ++i)
        {
            uint32 pointPos = i * VERTEX_SIZE;
            m_pathPoints[i] = { pathPoints[pointPos + 2], pathPoints[pointPos], pathPoints[pointPos + 1] };
        }
    }

    // first point is always our current location - we need the next one
    setActualEndPosition(m_pathPoints[pointCount - 1]);

    // force the given destination, if needed
    if (m_forceDestination &&
            (!(m_type & PATHFIND_NORMAL) || !inRange(getEndPosition(), getActualEndPosition(), 1.0f, 1.0f)))
    {
        // we may want to keep partial subpath
        if (dist3DSqr(getActualEndPosition(), getEndPosition()) < 0.3f * dist3DSqr(getStartPosition(), getEndPosition()))
        {
            setActualEndPosition(getEndPosition());
            m_pathPoints[m_pathPoints.size() - 1] = getEndPosition();
        }
        else
        {
            setActualEndPosition(getEndPosition());
            BuildShortcut();
        }

        m_type = PathType(PATHFIND_NORMAL | PATHFIND_NOT_USING_PATH);
    }

    NormalizePath();

    DEBUG_FILTER_LOG(LOG_FILTER_PATHFINDING, "++ PathFinder::BuildPointPath path type %d size %d poly-size %d\n", m_type, pointCount, m_polyLength);
}
Example #13
0
void Ide::FindInFiles(bool replace) {
	CodeEditor::FindReplaceData d = editor.GetFindReplaceData();
	CtrlRetriever rf;
	rf(ff.find, d.find)
	  (ff.replace, d.replace)
	  (ff.ignorecase, d.ignorecase)
	  (ff.samecase, d.samecase)
	  (ff.wholeword, d.wholeword)
	  (ff.wildcards, d.wildcards)
	  (ff.regexp, d.regexp)
	;
	WriteList(ff.find, d.find_list);
	WriteList(ff.replace, d.replace_list);
	ff.Sync();
	if(IsNull(~ff.folder))
		ff.folder <<= GetUppDir();
	ff.style <<= STYLE_NO_REPLACE;
	ff.Sync();
	ff.itext = editor.GetI();
	ff.Setup(replace);
	
	int c = ff.Execute();

	ff.find.AddHistory();
	ff.replace.AddHistory();

	rf.Retrieve();
	d.find_list = ReadList(ff.find);
	d.replace_list = ReadList(ff.replace);
	editor.SetFindReplaceData(d);
	
	if(c == IDOK) {
		ffound.HeaderTab(2).SetText("Source line");
		Renumber();
		ff.find.AddHistory();
		ff.files.AddHistory();
		ff.folder.AddHistory();
		ff.replace.AddHistory();
		Progress pi("Found %d files to search.");
		pi.AlignText(ALIGN_LEFT);
		Index<String> files;
		if(ff.workspace) {
			const Workspace& wspc = GetIdeWorkspace();
			for(int i = 0; i < wspc.GetCount(); i++)
				SearchForFiles(files, GetFileFolder(PackagePath(wspc[i])),
					           ~ff.files, ~ff.readonly, pi);
		}
		else
			SearchForFiles(files, NormalizePath(~~ff.folder, GetUppDir()), ~ff.files, ~ff.readonly, pi);
		if(!pi.Canceled()) {
			String pattern;
			RegExp rx, *regexp = NULL;
			if(ff.regexp) {
				rx.SetPattern(~ff.find);
				regexp = &rx;
				pattern = "dummy";
			}
			else
			if(ff.wildcards) {
				String q = ~ff.find;
				for(const char *s = q; *s; s++)
					if(*s == '\\') {
						s++;
						if(*s == '\0') break;
						pattern.Cat(*s);
					}
					else
					switch(*s) {
					case '*': pattern.Cat(WILDANY); break;
					case '?': pattern.Cat(WILDONE); break;
					case '%': pattern.Cat(WILDSPACE); break;
					case '#': pattern.Cat(WILDNUMBER); break;
					case '$': pattern.Cat(WILDID); break;
					default:  pattern.Cat(*s);
					}
			}
			else
				pattern = ~ff.find;
			pi.SetTotal(files.GetCount());
			ShowConsole2();
			ffound.Clear();
			pi.SetPos(0);
			int n = 0;
			for(int i = 0; i < files.GetCount(); i++) {
				pi.SetText(files[i]);
				if(pi.StepCanceled()) break;
				if(!IsNull(pattern)) {
					if(!SearchInFile(files[i], pattern, ff.wholeword, ff.ignorecase, n, regexp))
						break;
				}
				else {
					ErrorInfo f;
					f.file = files[i];
					f.lineno = 1;
					f.linepos = 0;
					f.kind = 0;
					f.message = files[i];
					ffound.Add(f.file, 1, f.message, RawToValue(f));
					ffound.Sync();
					n++;
				}
			}
			if(!IsNull(pattern))
				ffound.Add(Null, Null, AsString(n) + " occurrence(s) have been found.");
			else
				ffound.Add(Null, Null, AsString(n) + "  matching file(s) have been found.");
			ffound.HeaderTab(2).SetText(Format("Source line (%d)", ffound.GetCount()));
		}
	}
}
Example #14
0
HX_RESULT
CBaseArchiver2::InitTargetName(IHXRequest* pRequest)
{
    HXBOOL bAddExtension = TRUE;
    IHXBuffer* pFilePath = NULL;
    IHXBuffer* pFileName = NULL;
    IHXBuffer* pTempDirPath = NULL;
    HX_RESULT retVal = HXR_OK;

    // Get File Path (Archive Directory)
    if (SUCCEEDED(retVal))
    {
	retVal = m_pAdviser->GetPropertyCString("FilePath", 
						pFilePath);
    }

    if (SUCCEEDED(retVal))
    {
	char* pFilePathStr = (char*) pFilePath->GetBuffer();
	m_ArchiveDir = pFilePathStr;

	// Make sure the archive directory ends in a slash
	if ((m_ArchiveDir.GetLength() == 0) ||
	    ((m_ArchiveDir[m_ArchiveDir.GetLength() - 1] != '/') &&
	     (m_ArchiveDir[m_ArchiveDir.GetLength() - 1] != '\\')))
	{
	    m_ArchiveDir += '/';
	}
    }
    else
    {
	retVal = HXR_OK;    // File Path can be null;
    }
    
    // Get File Name
    if (SUCCEEDED(retVal))
    {
	retVal = m_pAdviser->GetPropertyCString("FileName", 
						pFileName);
	
    }

    if (SUCCEEDED(retVal))
    {
	char* pFileNameStr = (char*) pFileName->GetBuffer();
	m_BaseName = m_ArchiveDir + pFileNameStr;
    }

    // Try FullPath if FilePath and FileName not available
    if (FAILED(retVal))
    {
	IHXBuffer* pFilePathName = NULL;
	const char* pFilePathNameStr = NULL;
	char* pNameDelimiter = NULL;

	// Try from adviser first
	retVal = m_pAdviser->GetPropertyCString("FullPath", 
						pFilePathName);

	if (SUCCEEDED(retVal))
	{
	    pFilePathNameStr = (const char*) pFilePathName->GetBuffer();
	}
	else
	{   
	    // See if provided in request directly
	    if (pRequest)
	    {
		retVal = pRequest->GetURL(pFilePathNameStr);

		if (SUCCEEDED(retVal))
		{
		    if (pFilePathNameStr == NULL)
		    {
			retVal = HXR_FAIL;
		    }
		}
	    }
	}

	if (SUCCEEDED(retVal))
	{
	    char* pNameDelimiter2 = NULL;
	    
	    m_BaseName = pFilePathNameStr;
	    pNameDelimiter = (char *)strrchr(pFilePathNameStr, '/');
	    pNameDelimiter2 = (char *)strrchr(pFilePathNameStr, '\\');
	    
	    if (pNameDelimiter == NULL)
	    {
		pNameDelimiter = pNameDelimiter2;
	    }
	    else if (pNameDelimiter2 != NULL)
	    {
		if ((pNameDelimiter2 - pFilePathNameStr) >
		    (pNameDelimiter - pFilePathNameStr))
		{
		    pNameDelimiter = pNameDelimiter2;
		}
	    }
	    
	    if (pNameDelimiter != NULL)
	    {
		m_ArchiveDir = (const char*) m_BaseName;
		m_ArchiveDir.GetBufferSetLength(pNameDelimiter - 
						pFilePathNameStr + 1);
		m_FileName = (pNameDelimiter + 1);
	    }
	    else
	    {
		m_FileName = m_BaseName;
	    }
	}

	if (SUCCEEDED(retVal))
	{
	    const char* pExtension;    
	    
	    // See if extension is present
	    pExtension = strrchr(pFilePathNameStr, '.');
	    if (pExtension &&
		(pExtension != pFilePathNameStr) &&
		((pNameDelimiter == NULL) ||
		 (pExtension > pNameDelimiter)))
	    {
		m_AddOnExtension = pExtension;
		m_BaseName.GetBufferSetLength(pExtension - 
					      pFilePathNameStr);
		if (pNameDelimiter != NULL)
		{
		    m_FileName.GetBufferSetLength(pExtension - 
						  (pNameDelimiter + 1));
		}
		else
		{
		    m_FileName.GetBufferSetLength(pExtension - 
						  pFilePathNameStr);
		}

		bAddExtension = FALSE;
	    }
	}

	HX_RELEASE(pFilePathName);
    }

    if (SUCCEEDED(retVal) && (m_ProtocolName.GetLength() == 0))
    {
	IHXBuffer* pProtocolName = NULL;

	// Try to obtain protocol from the adviser
	retVal = m_pAdviser->GetPropertyCString("Protocol", 
						pProtocolName);

	if (SUCCEEDED(retVal))
	{
	    char* pProtocolNameStr = (char*) pProtocolName->GetBuffer();
	    m_ProtocolName = pProtocolNameStr;
	}

	HX_RELEASE(pProtocolName);

	retVal = HXR_OK;    // Some file system managers are not protocol driven
    }

    // See if a separate directory is to be used for temporary files
    if (SUCCEEDED(retVal))
    {
	retVal = m_pAdviser->GetPropertyCString("TempDirPath", 
						pTempDirPath);

	if (SUCCEEDED(retVal) && pTempDirPath)
	{
	    m_ArchiveDir = ((char*) pTempDirPath->GetBuffer());

	    // Make sure the archive directory ends in a slash
	    if ((m_ArchiveDir.GetLength() == 0) ||
		((m_ArchiveDir[m_ArchiveDir.GetLength() - 1] != OS_SEPARATOR_CHAR)))
	    {
		m_ArchiveDir += OS_SEPARATOR_CHAR;
	    }

	    m_bTempDirUsed = TRUE;
	}

	HX_RELEASE(pTempDirPath);

	retVal = HXR_OK;
    }

    // Form add-on file name extension if needed
    if (SUCCEEDED(retVal) && bAddExtension)
    {
	IHXBuffer* pExtensionBuffer = NULL;

	if (SUCCEEDED(m_pAdviser->GetPropertyCString("FileExtension",
						     pExtensionBuffer)) &&
	    pExtensionBuffer && 
	    pExtensionBuffer->GetBuffer())
	{
	    m_AddOnExtension = ((const char*) pExtensionBuffer->GetBuffer());
	}
	else
	{
	    m_AddOnExtension = ".rm";
	}

	HX_RELEASE(pExtensionBuffer);
    }

    if (SUCCEEDED(retVal))
    {
#ifdef _MACINTOSH
	// Convert legacy Mac-style paths to POSIX-style paths
	if (m_BaseName.Find('/') == -1)
	{
		CHXFileSpecifier fsBaseName = m_BaseName;
		m_BaseName = fsBaseName.GetPOSIXPath();
	}

	if (m_ArchiveDir.Find('/') == -1)
	{
		CHXFileSpecifier fsArchiveDir = m_ArchiveDir;
		m_ArchiveDir = fsArchiveDir.GetPOSIXPath();

	    if ((m_ArchiveDir.GetLength() == 0) ||
			((m_ArchiveDir[m_ArchiveDir.GetLength() - 1] != '/')))
	    {
			m_ArchiveDir += '/';
	    }
	}
#endif
    
	NormalizePath(&m_BaseName);
	NormalizePath(&m_ArchiveDir);
    }

    HX_RELEASE(pFileName);
    HX_RELEASE(pFilePath);

    return retVal;
}
Example #15
0
void PANEL_FP_LIB_TABLE::browseLibrariesHandler( wxCommandEvent& event )
{
    if( !m_cur_grid->CommitPendingChanges() )
        return;

    if( m_lastBrowseDir.IsEmpty() )
        m_lastBrowseDir = m_projectBasePath;

    DIALOG_FILE_DIR_PICKER dlg( this, _( "Select Library" ), m_lastBrowseDir,
                                getFilterString(), FD_MULTIPLE );

    auto result = dlg.ShowModal();

    if( result == wxID_CANCEL )
        return;

    m_lastBrowseDir = dlg.GetDirectory();

    // Drop the last directory if the path is a .pretty folder
    if( m_lastBrowseDir.EndsWith( KiCadFootprintLibPathExtension ) )
        m_lastBrowseDir = m_lastBrowseDir.BeforeLast( wxFileName::GetPathSeparator() );

    const ENV_VAR_MAP& envVars = Pgm().GetLocalEnvVariables();
    bool addDuplicates = false;
    bool applyToAll = false;
    wxString warning = _( "Warning: Duplicate Nickname" );
    wxString msg = _( "A library nicknamed \"%s\" already exists." );
    wxArrayString files;
    dlg.GetFilenames( files );

    for( const auto& filePath : files )
    {
        wxFileName fn( filePath );
        wxString nickname = LIB_ID::FixIllegalChars( fn.GetName(), LIB_ID::ID_PCB );
        bool doAdd = true;

        if( cur_model()->ContainsNickname( nickname ) )
        {
            if( !applyToAll )
            {
                int ret = YesOrCancelDialog( this, warning, wxString::Format( msg, nickname ),
                                             _( "Skip" ), _( "Add Anyway" ), &applyToAll );
                addDuplicates = (ret == wxID_CANCEL );
            }

            doAdd = addDuplicates;
        }

        if( doAdd && m_cur_grid->AppendRows( 1 ) )
        {
            int last_row = m_cur_grid->GetNumberRows() - 1;

            m_cur_grid->SetCellValue( last_row, COL_NICKNAME, nickname );

            auto type = IO_MGR::GuessPluginTypeFromLibPath( filePath );
            m_cur_grid->SetCellValue( last_row, COL_TYPE, IO_MGR::ShowType( type ) );

            // try to use path normalized to an environmental variable or project path
            wxString path = NormalizePath( filePath, &envVars, m_projectBasePath );

            if( path.IsEmpty() )
                path = fn.GetFullPath();

            m_cur_grid->SetCellValue( last_row, COL_URI, path );
        }
    }

    if( !files.IsEmpty() )
    {
        int new_row = m_cur_grid->GetNumberRows() - 1;
        m_cur_grid->MakeCellVisible( new_row, m_cur_grid->GetGridCursorCol() );
        m_cur_grid->SetGridCursor( new_row, m_cur_grid->GetGridCursorCol() );
    }
}
Example #16
0
wxString BuildConfig::GetOutputFileName() const { return NormalizePath(m_outputFile); }
Example #17
0
Vector<String> CppBuilder::CustomStep(const String& pf, const String& package_, bool& error)
{
	String package = Nvl(package_, mainpackage);
	String path = (*pf == '.' && pf[1] != '.') ? target : SourcePath(package, pf);
	String file = GetHostPath(path);
	String ext = ToLower(GetFileExt(pf));
	if(ext == ".ext") {
		Vector<String> files;
		Vector<String> dirs;
		sGatherAllExt(files, dirs, GetFileFolder(path), "");
		
		Index<String> pkg_files;
		Package pkg;
		pkg.Load(PackagePath(package));
		for(int i = 0; i < pkg.GetCount(); i++)
			pkg_files.Add(pkg[i]);
		
		Index<String> out;
		Index<String> include_path;
		String f = LoadFile(path);
		try {
			CParser p(f);
			while(!p.IsEof()) {
				if(p.Id("files")) {
					Vector<String> e = ReadPatterns(p);
					for(int i = 0; i < files.GetCount(); i++)
						for(int j = 0; j < e.GetCount(); j++) {
							String f = files[i];
							if(PatternMatch(e[j], f) && pkg_files.Find(f) < 0)
								out.FindAdd(f);
						}
				}
				if(p.Id("exclude")) {
					ExtExclude(p, out);
				}
				if(p.Id("include_path")) {
					Vector<String> e = ReadPatterns(p);
					for(int j = 0; j < e.GetCount(); j++) {
						String ee = e[j];
						if(ee.Find('*') >= 0)
							for(int i = 0; i < dirs.GetCount(); i++) {
								String d = dirs[i];
								if(PatternMatch(e[j], d)) {
									include_path.FindAdd(d);
								}
							}
						else
							include_path.Add(ee);
					}
				}
				if(p.Id("exclude_path")) {
					ExtExclude(p, include_path);
				}
				if(p.Id("includes")) {
					Vector<String> e = ReadPatterns(p);
					for(int i = 0; i < files.GetCount(); i++)
						for(int j = 0; j < e.GetCount(); j++) {
							String f = files[i];
							if(PatternMatch(e[j], f) && pkg_files.Find(f) < 0)
								include_path.FindAdd(GetFileFolder(f));
						}
				}
			}
		}
		catch(CParser::Error) {
			PutConsole("Invalid .ext file");
			error = true;
			return Vector<String>();
		}
		
		for(int i = 0; i < include_path.GetCount(); i++)
			include.Add(NormalizePath(include_path[i], GetFileFolder(path)));
		
		Vector<String> o;
		for(int i = 0; i < out.GetCount(); i++)
			o.Add(SourcePath(package, out[i]));
		return o;
	}
	for(int i = 0; i < wspc.GetCount(); i++) {
		const Array< ::CustomStep >& mv = wspc.GetPackage(i).custom;
		for(int j = 0; j < mv.GetCount(); j++) {
			const ::CustomStep& m = mv[j];
			if(MatchWhen(m.when, config.GetKeys()) && m.MatchExt(ext)) {
				VectorMap<String, String> mac;
				AddPath(mac, "PATH", file);
				AddPath(mac, "RELPATH", pf);
				AddPath(mac, "DIR", GetFileFolder(PackagePath(package)));
				AddPath(mac, "FILEDIR", GetFileFolder(file));
				AddPath(mac, "PACKAGE", package);
				mac.Add("FILE", GetFileName(file));
				mac.Add("TITLE", GetFileTitle(file));
				AddPath(mac, "EXEPATH", GetHostPath(target));
				AddPath(mac, "EXEDIR", GetHostPath(GetFileFolder(target)));
				mac.Add("EXEFILE", GetFileName(target));
				mac.Add("EXETITLE", GetFileTitle(target));
				AddPath(mac, "OUTDIR", GetHostPath(outdir));
				//BW
				AddPath(mac, "OUTDIR", GetHostPath(GetFileFolder(target)));
				AddPath(mac, "OUTFILE", GetHostPath(GetFileName(target)));
				AddPath(mac, "OUTTITLE", GetHostPath(GetFileTitle(target)));

				mac.Add("INCLUDE", Join(include, ";"));

				Vector<String> out = Cuprep(m.output, mac, include);
				bool dirty = out.IsEmpty();
				for(int i = 0; !dirty && i < out.GetCount(); i++)
					dirty = (GetFileTime(file) > GetFileTime(out[i]));
				if(dirty) {
					HdependTimeDirty();
					PutConsole(GetFileName(file));
					Vector<String> cmd = Cuprep(m.command, mac, include);
					String cmdtext;
					for(int c = 0; c < cmd.GetCount(); c++) {
						PutVerbose(cmd[c]);
						if(!Cd(cmd[c]) && !Cp(cmd[c], package, error)) {
							String ctext = cmd[c];
							const char *cm = ctext;
							if(*cm == '?')
								cm++;
							if(*ctext != '?' && Execute(cm)) {
								for(int t = 0; t < out.GetCount(); t++)
									DeleteFile(out[t]);
								PutConsole("FAILED: " + ctext);
								error = true;
								return Vector<String>();
							}
						}
					}
				}
				return out;
			}
		}
	}
	Vector<String> out;
	out.Add(path);
	return out;
}
Example #18
0
wxString BuildConfig::GetIntermediateDirectory() const { return NormalizePath(m_intermediateDirectory); }
Example #19
0
int
main(
	int argc,	/* Number of arguments */
	char *argv[])	/* Argument pointer list */
{
	extern int optind;
	char *cwd;
	int c, i;
	int errors = 0;

	/*
	 * Process arguments.
	 */
	CustmsgInit(0, NULL);
	program_name = basename(argv[0]);
	while ((c = getopt(argc, argv, "c:df:Vv")) != EOF) {
		switch (c) {
		case 'c':
			i = atoi(optarg);
			if (i < 1 || i > 4) {
				errors++;
				fprintf(stderr,
				    "%s: -c %s: invalid copy number\n",
				    program_name, optarg);
			}
			CopyMask |= 1<<(i-1);
			break;

		case 'd':
			Damaged = TRUE;
			break;

		case 'f':
			o_fname = optarg;
			o_fname_specified = TRUE;
			break;

		case 'V':
		case 'v':
			Verbose = TRUE;
			break;

		case '?':
		default:
			errors++;
		}
	}

	if (optind == argc)  errors++;	/* No root_path */
	if (errors != 0) {
		fprintf(stderr, catgets(catfd, SET, 13001, "Usage: %s %s\n"),
		    program_name,
		    "[-c copy_number]... [-f audit_file] [-V] root_path");
		return (ES_Args);
	}


	if (CopyMask == 0) CopyMask = 0xf;
			/* If no -c,interested in all copies */

	if ((cwd = getcwd(NULL, sizeof (fullpath)-1)) == NULL) {
		error(1, errno, catgets(catfd, SET, 587, "Cannot get cwd"));
	}
	/*
	 * Open the audit output file.  Rule is:
	 *    If -f not specified, or "-f -" specified, then use stdout
	 *    else use filename from -f argument.
	 */
	if (o_fname_specified && strcmp(o_fname, "-") != 0) {
		uid_t uid = getuid();
		gid_t gid = getgid();

		if ((*o_fname != '/') && (cwd != NULL)) {
			strncpy(fullpath, cwd, sizeof (fullpath)-1);
			strncat(fullpath, "/", sizeof (fullpath)-1);
		} else  *fullpath = '\0';
		strncat(fullpath, o_fname, sizeof (fullpath)-1);
		if (NormalizePath(fullpath) == NULL) {
			error(ES_OutputFile, 0,
			    catgets(catfd, SET, 1423,
			    "Invalid output file path"));
		}
		if ((o_st = FOPEN(fullpath, "a")) == NULL) {
			error(ES_OutputFile, errno,
			    catgets(catfd, SET, 574,
			    "Cannot create %s"), fullpath);
		}
		if (chown(fullpath, uid, gid) < 0) {
			error(0, errno,
			    catgets(catfd, SET, 573,
			    "Cannot chown %s"), fullpath);
			exit_status = ES_OutputFile;
		}
	} else {
		o_st = stdout;
	}


	/*
	 * Check the path to audit.
	 */
	if ((*argv[optind] != '/') && (cwd != NULL)) {
		strncpy(fullpath, cwd, sizeof (fullpath)-1);
		strncat(fullpath, "/", sizeof (fullpath)-1);
	} else  *fullpath = '\0';
	strncat(fullpath, argv[optind], sizeof (fullpath)-1);
	if (NormalizePath(fullpath) == NULL)
		error(ES_Path, 0, catgets(catfd, SET, 1425,
		    "Invalid path to audit"));
	if ((dir_buf = malloc(DIRBUF_SIZE)) == NULL) {
		error(ES_Malloc, errno,
		    catgets(catfd, SET, 1773,
		    "No memory for directory buffer %d"),
		    DIRBUF_SIZE);
	}
	if ((fs_fd = open(fullpath, O_RDONLY)) < 0) {
		error(ES_Path, errno,
		    catgets(catfd, SET, 613, "Cannot open %s"), fullpath);
	}
	/*LINTED pointer cast may result in improper alignment */
	getdent_s.dir.ptr = (struct sam_dirent *)dir_buf;

	/*
	 * Examine the audit path.
	 */
	base_name = fullpath;
	dodir(fullpath);
	if (o_st != stdout) fclose(o_st);

	if (Verbose)  ListVsns();

	if (seg_stat_buf) {
		free(seg_stat_buf);

		seg_stat_buf = (struct sam_stat *)NULL;
		seg_capacity = 0;
	}

	return (exit_status);
}
Example #20
0
wxString BuildConfig::GetWorkingDirectory() const { return NormalizePath(m_workingDirectory); }
Example #21
0
void PathGenerator::BuildPointPath(const float *startPoint, const float *endPoint)
{
    float pathPoints[MAX_POINT_PATH_LENGTH*VERTEX_SIZE];
    uint32 pointCount = 0;
    dtStatus dtResult = DT_FAILURE;
    if (_useStraightPath)
    {
        dtResult = _navMeshQuery->findStraightPath(
                startPoint,         // start position
                endPoint,           // end position
                _pathPolyRefs,     // current path
                _polyLength,       // lenth of current path
                pathPoints,         // [out] path corner points
                NULL,               // [out] flags
                NULL,               // [out] shortened path
                (int*)&pointCount,
                _pointPathLimit);   // maximum number of points/polygons to use
    }
    else
    {
        dtResult = FindSmoothPath(
                startPoint,         // start position
                endPoint,           // end position
                _pathPolyRefs,     // current path
                _polyLength,       // length of current path
                pathPoints,         // [out] path corner points
                (int*)&pointCount,
                _pointPathLimit);    // maximum number of points
    }

    if (pointCount < 2 || dtStatusFailed(dtResult))
    {
        // only happens if pass bad data to findStraightPath or navmesh is broken
        // single point paths can be generated here
        /// @todo check the exact cases
        TC_LOG_DEBUG(LOG_FILTER_MAPS, "++ PathGenerator::BuildPointPath FAILED! path sized %d returned\n", pointCount);
        BuildShortcut();
        _type = PATHFIND_NOPATH;
        return;
    }
    else if (pointCount == _pointPathLimit)
    {
        TC_LOG_DEBUG(LOG_FILTER_MAPS, "++ PathGenerator::BuildPointPath FAILED! path sized %d returned, lower than limit set to %d\n", pointCount, _pointPathLimit);
        BuildShortcut();
        _type = PATHFIND_SHORT;
        return;
    }

    _pathPoints.resize(pointCount);
    for (uint32 i = 0; i < pointCount; ++i)
        _pathPoints[i] = G3D::Vector3(pathPoints[i*VERTEX_SIZE+2], pathPoints[i*VERTEX_SIZE], pathPoints[i*VERTEX_SIZE+1]);

    NormalizePath();

    // first point is always our current location - we need the next one
    SetActualEndPosition(_pathPoints[pointCount-1]);

    // force the given destination, if needed
    if (_forceDestination &&
        (!(_type & PATHFIND_NORMAL) || !InRange(GetEndPosition(), GetActualEndPosition(), 1.0f, 1.0f)))
    {
        // we may want to keep partial subpath
        if (Dist3DSqr(GetActualEndPosition(), GetEndPosition()) < 0.3f * Dist3DSqr(GetStartPosition(), GetEndPosition()))
        {
            SetActualEndPosition(GetEndPosition());
            _pathPoints[_pathPoints.size()-1] = GetEndPosition();
        }
        else
        {
            SetActualEndPosition(GetEndPosition());
            BuildShortcut();
        }

        _type = PathType(PATHFIND_NORMAL | PATHFIND_NOT_USING_PATH);
    }

    TC_LOG_DEBUG(LOG_FILTER_MAPS, "++ PathGenerator::BuildPointPath path type %d size %d poly-size %d\n", _type, pointCount, _polyLength);
}
Example #22
0
int ArcCommand::ReplaceVar(char *Command,int &Length)
{
  char Chr=Command[2]&(~0x20);
  if (Command[0]!='%' || Command[1]!='%' || Chr < 'A' || Chr > 'Z')
    return FALSE;
  char SaveStr[MAX_COMMAND_LENGTH],LocalAllFilesMask[NM];
  int QuoteName=0,UseSlash=FALSE,FolderMask=FALSE,FolderName=FALSE;
  int NameOnly=FALSE,PathOnly=FALSE,AnsiCode=FALSE;
  int MaxNamesLength=127;

  int VarLength=3;

  lstrcpy(LocalAllFilesMask,AllFilesMask);

  while (1)
  {
    int BreakScan=FALSE;
    Chr=Command[VarLength];
    if (Command[2]=='F' && Chr >= '0' && Chr <= '9')
    {
      MaxNamesLength=FSF.atoi(&Command[VarLength]);
      while (Chr >= '0' && Chr <= '9')
        Chr=Command[++VarLength];
      continue;
    }
    if (Command[2]=='E' && Chr >= '0' && Chr <= '9')
    {
      MaxAllowedExitCode=FSF.atoi(&Command[VarLength]);
      while (Chr >= '0' && Chr <= '9')
        Chr=Command[++VarLength];
      continue;
    }
    switch(Command[VarLength])
    {
      case 'A':
        AnsiCode=TRUE;
        break;
      case 'Q':
        QuoteName=1;
        break;
      case 'q':
        QuoteName=2;
        break;
      case 'S':
        UseSlash=TRUE;
        break;
      case 'M':
        FolderMask=TRUE;
        break;
      case 'N':
        FolderName=TRUE;
        break;
      case 'W':
        NameOnly=TRUE;
        break;
      case 'P':
        PathOnly=TRUE;
        break;
      case '*':
        lstrcpy(LocalAllFilesMask,"*");
        break;
      default:
        BreakScan=TRUE;
        break;
    }
    if (BreakScan)
      break;
    VarLength++;
  }
  if ((MaxNamesLength-=Length)<=0)
    MaxNamesLength=1;
  if (MaxNamesLength>MAX_COMMAND_LENGTH-512)
    MaxNamesLength=MAX_COMMAND_LENGTH-512;
  if (FolderMask==FALSE && FolderName==FALSE)
    FolderName=TRUE;
  lstrcpy(SaveStr,Command+VarLength);
  switch(Command[2])
  {
    case 'A':
      lstrcpy(Command,ArcName);
      if (AnsiCode)
        OemToChar(Command,Command);
      if (PathOnly)
      {
        char *NamePtr=(char *)FSF.PointToName(Command);
        if (NamePtr!=Command)
          *(NamePtr-1)=0;
        else
          lstrcpy(Command," ");
      }
      FSF.QuoteSpaceOnly(Command);
      break;
    case 'a':
      {
        int Dot=strchr(FSF.PointToName(ArcName),'.')!=NULL;
        ConvertNameToShort(ArcName,Command);
        char *Slash=strrchr(ArcName,'\\');
        if (GetFileAttributes(ArcName)==0xFFFFFFFF && Slash!=NULL && Slash!=ArcName)
        {
          char Path[NM];
          lstrcpy(Path,ArcName);
          Path[Slash-ArcName]=0;
          ConvertNameToShort(Path,Command);
          lstrcat(Command,Slash);
        }
        if (Dot && strchr(FSF.PointToName(Command),'.')==NULL)
          lstrcat(Command,".");
        if (AnsiCode)
          OemToChar(Command,Command);
        if (PathOnly)
        {
          char *NamePtr=(char *)FSF.PointToName(Command);
          if (NamePtr!=Command)
            *(NamePtr-1)=0;
          else
            lstrcpy(Command," ");
        }
      }
      FSF.QuoteSpaceOnly(Command);
      break;
    case 'D':
      *Command=0;
      break;
    case 'E':
      *Command=0;
      break;
    case 'l':
    case 'L':
      if (!MakeListFile(ListFileName,Command[2]=='l',QuoteName,UseSlash,
                        FolderName,NameOnly,PathOnly,FolderMask,
                        LocalAllFilesMask,AnsiCode))
        return -1;
      char QListName[NM+2];
      FSF.QuoteSpaceOnly(lstrcpy(QListName,ListFileName));
      lstrcpy(Command,QListName);
      break;
    case 'P':
      lstrcpy(Command,Password);
      break;
    case 'C':
      if(*CommentFileName) //второй раз сюда не лезем
        break;
      {
        *Command=0;

        HANDLE CommentFile;
        //char CommentFileName[MAX_PATH];
        char Buf[512];
        SECURITY_ATTRIBUTES sa;

        sa.nLength=sizeof(sa);
        sa.lpSecurityDescriptor=NULL;
        sa.bInheritHandle=TRUE;

        if(FSF.MkTemp(CommentFileName, "FAR") &&
          (CommentFile=CreateFile(CommentFileName, GENERIC_WRITE,
                       FILE_SHARE_READ|FILE_SHARE_WRITE, &sa, CREATE_ALWAYS,
                       /*FILE_ATTRIBUTE_TEMPORARY|*//*FILE_FLAG_DELETE_ON_CLOSE*/0, NULL))
                       != INVALID_HANDLE_VALUE)
        {
          DWORD Count;
          if(Info.InputBox(GetMsg(MComment), GetMsg(MInputComment), NULL, "", Buf, sizeof(Buf), NULL, 0))
          //??тут можно и заполнить строку комментарием, но надо знать, файловый
          //?? он или архивный. да и имя файла в архиве тоже надо знать...
          {
            WriteFile(CommentFile, Buf, lstrlen(Buf), &Count, NULL);
            lstrcpy(Command, CommentFileName);
            CloseHandle(CommentFile);
          }
          FlushConsoleInputBuffer(GetStdHandle(STD_INPUT_HANDLE));
        }
      }
      break;
    case 'R':
      lstrcpy(Command,RealArcDir);
      if (UseSlash)
      {
        for (int I=0;Command[I];I++)
          if (Command[I]=='\\')
//            Command[I]='//';
/* $ 28.11.2000 AS
*/
            Command[I]='/';
/* AS $*/
      }
      FSF.QuoteSpaceOnly(Command);
      break;
    case 'W':
      lstrcpy(Command,TempPath);
      break;
    case 'f':
    case 'F':
      if (PanelItem!=NULL)
      {
        char CurArcDir[NM];
        lstrcpy(CurArcDir,ArcDir);
        int Length=lstrlen(CurArcDir);
        if (Length>0 && CurArcDir[Length-1]!='\\')
          lstrcat(CurArcDir,"\\");

        char Names[MAX_COMMAND_LENGTH];
        *Names=0;

        if (NameNumber==-1)
          NameNumber=0;

        while (NameNumber<ItemsNumber || Command[2]=='f')
        {
          char Name[NM*2];

          int IncreaseNumber=0,FileAttr;
          if (*NextFileName)
          {
            FSF.sprintf(Name,"%s%s%s",PrefixFileName,CurArcDir,NextFileName);
            *NextFileName=0;
            FileAttr=0;
          }
          else
          {
            int N;
            if (Command[2]=='f' && PrevFileNameNumber!=-1)
              N=PrevFileNameNumber;
            else
            {
              N=NameNumber;
              IncreaseNumber=1;
            }
            if (N>=ItemsNumber)
              break;

            *PrefixFileName=0;
            char *cFileName=PanelItem[N].FindData.cFileName;

            if(PanelItem[N].UserData && (PanelItem[N].Flags & PPIF_USERDATA))
            {
              struct ArcItemUserData *aud=(struct ArcItemUserData*)PanelItem[N].UserData;
              if(aud->SizeStruct == sizeof(struct ArcItemUserData))
              {
                if(aud->Prefix)
                  lstrcpyn(PrefixFileName,aud->Prefix,sizeof(PrefixFileName));
                if(aud->LinkName)
                  cFileName=aud->LinkName;
              }
            }
            // CHECK for BUGS!!
            if(*cFileName == '\\' || *cFileName == '/')
              FSF.sprintf(Name,"%s%s",PrefixFileName,cFileName+1);
            else
              FSF.sprintf(Name,"%s%s%s",PrefixFileName,CurArcDir,cFileName);
            NormalizePath(Name,Name);
            FileAttr=PanelItem[N].FindData.dwFileAttributes;
            PrevFileNameNumber=N;
          }
          if (AnsiCode)
            OemToChar(Name,Name);
          if (NameOnly)
          {
            char NewName[NM];
            lstrcpy(NewName,FSF.PointToName(Name));
            lstrcpy(Name,NewName);
          }
          if (PathOnly)
          {
            char *NamePtr=(char *)FSF.PointToName(Name);
            if (NamePtr!=Name)
              *(NamePtr-1)=0;
            else
              lstrcpy(Name," ");
          }
          if (*Names==0 || (lstrlen(Names)+lstrlen(Name)<MaxNamesLength && Command[2]!='f'))
          {
            NameNumber+=IncreaseNumber;
            if (FileAttr & FILE_ATTRIBUTE_DIRECTORY)
            {
              char FolderMaskName[NM];
              //lstrcpy(LocalAllFilesMask,PrefixFileName);
              FSF.sprintf(FolderMaskName,"%s\\%s",Name,LocalAllFilesMask);
              if (PathOnly)
              {
                lstrcpy(FolderMaskName,Name);
                char *NamePtr=(char *)FSF.PointToName(FolderMaskName);
                if (NamePtr!=FolderMaskName)
                  *(NamePtr-1)=0;
                else
                  lstrcpy(FolderMaskName," ");
              }
              if (FolderMask)
              {
                if (FolderName)
                  lstrcpy(NextFileName,FolderMaskName);
                else
                  lstrcpy(Name,FolderMaskName);
              }
            }

            if (QuoteName==1)
              FSF.QuoteSpaceOnly(Name);
            else
              if (QuoteName==2)
                QuoteText(Name);
            if (UseSlash)
              for (int I=0;Name[I];I++)
                if (Name[I]=='\\')
//                  Name[I]='//';
/* $ 28.11.2000 AS
*/
                  Name[I]='/';
/* AS $*/


            if (*Names)
              lstrcat(Names," ");
            lstrcat(Names,Name);
          }
          else
            break;
        }
        lstrcpy(Command,Names);
      }
      else
        *Command=0;
      break;
    default:
      return FALSE;
  }
  Length=lstrlen(Command);
  lstrcat(Command,SaveStr);
  return TRUE;
}
RageFileObj *RageFileManager::OpenForWriting( CString sPath, int mode, RageFile &p, int &err )
{
	LockMut( *g_Mutex );

	/*
	 * The value for a driver to open a file is the number of directories and/or files
	 * that would have to be created in order to write it, or 0 if the file already exists.
	 * For example, if we're opening "foo/bar/baz.txt", and only "foo/" exists in a
	 * driver, we'd have to create the "bar" directory and the "baz.txt" file, so the
	 * value is 2.  If "foo/bar/" exists, we'd only have to create the file, so the
	 * value is 1.  Create the file with the driver that returns the lowest value;
	 * in case of a tie, earliest-loaded driver wins.
	 *
	 * The purpose of this is to create files in the expected place.  For example, if we
	 * have both C:/games/StepMania and C:/games/DWI loaded, and we're writing
	 * "Songs/Music/Waltz/waltz.sm", and the song was loaded out of
	 * "C:/games/DWI/Songs/Music/Waltz/waltz.dwi", we want to write the new SM into the
	 * same directory (if possible).  Don't split up files in the same directory any
	 * more than we have to.
	 *
	 * If the given path can not be created, return -1.  This happens if a path
	 * that needs to be a directory is a file, or vice versa.
	 */
	NormalizePath( sPath );

	vector< pair<int,int> > Values;
	unsigned i;
	for( i = 0; i < g_Drivers.size(); ++i )
	{
		LoadedDriver &ld = g_Drivers[i];
		const CString path = ld.GetPath( sPath );
		if( path.size() == 0 )
			continue;

		const int value = ld.driver->GetPathValue( path );
		if( value == -1 )
			continue;

		Values.push_back( pair<int,int>( i, value ) );
	}

	stable_sort( Values.begin(), Values.end(), SortBySecond );

	err = 0;
	for( i = 0; i < Values.size(); ++i )
	{
		const int driver = Values[i].first;
		LoadedDriver &ld = g_Drivers[driver];
		const CString path = ld.GetPath( sPath );
		ASSERT( path.size() );

		int error;
		RageFileObj *ret = ld.driver->Open( path, mode, p, error );
		if( ret )
		{
			AddReference( ret, ld.driver );
			return ret;
		}

		/* The drivers are in order of priority; if they all return error, return the
		 * first.  Never return ERROR_WRITING_NOT_SUPPORTED. */
		if( !err && error != RageFileDriver::ERROR_WRITING_NOT_SUPPORTED )
			err = error;
	}

	if( !err )
		err = EEXIST; /* no driver could write */

	return NULL;
}
Example #24
0
int ArcCommand::MakeListFile(char *ListFileName,int ShortNames,int QuoteName,
                int UseSlash,int FolderName,int NameOnly,int PathOnly,
                int FolderMask,char *LocalAllFilesMask,int AnsiCode)
{
//  FILE *ListFile;
  HANDLE ListFile;
  DWORD WriteSize;
  SECURITY_ATTRIBUTES sa;

  sa.nLength=sizeof(sa);
  sa.lpSecurityDescriptor=NULL;
  sa.bInheritHandle=TRUE;

  if (FSF.MkTemp(ListFileName,"FAR")==NULL ||
     (ListFile=CreateFile(ListFileName,GENERIC_WRITE,
                   FILE_SHARE_READ|FILE_SHARE_WRITE,
                   &sa,CREATE_ALWAYS,
                   FILE_FLAG_SEQUENTIAL_SCAN,NULL)) == INVALID_HANDLE_VALUE)

  {
    if(!Silent)
    {
      char NameMsg[NM];
      const char *MsgItems[]={GetMsg(MError),GetMsg(MCannotCreateListFile),NameMsg,GetMsg(MOk)};
      FSF.TruncPathStr(lstrcpyn(NameMsg,ListFileName,sizeof(NameMsg)),MAX_WIDTH_MESSAGE);
      Info.Message(Info.ModuleNumber,FMSG_WARNING,NULL,MsgItems,ARRAYSIZE(MsgItems),1);
    }
/* $ 25.07.2001 AA
    if(ListFile != INVALID_HANDLE_VALUE)
      CloseHandle(ListFile);
25.07.2001 AA $*/
    return FALSE;
  }

  char CurArcDir[NM];
  char Buf[3*NM];

  if(NameOnly)
    *CurArcDir=0;
  else
    lstrcpy( CurArcDir, ArcDir );

  int Length=lstrlen(CurArcDir);
  if (Length>0 && CurArcDir[Length-1]!='\\')
    lstrcat(CurArcDir,"\\");

  if (UseSlash)
    for (int I=0;CurArcDir[I];I++)
      if (CurArcDir[I]=='\\')
//        CurArcDir[I]='//';
        CurArcDir[I]='/';

  for (int I=0;I<ItemsNumber;I++)
  {
    char FileName[NM];
    if (ShortNames && *PanelItem[I].FindData.cAlternateFileName)
      lstrcpy(FileName,PanelItem[I].FindData.cAlternateFileName);
    else
      lstrcpy(FileName,PanelItem[I].FindData.cFileName);
    if (NameOnly)
    {
      char NewName[NM];
      lstrcpy(NewName,FSF.PointToName(FileName));
      lstrcpy(FileName,NewName);
    }
    if (PathOnly)
    {
      char *Ptr=(char*)FSF.PointToName(FileName);
      *Ptr=0;
    }
    int FileAttr=PanelItem[I].FindData.dwFileAttributes;

    *PrefixFileName=0;
    if(PanelItem[I].UserData && (PanelItem[I].Flags & PPIF_USERDATA))
    {
      struct ArcItemUserData *aud=(struct ArcItemUserData*)PanelItem[I].UserData;
      if(aud->SizeStruct == sizeof(struct ArcItemUserData))
      {
        if(aud->Prefix)
          lstrcpyn(PrefixFileName,aud->Prefix,sizeof(PrefixFileName));
        if(aud->LinkName)
           lstrcpyn(FileName,aud->LinkName,sizeof(FileName));
      }
    }

    int Error=FALSE;
    if (((FileAttr & FILE_ATTRIBUTE_DIRECTORY)==0 || FolderName))
    {
      char OutName[NM];
      // CHECK for BUGS!!
      if(*FileName == '\\' || *FileName == '/')
        FSF.sprintf(OutName,"%s%s",PrefixFileName,FileName+1);
      else
        FSF.sprintf(OutName,"%s%s%s",PrefixFileName,CurArcDir,FileName);
      NormalizePath(OutName,OutName);
      if (QuoteName==1)
        FSF.QuoteSpaceOnly(OutName);
      else
        if (QuoteName==2)
          QuoteText(OutName);
      if (AnsiCode)
        OemToChar(OutName,OutName);

      lstrcpy(Buf,OutName);lstrcat(Buf,"\r\n");
      Error=WriteFile(ListFile,Buf,lstrlen(Buf),&WriteSize,NULL) == FALSE;
      //Error=fwrite(Buf,1,lstrlen(Buf),ListFile) != lstrlen(Buf);
    }
    if (!Error && (FileAttr & FILE_ATTRIBUTE_DIRECTORY) && FolderMask)
    {
      char OutName[NM];
      FSF.sprintf(OutName,"%s%s%s%c%s",PrefixFileName,CurArcDir,FileName,UseSlash ? '/':'\\',LocalAllFilesMask);
      if (QuoteName==1)
        FSF.QuoteSpaceOnly(OutName);
      else
        if (QuoteName==2)
          QuoteText(OutName);
      if (AnsiCode)
        OemToChar(OutName,OutName);
      lstrcpy(Buf,OutName);lstrcat(Buf,"\r\n");
      Error=WriteFile(ListFile,Buf,lstrlen(Buf),&WriteSize,NULL) == FALSE;
      //Error=fwrite(Buf,1,lstrlen(Buf),ListFile) != lstrlen(Buf);
    }
    if (Error)
    {
      CloseHandle(ListFile);
      DeleteFile(ListFileName);
      if(!Silent)
      {
        const char *MsgItems[]={GetMsg(MError),GetMsg(MCannotCreateListFile),GetMsg(MOk)};
        Info.Message(Info.ModuleNumber,FMSG_WARNING,NULL,MsgItems,ARRAYSIZE(MsgItems),1);
      }
      return FALSE;
    }
  }

  CloseHandle(ListFile);
/*
  if (!CloseHandle(ListFile))
  {
    // clearerr(ListFile);
    CloseHandle(ListFile);
    DeleteFile(ListFileName);
    if(!Silent)
    {
      char *MsgItems[]={GetMsg(MError),GetMsg(MCannotCreateListFile),GetMsg(MOk)};
      Info.Message(Info.ModuleNumber,FMSG_WARNING,NULL,MsgItems,ARRAYSIZE(MsgItems),1);
    }
    return FALSE;
  }
*/
  return TRUE;
}
Example #25
0
void PathGenerator::BuildPointPath(const float *startPoint, const float *endPoint)
{
    float pathPoints[MAX_POINT_PATH_LENGTH*VERTEX_SIZE];
    uint32 pointCount = 0;
    dtStatus dtResult = DT_FAILURE;
    if (_useStraightPath)
    {
        dtResult = _navMeshQuery->findStraightPath(
                startPoint,         // start position
                endPoint,           // end position
                _pathPolyRefs,     // current path
                _polyLength,       // lenth of current path
                pathPoints,         // [out] path corner points
                NULL,               // [out] flags
                NULL,               // [out] shortened path
                (int*)&pointCount,
                _pointPathLimit);   // maximum number of points/polygons to use
    }
    else
    {
        dtResult = FindSmoothPath(
                startPoint,         // start position
                endPoint,           // end position
                _pathPolyRefs,     // current path
                _polyLength,       // length of current path
                pathPoints,         // [out] path corner points
                (int*)&pointCount,
                _pointPathLimit);    // maximum number of points
    }

    if (pointCount < 2 || dtStatusFailed(dtResult))
    {
        // only happens if pass bad data to findStraightPath or navmesh is broken
        // single point paths can be generated here
        /// @todo check the exact cases
        TC_LOG_DEBUG(LOG_FILTER_MAPS, "++ PathGenerator::BuildPointPath FAILED! path sized %d returned\n", pointCount);
        BuildShortcut();
        _type = PATHFIND_NOPATH;
        return;
    }
    else if (pointCount == _pointPathLimit)
    {
        TC_LOG_DEBUG(LOG_FILTER_MAPS, "++ PathGenerator::BuildPointPath FAILED! path sized %d returned, lower than limit set to %d\n", pointCount, _pointPathLimit);
        BuildShortcut();
        _type = PATHFIND_SHORT;
        return;
    }

    _pathPoints.resize(pointCount);
    for (uint32 i = 0; i < pointCount; ++i)
        _pathPoints[i] = G3D::Vector3(pathPoints[i*VERTEX_SIZE+2], pathPoints[i*VERTEX_SIZE], pathPoints[i*VERTEX_SIZE+1]);

    NormalizePath();

    // first point is always our current location - we need the next one
    SetActualEndPosition(_pathPoints[pointCount-1]);

    // force the given destination, if needed
    if (_forceDestination &&
        (!(_type & PATHFIND_NORMAL) || !InRange(GetEndPosition(), GetActualEndPosition(), 1.0f, 1.0f)))
    {
        // we may want to keep partial subpath
        if (Dist3DSqr(GetActualEndPosition(), GetEndPosition()) < 0.3f * Dist3DSqr(GetStartPosition(), GetEndPosition()))
        {
            SetActualEndPosition(GetEndPosition());
            _pathPoints[_pathPoints.size()-1] = GetEndPosition();
        }
        else
        {
            SetActualEndPosition(GetEndPosition());
            BuildShortcut();
        }

        _type = PathType(PATHFIND_NORMAL | PATHFIND_NOT_USING_PATH);
    }

    // Custom Point for Bugged Zone (By Quentis)
    float startEndDist = Dist3DSqr(GetStartPosition(), GetEndPosition());

    // Blade's Edge Arena
    if (_sourceUnit->GetMapId() == 562)
    {
        // Your Position & Target Position
        if (endPoint[1] >= 9.000000f && startPoint[1] >= 9.000000f && endPoint[2] <= 6233.953223f && endPoint[2] >= 6223.140430f && endPoint[0] >= 246.160000f && endPoint[0] <= 256.818940f) // southeast pillar
        {
            // Path X,y,z 1# END
            Clear();
            _pathPoints.resize(4);
            _pathPoints[0] = GetStartPosition();
            _pathPoints[1] = G3D::Vector3(6236.567836f, 258.339106f, 11.500018f);
            _pathPoints[2] = G3D::Vector3(6229.818836f, 252.049106f, 11.500018f);
            _pathPoints[3] = GetEndPosition();
        }
        else if (startEndDist < 3000.0f && startPoint[1] >= 9.000000f && endPoint[1] >= 9.000000f && startPoint[2] <= 6233.953223f && startPoint[2] >= 6223.440430f && startPoint[0] >= 246.060000f && startPoint[0] <= 256.818940f) // southeast pillar
        {
             // Path X,y,z 1# Start
             Clear();
             _polyLength = 4;
             _pathPoints.resize(4);
             _pathPoints[0] = GetStartPosition();
             _pathPoints[1] = G3D::Vector3(6229.818836f, 252.049106f, 11.500018f);
             _pathPoints[2] = G3D::Vector3(6236.567836f, 258.339106f, 11.500018f);
             _pathPoints[3] = GetEndPosition();
        }
        else if (startEndDist < 3000.0f && startPoint[1] >= 9.000000f && startPoint[2] >= 6242.185660f && startPoint[2] <= 6254.611660f && startPoint[0] >= 266.757917f && startPoint[0] <= 279.558794f) // northwest pillar
        {
             // Path X,y,z 2# Start
             Clear();
             _pathPoints.resize(5);
             _pathPoints[0] = GetStartPosition();
             _pathPoints[1] = G3D::Vector3(6246.324219f, 271.570000f, 11.300000f);
             _pathPoints[2] = G3D::Vector3(6242.942484f, 267.210030f, 11.280000f);
             _pathPoints[3] = G3D::Vector3(6241.539484f, 265.441030f, 11.280000f);
             _pathPoints[4] = GetEndPosition();
        }
        else if (startEndDist < 3000.0f && endPoint[1] >= 9.000000f && endPoint[2] >= 6242.185660f && endPoint[2] <= 6254.611660f && endPoint[0] >= 266.757917f && endPoint[0] <= 279.558794f) // northwest pillar
        {
             // Path X,y,z 2# END
             Clear();
             _pathPoints.resize(5);
             _pathPoints[0] = GetStartPosition();
             _pathPoints[1] = G3D::Vector3(6241.539484f, 265.441030f, 11.280000f);
             _pathPoints[2] = G3D::Vector3(6242.942484f, 267.210030f, 11.280000f);
             _pathPoints[3] = G3D::Vector3(6246.324219f, 271.570000f, 11.300000f);
             _pathPoints[4] = GetEndPosition();
        }
    }
    // Dalaran Sewers
    else if (_sourceUnit->GetMapId() == 617)
    {
         if (startEndDist < 2500.0f && startPoint[2] >= 1325.033223f && startPoint[1] >= 9.000000f) // Canal 1#
         {
             // Path X,y,z
             Clear();
             _pathPoints.resize(5);
             _pathPoints[0] = GetStartPosition();
             _pathPoints[1] = G3D::Vector3(1332.749268f, 816.274780f, 8.355900f);
             _pathPoints[2] = G3D::Vector3(1325.749268f, 816.602539f, 5.4000000f);
             _pathPoints[3] = G3D::Vector3(1328.749268f, 816.602539f, 3.4000000f);
             _pathPoints[4] = GetEndPosition();
         }
         else if (startEndDist < 2500.0f && startPoint[2] <= 1253.904785f && startPoint[1] >= 9.000000f) // Canal 2#
         {
             // Path X,y,z
             Clear();
             _pathPoints.resize(5);
             _pathPoints[0] = GetStartPosition();
             _pathPoints[1] = G3D::Vector3(1252.425395f, 764.971680f, 8.000000f);
             _pathPoints[3] = G3D::Vector3(1255.425395f, 764.971680f, 5.3559000f);
             _pathPoints[3] = G3D::Vector3(1257.425395f, 764.971680f, 3.3559000f);
             _pathPoints[4] = GetEndPosition();
         }
    }
    // Eye of the Storm
    else if (_sourceUnit->GetMapId() == 566)
    {
         if (startEndDist < 2500.0f && startPoint[2] <= 1850.003223f && startPoint[1] >= 1237.000000f && startPoint[0] >= 1501.420000f && startPoint[0] <= 1579.960000f) // StartZone Horde
         {
             // Path X,y,z
             Clear();
             _pathPoints.resize(5);
             _pathPoints[0] = GetStartPosition();
             _pathPoints[1] = G3D::Vector3(1847.004468f, 1540.660539f, 1243.400000f);
             _pathPoints[2] = G3D::Vector3(1842.883268f, 1527.123839f, 1238.410000f);
             _pathPoints[3] = G3D::Vector3(1839.593268f, 1519.479539f, 1229.428000f);
             _pathPoints[4] = GetEndPosition();
         }
         if (startEndDist < 2500.0f && startPoint[2] >= 2484.003223f && startPoint[1] >= 1240.000000f && startPoint[0] >= 1567.420000f && startPoint[0] <= 1626.960000f) // StartZone Alliance
         {
             // Path X,y,z
             Clear();
             _pathPoints.resize(5);
             _pathPoints[0] = GetStartPosition();
             _pathPoints[1] = G3D::Vector3(2485.154468f, 1596.583439f, 1244.898315f);
             _pathPoints[2] = G3D::Vector3(2482.733268f, 1608.305649f, 1238.092000f);
             _pathPoints[3] = G3D::Vector3(2488.073268f, 1623.749539f, 1227.788000f);
             _pathPoints[4] = GetEndPosition();
         }
    }
    // Custom Point for Bugged Zone 

    TC_LOG_DEBUG(LOG_FILTER_MAPS, "++ PathGenerator::BuildPointPath path type %d size %d poly-size %d\n", _type, pointCount, _polyLength);
}
Example #26
0
String SourcePath(const String& package, const String& file) {
	if(IsFullPath(file)) return NativePath(file);
	return NormalizePath(AppendFileName(GetFileFolder(PackagePath(package)), file));
}
Example #27
0
std::string RealPath(const char* path)
{
  std::string s = Sys::JoinPath(CurrentDir().c_str(), path);
  return NormalizePath(s.c_str());
}
Example #28
0
bool Ide::CanToggleReadOnly()
{
	return NormalizePath(GetActiveFilePath()) == NormalizePath(editfile);
}
Example #29
0
int ArcCommand::ReplaceVar(std::string &Command)
{
  int MaxNamesLength = 0x10000;
  std::string LocalAllFilesMask = AllFilesMask;
  bool UseSlash = false;
  bool FolderMask = false;
  bool FolderName = false;
  bool NameOnly = false;
  bool PathOnly = false;
  int QuoteName = 0;

  if (Command.size() < 3)
    return 0;

  char Chr = Command[2] & (~0x20);
  if (Command[0] != '%' || Command[1] != '%' || Chr < 'A' || Chr > 'Z')
    return 0;

  int VarLength = 3;

  while (VarLength < Command.size())
  {
    bool BreakScan = false;
    Chr = Command[VarLength];
    if (Command[2]=='F' && Chr >= '0' && Chr <= '9')
    {
      MaxNamesLength = FSF.atoi(Command.c_str() + VarLength);
      while (Chr >= '0' && Chr <= '9' && VarLength < Command.size())
        Chr = Command[++VarLength];
      continue;
    }
    if (Command[2]=='E' && Chr >= '0' && Chr <= '9')
    {
      MaxAllowedExitCode = FSF.atoi(Command.c_str() + VarLength);
      while (Chr >= '0' && Chr <= '9' && VarLength < Command.size())
        Chr=Command[++VarLength];
      continue;
    }
    switch (Command[VarLength])
    {
      case 'A': break; /* deprecated AnsiCode = true; */
      case 'Q': QuoteName = 1; break;
      case 'q': QuoteName = 2; break;
      case 'S': UseSlash = true; break;
      case 'M': FolderMask = true; break;
      case 'N': FolderName = true; break;
      case 'W': NameOnly = true; break;
      case 'P': PathOnly = true; break;
      case '*': LocalAllFilesMask = "*"; break;
      default: BreakScan = true;
    }
    if (BreakScan)
      break;
    VarLength++;
  }

  if ( (MaxNamesLength-=(int)Command.size()) <= 0)
    MaxNamesLength = 1;

  if (!FolderMask && !FolderName)
    FolderName = true;

/////////////////////////////////
  switch (Command[2])
  {
    case 'A': case 'a': /* deprecated: short name - works same as normal name */
      Command = ArcName;
      if (PathOnly)
        CutToPathOrSpace(Command);
      QuoteCmdArgIfNeed(Command);
      break;

    case 'D': case 'E':
      Command.clear();
      break;

    case 'L': case 'l':
      if (!MakeListFile(ListFileName, QuoteName, UseSlash, FolderName,
         NameOnly, PathOnly, FolderMask, LocalAllFilesMask.c_str())) {
        return -1;
      }
      Command = ListFileName;
      QuoteCmdArgIfNeed(Command);
      break;

    case 'P':
      Command = Password;
      break;

    case 'C':
      if (*CommentFileName) //второй раз сюда не лезем
        break;
      {
        Command.clear();
        int CommentFile;
        if (FSF.MkTemp(CommentFileName, "FAR") && (CommentFile =
          sdc_open(CommentFileName, O_CREAT | O_TRUNC | O_RDWR, 0660)) != -1)
        {
          char Buf[512];
          if(Info.InputBox(GetMsg(MComment), GetMsg(MInputComment), NULL, "", Buf, sizeof(Buf), NULL, 0))
          //??тут можно и заполнить строку комментарием, но надо знать, файловый
          //?? он или архивный. да и имя файла в архиве тоже надо знать...
          {
            sdc_write(CommentFile, Buf, strlen(Buf));
            sdc_close(CommentFile);
            Command = CommentFileName;
          }
          WINPORT(FlushConsoleInputBuffer)(NULL);//GetStdHandle(STD_INPUT_HANDLE));
        }
      }
      break;

    case 'r':
      Command = RealArcDir;
      if (!Command.empty())
        Command+= '/';
      break;
    case 'R':
      Command = RealArcDir;
      if (UseSlash)
      {
      }
      QuoteCmdArgIfNeed(Command);
      break;

    case 'W':
      Command = TempPath;
      break;

    case 'F': case 'f':
      if (PanelItem!=NULL)
      {
        std::string CurArcDir = ArcDir;
        if (!CurArcDir.empty() && CurArcDir[CurArcDir.size() - 1] != GOOD_SLASH)
          CurArcDir+= GOOD_SLASH;

        std::string Names, Name;

        if (NameNumber == -1)
          NameNumber = 0;

        while (NameNumber < ItemsNumber || Command[2] == 'f')
        {
          int IncreaseNumber = 0;
          DWORD FileAttr;
          if (!NextFileName.empty())
          {
            Name = PrefixFileName;
            Name+= CurArcDir;
            Name+= NextFileName;
            NextFileName.clear();
            FileAttr = 0;
          }
          else
          {
            int N;
            if (Command[2]=='f' && PrevFileNameNumber!=-1)
              N = PrevFileNameNumber;
            else
            {
              N = NameNumber;
              IncreaseNumber=1;
            }
            if (N >= ItemsNumber)
              break;

            *PrefixFileName=0;
            char *cFileName = PanelItem[N].FindData.cFileName;

            if(PanelItem[N].UserData && (PanelItem[N].Flags & PPIF_USERDATA))
            {
              struct ArcItemUserData *aud=(struct ArcItemUserData*)PanelItem[N].UserData;
              if(aud->SizeStruct == sizeof(struct ArcItemUserData))
              {
                if(aud->Prefix)
                  strncpy(PrefixFileName,aud->Prefix,sizeof(PrefixFileName));
                if(aud->LinkName)
                  cFileName=aud->LinkName;
              }
            }
            // CHECK for BUGS!!
            Name = PrefixFileName;
            if(*cFileName != GOOD_SLASH)
            {
              Name+= CurArcDir;
              Name+= cFileName;
            }
            else
              Name+= cFileName+1;
            NormalizePath(Name);
            FileAttr = PanelItem[N].FindData.dwFileAttributes;
            PrevFileNameNumber = N;
          }
          if (NameOnly)
          {
            size_t slash = Name.rfind(GOOD_SLASH);
            if (slash != std::string::npos)
              Name.erase(0, slash + 1);
          }
          if (PathOnly)
            CutToPathOrSpace(Name);
          if (Names.empty() || (Names.size() + Name.size() < MaxNamesLength && Command[2] != 'f'))
          {
            NameNumber+= IncreaseNumber;
            if (FileAttr & FILE_ATTRIBUTE_DIRECTORY)
            {
              std::string FolderMaskName = Name;
              if (!PathOnly)
              {
                FolderMaskName+= GOOD_SLASH;
                FolderMaskName+= LocalAllFilesMask;
              }
              else
                CutToPathOrSpace(FolderMaskName);
              if (FolderMask)
              {
                if (FolderName)
                  NextFileName.swap(FolderMaskName);
                else
                  Name.swap(FolderMaskName);
              }
            }

            if (QuoteName==1)
              QuoteCmdArgIfNeed(Name);
            else if (QuoteName==2)
              QuoteCmdArg(Name);

            if (!Names.empty())
              Names+= ' ';
            Names+= Name;
          }
          else
            break;
        }
        Command.swap(Names);
      }
      else
        Command.clear();
      break;
    default:
      return 0;
  }

  return VarLength;
}
void ClassBrowser::OnTreeItemDoubleClick(wxTreeEvent& event)
{
    wxTreeCtrl* wx_tree = (wxTreeCtrl*)event.GetEventObject();
    if (!wx_tree || !m_Parser)
        return;

    wxTreeItemId id = event.GetItem();
    CCTreeCtrlData* ctd = (CCTreeCtrlData*)wx_tree->GetItemData(id);
    if (ctd && ctd->m_Token)
    {
        if (wxGetKeyState(WXK_CONTROL) && wxGetKeyState(WXK_SHIFT))
        {
//            TokenTree* tree = m_Parser->GetTokenTree(); // the one used inside CCDebugInfo

            CC_LOCKER_TRACK_TT_MTX_LOCK(s_TokenTreeMutex)

            CCDebugInfo info(wx_tree, m_Parser, ctd->m_Token);
            info.ShowModal();

            CC_LOCKER_TRACK_TT_MTX_UNLOCK(s_TokenTreeMutex)

            return;
        }

        bool toImp = false;
        switch (ctd->m_Token->m_TokenKind)
        {
            case tkConstructor:
            case tkDestructor:
            case tkFunction:
                if (ctd->m_Token->m_ImplLine != 0 && !ctd->m_Token->GetImplFilename().IsEmpty())
                    toImp = true;
                break;
            case tkNamespace:
            case tkClass:
            case tkEnum:
            case tkTypedef:
            case tkVariable:
            case tkEnumerator:
            case tkMacroDef:
            case tkMacroUse:
            case tkAnyContainer:
            case tkAnyFunction:
            case tkUndefined:
            default:
                break;
        }

        wxFileName fname;
        if (toImp)
            fname.Assign(ctd->m_Token->GetImplFilename());
        else
            fname.Assign(ctd->m_Token->GetFilename());

        cbProject* project = nullptr;
        if (!m_NativeParser->IsParserPerWorkspace())
            project = m_NativeParser->GetProjectByParser(m_Parser);
        else
            project = m_NativeParser->GetCurrentProject();

        wxString base;
        if (project)
        {
            base = project->GetBasePath();
            NormalizePath(fname, base);
        }
        else
        {
            const wxArrayString& incDirs = m_Parser->GetIncludeDirs();
            for (size_t i = 0; i < incDirs.GetCount(); ++i)
            {
                if (NormalizePath(fname, incDirs.Item(i)))
                    break;
            }
        }

        cbEditor* ed = Manager::Get()->GetEditorManager()->Open(fname.GetFullPath());
        if (ed)
        {
            int line;
            if (toImp)
                line = ctd->m_Token->m_ImplLine - 1;
            else
                line = ctd->m_Token->m_Line - 1;

            ed->GotoTokenPosition(line, ctd->m_Token->m_Name);
        }
    }