It seems that the primary system call to change a new directory within an Amiga process is dos.library/CurrentDir(lock) but the documentation does not tell me how to detect if it succeeded.

Quoting from the documentation:


CurrentDir() causes a directory associated with a lock to be made the current directory. The old current directory lock is returned.

A value of zero is a valid result here, this 0 lock represents the root of file system that you booted from.

Any call that has to Open() or Lock() files (etc) requires that the current directory be a valid lock or 0.


lock - BCPL pointer to a lock


oldLock - BCPL pointer to a lock

The problem is the part where "a value of zero is a valid result". What would (or should) happen if I supply for example a file lock? They are the same type of objects.

1 Answer 1


The only thing CurrentDir() does is change the lock in your process structure that is used as the process' current directory, and return the old value.

So, it is the return value of Lock() applied to the directory you want to use that needs to be checked. If this is a valid/successful lock pointer, then you can be assured that it will become your current directory lock. If, however, it is an invalid lock pointer, then you will get an error on subsequent usage - e.g. when you try to call Open() on a relative path.

  • 2
    To be precise, it simply jams the value you supply into pr_CurrentDir and returns the old value. No checking is done. Feb 26, 2021 at 19:48
  • Ok, that makes sense. I wanted to use Lock() + CurrentDir() and hoped that Lock() would make sure it's a valid file or directory, and CurrentDir() would then make sure it's a directory you can read, but I guess I have to add some more checks.
    – pipe
    Feb 27, 2021 at 3:53

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .