Bug in CurrentDir() or possibly GetCurrentDirName() ?

A forum for general AmigaOS 4.x support questions that are not platform-specific

Bug in CurrentDir() or possibly GetCurrentDirName() ?

Postby ChrisH » Fri Sep 23, 2011 1:40 pm

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: 915
Joined: Mon Dec 20, 2010 10:09 pm

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

Postby ChrisH » Fri Sep 23, 2011 1:48 pm

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

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

Postby xenic » Fri Sep 23, 2011 6:46 pm

@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 4:35 am, edited 1 time in total.
AmigaOne X1000 with 2GB memory - OS4.1 FE
xenic
 
Posts: 1160
Joined: Sun Jun 19, 2011 1:06 am

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

Postby ChrisH » Fri Sep 23, 2011 8:04 pm

@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: 915
Joined: Mon Dec 20, 2010 10:09 pm

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

Postby ChrisH » Sat Sep 24, 2011 4:05 pm

@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.
User avatar
ChrisH
Beta Tester
Beta Tester
 
Posts: 915
Joined: Mon Dec 20, 2010 10:09 pm

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

Postby xenic » Sun Sep 25, 2011 3:59 am

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
xenic
 
Posts: 1160
Joined: Sun Jun 19, 2011 1:06 am

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

Postby ssolie » Sun Sep 25, 2011 6:15 am

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
User avatar
ssolie
Beta Tester
Beta Tester
 
Posts: 1010
Joined: Mon Dec 20, 2010 9:51 pm
Location: Canada

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

Postby chris » Sun Sep 25, 2011 12:09 pm

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.
chris
 
Posts: 552
Joined: Sat Jun 18, 2011 12:05 pm

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

Postby xenic » Sun Sep 25, 2011 5:58 pm

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
xenic
 
Posts: 1160
Joined: Sun Jun 19, 2011 1:06 am

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

Postby thomasrapp » Tue Sep 27, 2011 8:53 am

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.
User avatar
thomasrapp
 
Posts: 277
Joined: Sun Jun 19, 2011 12:22 am

Next

Return to General AmigaOS

Who is online

Users browsing this forum: No registered users and 4 guests