Welcome, Guest. Please login or register.

Author Topic: Stopping "Insert Volume.." requesters with Lock()  (Read 1715 times)

Description:

0 Members and 1 Guest are viewing this topic.

Offline DoobreyTopic starter

  • Hero Member
  • *****
  • Join Date: Oct 2002
  • Posts: 1876
    • Show only replies by Doobrey
    • http://www.doobreynet.co.uk
Stopping "Insert Volume.." requesters with Lock()
« on: January 04, 2006, 08:23:03 PM »
 Is there an easy way to check that a file/dir exists without having that annoying "Please insert volume:blah blah" requester ?

 Or am I stuck having to LockDosList() and traverse the list to see if the volume exists ,and only then do a Lock() (not forgetting the UnlockDosList() after !!) ?


On schedule, and suing
 

Offline Piru

  • \' union select name,pwd--
  • Hero Member
  • *****
  • Join Date: Aug 2002
  • Posts: 6946
    • Show only replies by Piru
    • http://www.iki.fi/sintonen/
Re: Stopping "Insert Volume.." requesters with Lock()
« Reply #1 on: January 04, 2006, 08:38:33 PM »
@Doobrey
Quote
Is there an easy way to check that a file/dir exists without having that annoying "Please insert volume:blah blah" requester ?

Code: [Select]

#include <dos/dos.h>
#include <dos/dosextens.h>

#include <proto/exec.h>
#include <proto/dos.h>

BPTR LockQuiet(const char *name, LONG mode)
{
  struct Process *self = (APTR) FindTask(NULL);
  APTR oldwinptr;
  BPTR lock;

  oldwinptr = self->pr_WindowPtr;
  self->pr_WindowPtr = (APTR) -1;

  lock = Lock(name, mode);

  self->pr_WindowPtr = oldwinptr;

  return lock;
}


To test existance:
Code: [Select]

BPTR exists;

exists = LockQuiet("some:path/to/object", ACTION_READ);
if (exists)
{
  UnLock(exists);

  /* object exists */
}
else
{
  /* object doesn't exist */
}


Quote
Or am I stuck having to LockDosList() and traverse the list to see if the volume exists ,and only then do a Lock() (not forgetting the UnlockDosList() after !!) ?

No. That would break anyway: You must not Lock() while holding lock of the doslist.
 

Offline DoobreyTopic starter

  • Hero Member
  • *****
  • Join Date: Oct 2002
  • Posts: 1876
    • Show only replies by Doobrey
    • http://www.doobreynet.co.uk
Re: Stopping "Insert Volume.." requesters with Lock()
« Reply #2 on: January 04, 2006, 08:47:00 PM »
Thanks Piru, nice and simple...just what I needed.

Quote

You must not Lock() while holding lock of the doslist.


Ooops.. I meant LockDosList(), check for volume, UnlockDosList() then Lock()... honest guv ;-)
On schedule, and suing