Page 1 of 2

Bug in CurrentDir() or possibly GetCurrentDirName() ?

Posted: Fri Sep 23, 2011 1:40 pm
by ChrisH
Can someone please confirm that the following behaviour is not intended, and is in fact a bug in AmigaOS4.1:

If I perform CurrentDir(lock) using a lock on 'Volume:Folder', then GetCurrentDirName() unexpectedly still shows the old (unchanged) current directory. This looks like a bug to me.

But if I perform SetCurrentDirName('Volume:Folder'), and it returns success, then as expected GetCurrentDirName() shows 'Volume:Folder' as the current directory.

Re: Bug in CurrentDir() or possibly GetCurrentDirName() ?

Posted: Fri Sep 23, 2011 1:48 pm
by ChrisH
When using CurrentDir(), I can find out the correct current directory by giving myProcess.pr_CurrentDir to NameFromLock(). So I am inclined to say that GetCurrentDirName() is somehow buggy.

Re: Bug in CurrentDir() or possibly GetCurrentDirName() ?

Posted: Fri Sep 23, 2011 6:46 pm
by xenic
@ChrisH
I threw together a quick shell program to test GetCurrentDirName() and it does appear to get the wrong name.
NameFromLock confirms that problem is not CurrentDir(). The dos AutoDocs proclaim GetCurrentDirName() as having bugs but doesn't mention the bug you have found. This is bad news for programs that aren't expecting this bug and it would be advisable to use the alternative function call suggested in the dos AutoDocs; even though it would be for reasons other than the ones stated in the AutoDocs. This might explain why some programs don't find the files they are looking for unless the files are in the current directory.

Re: Bug in CurrentDir() or possibly GetCurrentDirName() ?

Posted: Fri Sep 23, 2011 8:04 pm
by ChrisH
@xenic
Thanks for confirming this is the wrong behaviour, and for duplicating it. I will create a bug report for it (as none seems to exist).

Re: Bug in CurrentDir() or possibly GetCurrentDirName() ?

Posted: Sat Sep 24, 2011 4:05 pm
by ChrisH
@xenic
At appears that the behaviour I saw is NOT a bug, rather due to my not understanding a quirk on AmigaDOS's design. However, I am still not entirely sure I understand why (I think there are two different "Current Directories"!) so I won't post more until I understand for sure.

Re: Bug in CurrentDir() or possibly GetCurrentDirName() ?

Posted: Sun Sep 25, 2011 3:59 am
by xenic
ChrisH wrote:At appears that the behaviour I saw is NOT a bug, rather due to my not understanding a quirk on AmigaDOS's design. However, I am still not entirely sure I understand why (I think there are two different "Current Directories"!) so I won't post more until I understand for sure.
I think somebody is blowing hot air up your sleeve because by definition there can only be one "current" directory. Current means the present moment and directory is singular not plural (directories). Maybe in a parallel universe your Amiga has another current directory but not in this one :-)

Re: Bug in CurrentDir() or possibly GetCurrentDirName() ?

Posted: Sun Sep 25, 2011 6:15 am
by ssolie
xenic wrote:I think somebody is blowing hot air up your sleeve because by definition there can only be one "current" directory.
I think the guy who rewrote most of dos.library knows a tad more than you do... ;-)

Re: Bug in CurrentDir() or possibly GetCurrentDirName() ?

Posted: Sun Sep 25, 2011 12:09 pm
by chris
ChrisH wrote:Can someone please confirm that the following behaviour is not intended, and is in fact a bug in AmigaOS4.1:

If I perform CurrentDir(lock) using a lock on 'Volume:Folder', then GetCurrentDirName() unexpectedly still shows the old (unchanged) current directory. This looks like a bug to me.

But if I perform SetCurrentDirName('Volume:Folder'), and it returns success, then as expected GetCurrentDirName() shows 'Volume:Folder' as the current directory.
Reading the Autodoc, I would avoid GetCurrentDirName(). It appears to only exist for legacy reasons - it even says that it is better to use GetCurrentDir/NameFromLock! It ought to be marked as DEPRECATED.

Re: Bug in CurrentDir() or possibly GetCurrentDirName() ?

Posted: Sun Sep 25, 2011 5:58 pm
by xenic
ssolie wrote:
xenic wrote:I think somebody is blowing hot air up your sleeve because by definition there can only be one "current" directory.
I think the guy who rewrote most of dos.library knows a tad more than you do... ;-)
A lot of people know more than I do :-) The GetCurrentDirName() autodoc states that it gets the CLI's current directory (cli.cli_CurrentDirName) which ChrisH and I have apparently misinterpreted to mean the program's (process) current directory. Maybe an additional statement in the autodoc like "The CLI current directory can be different than a process's current directory" would help. It too late to change function names but this function should really have been named GetCliCurrentDirName(). I guess I was the one blowing smoke :-)

Re: Bug in CurrentDir() or possibly GetCurrentDirName() ?

Posted: Tue Sep 27, 2011 8:53 am
by thomasrapp
You still didn't understand it right. There is no CLI current dir and process current dir. There can be only one current dir. But we are not talking about the current dir but about the current dir name. The CurrentDirName is a variable in the CLI structure which can be set by SetCurrentDirName and read by GetCurrentDirName. Nothing more. It is completely unrelated to the real current dir. The CD command sets it and the prompt %s placeholder reads it. It's not used anywhere else. It is not set automatically. And of course you are right, from a non-system programmer's point of view it is misleading and almost useless. The real current dir is a lock, not a string.