Is '/' necessary in the starting of a pathname? - pathname

What is the difference between these two pathnames? Is / necessary to put in start for going in a folder?
assets/myImg.png
/assets/myImg.png

/assets/myImg.png is an absolute path. It means no matter where do you call the path from it's always the same. assets/myImg.png is relative path to your current directory

You haven't mentioned an OS, so given the leading / I'll assume we're on a Unix-like system.
/assets/myImg.png
This is an absolute path. It's going to look in the root directory of your file system for a folder called assets and go from there.
assets/myImg.png
This is a relative path. It's going to look in the current working directory, which is likely the directory where you started your current program. If you're using this from the command line, it's going to look starting from the current directory of the shell (i.e. the thing you change with cd).

Related

How to prevent local msmpi installation from loading system wide msmpi.dll

I'm writing a console app for windows that sets up an environment and launches (popen) various hpc-apps using msmpi mpiexec.exe.
I have an msmpi installation installed locally to the application I'm writing. All works fine and parallel processing is OK.
However, as soon as I happen to have a system installation of msmpi as well (as installed by e.g. msmpisetup.exe), my applications stubbornly loads the Windows/system32/msmpi.dll instead of the msmpi.dll that I point at using PATH. Since the system msmpi.dll is of a different version, my apps does not run.
The PATH env.var. is set within my app, and it is apparently inherited correctly by the child processes, including mpiexec.
The only remedy I've found is to either (1) Rename system32/msmpi.dll or (2) place a copy of "my" msmpi.dll into every folder in which I have a parallel executable. Both remedies are... not nice.
How can I prevent my apps from selecting the system32/msmpi.dll and use the instance that's in the PATH instead??
Thank you for any advice.
N
The standard DLL search order in Windows is documented to be
The directory from which the application loaded.
The system directory. Use the GetSystemDirectory function to get the path of this directory.
The 16-bit system directory. There is no function that obtains the path of this directory, but it is searched.
The Windows directory. Use the GetWindowsDirectory function to get the path of this directory.
The current directory.
The directories that are listed in the PATH environment variable. Note that this does not include the per-application path specified by the App Paths registry key. The App Paths key is not used when computing the DLL search path.
If you want your application to check a specific location first before using the system locations, you can call SetDllDirectory in the parent application before letting it execute other binaries that require a particular DLL.

save path in database / or \

I want to save the path of an image in my database. I'm developing on a Windows system.
I'm using
setDestination( APPLICATION_PATH . "/userfiles/")
In my database I have a path like the following:
C:\wamp\www\cheyenne\application/userfiles\test...
If I try to use a relative path like \public\covers I get an error like "path or directory does not exist".
I'd prefer the 2nd possibility because the former webserver will be an Apache on a Linux.
It's not a good idea to store in a database the complete path of your picture. You really should consider to use a relative path and build the complete path on render, with a database view... My point of view is that you can or not know where your application will be and how your application will be deploy.
For example, today, you store your image on the same server, tomorow, because of traffic issues, you move all your pictures on a second server dedicated for pictures... if you store the complete path of your pictures, you have to execute a SQL request to change partial path and update your code. If you have juste a relative path, you just have to change your application configuration. This can be done in a config.local file that override your default configuration.
For the backslash... it's normal, you are on Windows. Use on your code the default php global variable DIRECTORY_SEPARATOR instead of "/".

Rikulo stream base folder

Is it possible to choose to serve files only from a specific folder using Rikulo stream? I've tried
new StreamServer(uriMapping: _mapping, homeDir: 'my/web/webapp/app')
but I'm not getting the desired results as it's still serving files under the 'web' directory.
When homeDir is specified with a relative path, it is assumed to be relative to the current directory (Directory.current.path). I think it is not what you expect. You can use an absolute path for better control.
After examining the code, I think the relative path is better to base on the root directory rather than the current directory. Please follow Issue 29 for details. Also refer to the sample app here.

Conflict between relative and absolute path while using two exe file in delphi

I have one exe say myApp.exe in C:\MyProject folder. It writes logs in logfile say tracefile.log which is also there in C:\MyProject.
Now I have to make a schedule task say Schedule1.exe which will also write in logfile tracefile.log located in C:\MyProject.
Ok, I created Schedule1.exe and kept it in same folder C:\MyProject folder and made schedule taks using this exe.
Problem: Schedule1.exe cannot pick the path of logfile when I give relative path of logfile as ".\tracefile.log". But when I give full path like "C:\MyProject", it picks the logfile path and writes on it.
Please suggest what could be the problem?
Relative paths are relative to the working directory of the process. The working directory of the process is determined at process startup, and may not be the directory that contains the executable. What's more, the working directory can change during the processes life.
It seems to me that you should be giving a full path to these files. You need to get hold of the directory in which the executable lives. That is
ExtractFilePath(ParamStr(0));
So you should be using this code to name your file:
ExtractFilePath(ParamStr(0)) + 'tracefile.log'

What's the differences between images/ and ./images/?

In fact, it seems to start both from the current page path.
Its a subtle one which is only relevant if multiple search paths exist (like for executables, see $PATH).
For example, you can start a local executable with ./filename, but not with filename, as the latter makes (most?) shells search in the paths specified by $PATH and not the current working directory.
In a context of URLs, there is no real difference. One should note though, that relative paths are a common attack vector on web applications (escaping the DocumentRoot using ../).
For directories one would imagine nothing. The PATH variable would not come into the picture as a directory is not a command the shell needs to search.
On the side note here is an interesting page to know more about "./" : http://www.linfo.org/dot_slash.html

Resources