Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW
 
PerlMonks  

Re: standard library to return system paths

by Don Coyote (Hermit)
on Jun 07, 2016 at 06:12 UTC ( [id://1165030]=note: print w/replies, xml ) Need Help??


in reply to standard library to return system paths

Hello igoryonya

Can you clarify which paths you intend to Find? Standard paths will vary on an application by application basis.

Standard paths for a nix could be found by readdir('/'), which is what I understand by your question. Or grep a self-created list against File::Find

You may also need to ensure you have permission to read the directories on either system, Errors can be generated if you do not have said permissions.

Not knowing the paths you are looking for, you could use Find::lib module, that iirc will return the absolute filepath for the currently running program, from which you can use relative links within your program rather than trying to discern and hard-code standard paths for many different machines.


less roam; more sell.

Replies are listed 'Best First'.
Re^2: standard library to return system paths
by igoryonya (Pilgrim) on Jun 07, 2016 at 06:27 UTC
    Like I said:

    libdir
    progdir
    confdir
    homedir
    userdir

    It varies not by application, but by OS. For example:

    libdir: win(c:\program files\common files); lin(/lib)
    progdir: win(c:\program files); lin(/bin)
    confdir: win(c:\programdata); lin(/etc)
    homedir: win(c:\users); lin(/home)
    userdir: win(c:\users\user); lin(/home/user)
    etc..., etc..., etc...

      Maybe see File::HomeDir.

      Note that on Windows, C:\Program Files is not universal - it might localized to the language that Windows was installed to.

      There is no universal idea of where libraries get installed to, even on Linuxish OSes, you might have /lib, /usr/lib and /lib64.

      Maybe you will get better answers if you can tell us what exact problem you are trying to solve.

        > "Note that on Windows, C:\Program Files is not universal - it might localized to the language that Windows was installed to."

        Yes, that's why I was looking for a lib, that find such dirs, depending, on what OS, the perl program is launched.

        Unfortunately, File::HomeDir is not a standard module. It's not helping.
        It's like a catch 22, I order to run a program with libraries, I need to be able to tell my program to tell, where those libraries are. In order to tell, where the libraries are, I have to tell load a library, that can tell it. That's why I need a module, or a variable, that's is standard on perl distros.

      There may be some useful modules with your purpose in mind, here:

      Cpan search: Find::lib

      There is likely to be something there which will be able to help you, or can be modified to spec. hth

        I need a standard module, because it's like a catch 22, I order to run a program with libraries, I need to be able to tell my program to tell, where those libraries are. In order to tell, where the libraries are, I have to tell load a library, that can tell it. That's why I need a module, or a variable, that's is standard on perl distros.
Re^2: standard library to return system paths
by igoryonya (Pilgrim) on Jul 11, 2016 at 19:30 UTC
    the end

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1165030]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others about the Monastery: (3)
As of 2024-04-25 17:37 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found