Welcome, Guest. Please login or register.

Author Topic: It's all double-DOS to me...  (Read 1051 times)

Description:

0 Members and 1 Guest are viewing this topic.

Offline peroxidechickenTopic starter

  • Full Member
  • ***
  • Join Date: Apr 2002
  • Posts: 170
    • Show only replies by peroxidechicken
It's all double-DOS to me...
« on: April 09, 2004, 11:11:04 PM »
Back again.  This time I'd like any feedback I can get on the correct/standard way of processing the result of a user file selection done through an asl requester.  I intend the program I'm working on to start from workbench and shell but either way I've so far had no success with the SetCurrentDir() function.  I've had a close look at the fields in the process structure and noticed that none of them change even though SetCurrentDir() appears not to fail.  

Also, with calls such as CurrentDir() that take a directory lock as an input and give an old directory lock back as an output, is it up to me to free the old lock or should I just ignore it?  
H2O2
 

Offline Thomas

Re: It's all double-DOS to me...
« Reply #1 on: April 10, 2004, 12:18:17 AM »

Man, read the autodocs !!!!!!

Well, one way to do it is this:

char filename[256];
strcpy (filename,filereq->fr_Drawer);
AddPart (filename,filereq->fr_File,256);
f = Open(filename,MODE_OLDFILE);

Another way is this:

lock = Lock (filereq->fr_Drawer);
olddir = CurrentDir (lock);
f = Open (filereq->fr_File);
...
Close (f);
CurrentDir (olddir);
Unlock (lock);

As you can see you should store the result of CurrentDir and change it back before you leave.

SetCurrentDir() just sets the string which is displayed in the Shell prompt if you let it display the current path. It does not change the current directory.

Bye,
Thomas

Offline that_punk_guy

  • Hero Member
  • *****
  • Join Date: Aug 2002
  • Posts: 4526
    • Show only replies by that_punk_guy
Re: It's all double-DOS to me...
« Reply #2 on: April 10, 2004, 01:14:05 AM »
Worst. Pun. Ever.

:-D
 

Offline peroxidechickenTopic starter

  • Full Member
  • ***
  • Join Date: Apr 2002
  • Posts: 170
    • Show only replies by peroxidechicken
Re: It's all double-DOS to me...
« Reply #3 on: April 10, 2004, 10:35:53 PM »
Thanks Thomas.  I won't say I read all of the autodocs but I did read about the likely looking functions and there was still a question about CurrentDir() in my mind.  But you've solved that for me so, thanks!  

Gotta get myself that Bantam book on AmigaDOS...  
H2O2
 

Offline Noster

  • Sr. Member
  • ****
  • Join Date: Jan 2004
  • Posts: 375
    • Show only replies by Noster
Re: It's all double-DOS to me...
« Reply #4 on: April 12, 2004, 01:15:12 PM »
Hi

> As you can see you should store the result of CurrentDir and change it back before you leave.

Yeah, indeed you really MUST store the result of CurrentDir() and restore it before your application terminates, because this directory lock is not owned by your application, it is owned by the shell your application is started from (or the Workbench, if started by Workbench) and so you will corrupt your system if you simply free this lock and may meet the Guru...

Noster
DON\\\'T PANIC
    Douglas Adams - Hitch Hiker\\\'s Guide to the Galaxis