ExePath in 0.90.0 still omits trailing backslash (Win)

For other topics related to the FreeBASIC project or its community.
MrSwiss
Posts: 3305
Joined: Jun 02, 2013 9:27
Location: Switzerland

ExePath in 0.90.0 still omits trailing backslash (Win)

Postby MrSwiss » Jul 05, 2013 12:05

Hi all,
in the release note of 0.90.0 it says that this issue is fixed now. A test of mine on a Win8 pro 64bit machine shows, that it is still the same as in 0.24.0. Is this a Win only problem or does it also appear in DOS/LINUX?
TJF
Posts: 3486
Joined: Dec 06, 2009 22:27
Location: N47°, E15°
Contact:

Re: ExePath in 0.90.0 still omits trailing backslash (Win)

Postby TJF » Jul 05, 2013 12:21

There has never been a trailing backslash on neither platform. "Fixing" (changing) this will break a lot of existing code.
MrSwiss
Posts: 3305
Joined: Jun 02, 2013 9:27
Location: Switzerland

Re: ExePath in 0.90.0 still omits trailing backslash (Win)

Postby MrSwiss » Jul 05, 2013 12:40

@TJF,
you are right on "breaking existing code", but ... dkl wrote under the title "Most intresting (?) fixes" at:http://www.freebasic.net/forum/viewtopic.php?f=1&t=21321 that ExePath now "no longer omits ..." ?!?
This beeing the reason for me to post it here.
counting_pine
Site Admin
Posts: 6173
Joined: Jul 05, 2005 17:32
Location: Manchester, Lancs

Re: ExePath in 0.90.0 still omits trailing backslash (Win)

Postby counting_pine » Jul 05, 2013 13:15

The thread behind this issue is at viewtopic.php?p=186402#p186402. The trailing slash should be added only for root paths, eg 'C:\' or '/'.
TJF
Posts: 3486
Joined: Dec 06, 2009 22:27
Location: N47°, E15°
Contact:

Re: ExePath in 0.90.0 still omits trailing backslash (Win)

Postby TJF » Jul 05, 2013 17:03

What is a root path under UNIX? An empty path?
dkl
Site Admin
Posts: 3210
Joined: Jul 28, 2005 14:45
Location: Germany

Re: ExePath in 0.90.0 still omits trailing backslash (Win)

Postby dkl » Jul 05, 2013 19:21

For Unix it should be "/", I think it'd be bad to return an empty string there. For DOS/Win32 "C:" and "C:\" should both be ok in theory.
nobozoz
Posts: 238
Joined: Nov 17, 2005 6:24
Location: Chino Hills, CA, USA

Re: ExePath in 0.90.0 still omits trailing backslash (Win)

Postby nobozoz » Jul 06, 2013 5:36

In WINxp, the COMMAND.COM console (MS-DOS Version 5.00.500) allows either "C:\" or "C:" while the CMD.EXE console (Microsoft Windows XP [Version 5.1.2600]) only permits "C:".

There may be other subtle differences, I just know about these.

jim
monochromator
Posts: 42
Joined: Mar 05, 2013 5:37

Re: ExePath in 0.90.0 still omits trailing backslash (Win)

Postby monochromator » Jul 06, 2013 6:52

All file functions of the language have to work in uniform style. As a standard it is reasonable to take the CURDIR$ function. And it returns "C:\", but not "C:", and not only in "FreeBASIC", but also in "QuickBASIC".
MrSwiss
Posts: 3305
Joined: Jun 02, 2013 9:27
Location: Switzerland

Re: ExePath in 0.90.0 still omits trailing backslash (Win)

Postby MrSwiss » Jul 06, 2013 9:29

Hi all,
monochromator wrote:"... a standard it is reasonable to take the CURDIR$ function ..."
I strongly object the notion to use anything NOT lang "fb" to be referred to "as standard", because it is "depreciated".
That said, I'd like to give my opinion on the issue as follows:
- On Linux it should return "/", returning 'empy' string seems to indicate an error.
- On DOS/Windows it should stay the 0.24.0 'way' (NEVER return trailing bachslash),
otherwise it might break code (or at least leads to more complex code), which nobody wants:

Code: Select all

function getExePath () as string
  dim as string TmpStrg = ExePath + "\"
  Function = TmpStrg
end function

This would have to be extended with additional ROOT-CHECKING, in order to cover all possible cases ...
fxm
Posts: 9256
Joined: Apr 22, 2009 12:46
Location: Paris suburbs, FRANCE

Re: ExePath in 0.90.0 still omits trailing backslash (Win)

Postby fxm » Jul 06, 2013 9:37

'C:' represents/defines only the disk whatever the directory path, while in addition 'C:\' the full path (the C disk root).
MrSwiss
Posts: 3305
Joined: Jun 02, 2013 9:27
Location: Switzerland

Re: ExePath in 0.90.0 still omits trailing backslash (Win)

Postby MrSwiss » Jul 06, 2013 9:51

fxm wrote:'C:' represents/defines only the disk whatever the directory path, while in addition 'C:\' the full path (the C disk root).

Just to cut a long story short: IMHO either return it "ALLWAYS" or "NEVER" but don't mix.

BTW: X: does not necessarily have to be a Disk (on Win at least), it might as well be a virtual drive\path assignment pointing to any chosen place ...
monochromator
Posts: 42
Joined: Mar 05, 2013 5:37

Re: ExePath in 0.90.0 still omits trailing backslash (Win)

Postby monochromator » Jul 06, 2013 10:06

fxm tries to explain to you that routes with first slash and without have different value. Routes "dir1\dir2" and "\dir1\di2" are different routes. The first of them is set from current directory, and the second is set from root directory. There is silly thing to designate different things in one word.
Therefore, if we refer to the root directory, the correct version should be just "C: \" and a last slash there should be present, as it is, in fact, represents root directory.
If we refer to a non-root directory, then a slash in his end should not be, because it is totally meaningless there.
Last edited by monochromator on Jul 06, 2013 10:38, edited 1 time in total.
MrSwiss
Posts: 3305
Joined: Jun 02, 2013 9:27
Location: Switzerland

Re: ExePath in 0.90.0 still omits trailing backslash (Win)

Postby MrSwiss » Jul 06, 2013 10:19

I'm well aware of that fact (absolute vs. relative).
X:\MyDir\anything ... is ambigous, because 'anything' can be 'DIR' or 'FILE'
X:\MyDir\anything\ ... here 'anything' is definitely a 'DIR'
monochromator
Posts: 42
Joined: Mar 05, 2013 5:37

Re: ExePath in 0.90.0 still omits trailing backslash (Win)

Postby monochromator » Jul 06, 2013 10:31

In all modern file systems directory is just a special type of file. It differs from a conventional file with only special attribute. And it is completely logical that it is called the same way as ordinary files.
FreeBASIC shouldn't invent own approaches to file system, and has to follow the principles contained in operating systems.
marcov
Posts: 2793
Joined: Jun 16, 2005 9:45
Location: Eindhoven, NL
Contact:

Re: ExePath in 0.90.0 still omits trailing backslash (Win)

Postby marcov » Jul 06, 2013 12:25

dkl wrote:For Unix it should be "/", I think it'd be bad to return an empty string there. For DOS/Win32 "C:" and "C:\" should both be ok in theory.


Isn't C: ambiguous? It usually means "the working dir on drive C:".

Return to “Community Discussion”

Who is online

Users browsing this forum: No registered users and 1 guest