Bug in CurrentDir() or possibly GetCurrentDirName() ?

A forum for general AmigaOS 4.x support questions that are not platform-specific
User avatar
ChrisH
Beta Tester
Beta Tester
Posts: 920
Joined: Mon Dec 20, 2010 9:09 pm
Contact:

Bug in CurrentDir() or possibly GetCurrentDirName() ?

Post 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.
User avatar
ChrisH
Beta Tester
Beta Tester
Posts: 920
Joined: Mon Dec 20, 2010 9:09 pm
Contact:

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

Post 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.
xenic
Posts: 1185
Joined: Sun Jun 19, 2011 12:06 am

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

Post 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.
Last edited by xenic on Sat Sep 24, 2011 3:35 am, edited 1 time in total.
AmigaOne X1000 with 2GB memory - OS4.1 FE
User avatar
ChrisH
Beta Tester
Beta Tester
Posts: 920
Joined: Mon Dec 20, 2010 9:09 pm
Contact:

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

Post 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).
User avatar
ChrisH
Beta Tester
Beta Tester
Posts: 920
Joined: Mon Dec 20, 2010 9:09 pm
Contact:

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

Post 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.
xenic
Posts: 1185
Joined: Sun Jun 19, 2011 12:06 am

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

Post 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 :-)
AmigaOne X1000 with 2GB memory - OS4.1 FE
User avatar
ssolie
Beta Tester
Beta Tester
Posts: 1010
Joined: Mon Dec 20, 2010 8:51 pm
Location: Canada
Contact:

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

Post 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... ;-)
ExecSG Team Lead
chris
Posts: 562
Joined: Sat Jun 18, 2011 11:05 am
Contact:

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

Post 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.
xenic
Posts: 1185
Joined: Sun Jun 19, 2011 12:06 am

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

Post 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 :-)
AmigaOne X1000 with 2GB memory - OS4.1 FE
User avatar
thomasrapp
Posts: 310
Joined: Sat Jun 18, 2011 11:22 pm

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

Post 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.
Post Reply