Skip to content
GitLab
    • GitLab: the DevOps platform
    • Explore GitLab
    • Install GitLab
    • How GitLab compares
    • Get started
    • GitLab docs
    • GitLab Learn
  • Pricing
  • Talk to an expert
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
    • Switch to GitLab Next
    Projects Groups Topics Snippets
  • Register
  • Sign in
  • FPC Source FPC Source
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributor statistics
    • Graph
    • Compare revisions
    • Locked files
  • Issues 1,404
    • Issues 1,404
    • List
    • Boards
    • Service Desk
    • Milestones
    • Iterations
  • Merge requests 67
    • Merge requests 67
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Artifacts
    • Schedules
    • Test cases
  • Deployments
    • Deployments
    • Releases
  • Packages and registries
    • Packages and registries
    • Package Registry
    • Container Registry
    • Infrastructure Registry
  • External wiki
    • External wiki
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • FPC
  • FPCFPC
  • FPC SourceFPC Source
  • Issues
  • #19282
Closed
Open
Issue created May 03, 2011 by FPC Admin account@fpc_adminOwner

Proposing PathFileSearch: like FileSeach, working correctly for $PATH

Original Reporter info from Mantis: Michalis @michaliskambi
  • Reporter name: Michalis Kamburelis

Description:

As explained in #19279 (closed), the FileSearch is not the correct way on Windows to search for files on $PATH. If the FileSearch cannot be modified, I propose to add a new function designed specifically for this :) (My reasoning for pushing this is that I think it's common to want to search on $PATH, so I would like to see a correct utility for this in RTL.)

I attach a simple implementation. This is based on FileSearch implementation, adding a small piece of code to remove double quotes around. (A shorter and cleaner implementation, preprocessing the path removing double quotes, and then calling FileSearch, is possible --- but it would be slower.)

Suggested place to put it is inside rtl/objpas/sysutils/sysutils.inc, right beside FileSearch implementation.

Note that there are some places in FPC RTL when we search the environment variable $PATH, using FileSearch (or ExeSearch, which is just a wrapper around FileSearch). They could be changed to use PathFileSearch for clarity. Although they are not for Windows platform --- so they may stay using FileSearch / ExeSearch as well.

./rtl/qnx/system.pp:165: fstr:=filesearch(strpas(argv[0]), getenv('PATH'));
./src/unix/process.inc:306: FoundName := ExeSearch(Pname,fpgetenv('PATH'));

There's also one place in Lazarus where they use FileSearchUTF8 in the same maner, I guess they should fix it the same way (by introducing PathFileSearchUTF8):

./components/datadict/reglazdatadict.pp:84: Result:=FileSearchUTF8(LazDataDesktop,GetEnvironmentVariableUTF8('PATH'));

Mantis conversion info:

  • Mantis ID: 19282
  • Fixed in version: 2.6.0
  • Fixed in revision: 17717 (#6b42ee69).
  • Target version: 2.6.0
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information
Assignee
Assign to
Time tracking