[comp.sys.amiga.programmer] dos.library ACTION_SET_DATE question.

ben@epmooch.UUCP (Rev. Ben A. Mesander) (04/06/91)

I grabbed an excellent program called PickPacket from a fish disk. It's
a great tool to play with dos.library packets. 

I'm trying to set the date on a file with it. The first thing I do is
send an ACTION_LOCATE_OBJECT packet to df1:. I'm trying to set the date
on a file named "df1:ruru". The ACTION_LOCATE_OBJECT packet is filled out
with Arg1: NULL, Arg2: (BSTR) ruru, Arg3: EXCLUSIVE_LOCK.

It appears that I get a lock on the file "ruru". So now, I 
send an ACTION_SET_DATE packet with Arg1 being the lock I obtained from
the ACTION_LOCATE_OBJECT packet, and Arg2 being a pointer to a buffer
containing nulls (I want to set the date to "the beginning of time"). 

But I get an error back: "Invalid object lock". This happens whether I
give a shared or exclusive lock to the ACTION_SET_DATE packet.

What gives? What the heck am I doing wrong? Why isn't dos.library in the
RKMs? Why is the AmigaDOS manual (2nd Ed) so clear? :-)

--
| ben@epmooch.UUCP   (Ben Mesander)       | "Cash is more important than |
| ben%servalan.UUCP@uokmax.ecn.uoknor.edu |  your mother." - Al Shugart, |
| !chinet!uokmax!servalan!epmooch!ben     |  CEO, Seagate Technologies   |

ben@epmooch.UUCP (Rev. Ben A. Mesander) (04/07/91)

>In article <20441@cbmvax.commodore.com> jesup@cbmvax.commodore.com (Randell Jesup) writes:

[action set date packet info]

>	The format of the packet is:
>dp_Arg1: unused
>dp_arg2: lock
>dp_Arg3: name
>dp_Arg4: CPTR to datestamp

Wow! That isn't at *all* what was in "The AmigaDOS Manual" (2nd ed). In
fact, pickpacket has that packet defined as the book does, which is
wrong. Well, I just realized I had source, so I can fix it someday. Do I
actually have to call DeviceProc as described in the manual and fetch
the lock value from IoErr()? Can I fetch it by obtaining a lock on the
parent of the lock I have on the object?

Do I need to lock the object? I'm confused. What packets do I need to
send in order to set a file date?


>Randell Jesup, Keeper of AmigaDos, Commodore Engineering.
Thanks, Randell.

--
| ben@epmooch.UUCP   (Ben Mesander)       | "Cash is more important than |
| ben%servalan.UUCP@uokmax.ecn.uoknor.edu |  your mother." - Al Shugart, |
| !chinet!uokmax!servalan!epmooch!ben     |  CEO, Seagate Technologies   |

ben@epmooch.UUCP (Rev. Ben A. Mesander) (04/08/91)

>In article <182@atesysv.UUCP> lanzo@wgate.UUCP (Mark Lanzo) writes:
>In a prior article ben@epmooch.UUCP (Rev. Ben A. Mesander) wrote:
> >   I grabbed an excellent program called PickPacket from a fish disk. It's
> >   a great tool to play with dos.library packets. 
>    
>Another fine product brought to you by those folks at 
>the Software Distillery   :-)
[...]
>Unfortunately, I can't remember what the exact args for ACTION_SET_DATE
>are; but I'll take a few stabs in the dark:
>
>   1.  Pickpacket is incorrectly passing the pointer to the DateStamp
>       structure (BPTR vs APTR).
>
>   2.  Pickpacket is prompting for the wrong args, and you need:
>       Arg1 = Lock on parent, Arg2 = name of file, Arg3 = Ptr to DateStamp.
>       Note that Arg1 can NOT be null.  

Arg1 = unused
Arg2 = lock to parent dir (BPTR)
Arg3 = name of file (BSTR)
Arg4 = CPTR to date stamp

Thanks to you and Randall Jesup, I patched my copy of PickPacket. It works
fine for ACTION_SET_DATE (aside from the fact that I can only set the time
of a file to the "beginning of time") That's no big deal though, I can
always "touch" it later.

>Also, try this:
>
>   3a.  Get a lock on DF1:
>	  LOCATE_OBJECT:  Arg1=NULL, Arg2=NULL, Arg3=Shared
>	  (assume pickpacket returns "FileLock 1").
>   3b.  Get a lock on DF1:ruru
>	  LOCATE_OBJECT:  Arg1="FileLock 1", Arg2="ruru", Arg3=Shared
>	  (assume pickpacket returns "FileLock 2").
>   3c.  Now do the SET_DATE, using "FileLock 2".

Now that's strange - I thought that I had to put a lock on the parent
directory in the SET_DATE packet, not a lock on the file itself.

Also, I can set the date of a file using shared locks? That seems odd to
me also...

>If this is due to a bug in pickpacket 1.0, then the solution is to wait
>until I finish with pickpacket 2.0!

Yeah, except I'd like to get it done ASAP! :-)

Thanks, Mark.

--
| ben@epmooch.UUCP   (Ben Mesander)       | "Cash is more important than |
| ben%servalan.UUCP@uokmax.ecn.uoknor.edu |  your mother." - Al Shugart, |
| !chinet!uokmax!servalan!epmooch!ben     |  CEO, Seagate Technologies   |

jesup@cbmvax.commodore.com (Randell Jesup) (04/08/91)

In article <ben.5658@epmooch.UUCP> ben@epmooch.UUCP (Rev. Ben A. Mesander) writes:
>It appears that I get a lock on the file "ruru". So now, I 
>send an ACTION_SET_DATE packet with Arg1 being the lock I obtained from
>the ACTION_LOCATE_OBJECT packet, and Arg2 being a pointer to a buffer
>containing nulls (I want to set the date to "the beginning of time"). 

	The format of the packet is:
dp_Arg1: unused
dp_arg2: lock
dp_Arg3: name
dp_Arg4: CPTR to datestamp

>What gives? What the heck am I doing wrong? Why isn't dos.library in the
>RKMs? Why is the AmigaDOS manual (2nd Ed) so clear? :-)

	Comment/setdate/setprotect have "unusual" argument setups.  Dos
isn't in the RKMs because of contract written by someone long-gone from
commodore that gives Bantam exclusive rights to all Dos documentation.

-- 
Randell Jesup, Keeper of AmigaDos, Commodore Engineering.
{uunet|rutgers}!cbmvax!jesup, jesup@cbmvax.commodore.com  BIX: rjesup  
Disclaimer: Nothing I say is anything other than my personal opinion.
Thus spake the Master Ninjei: "To program a million-line operating system
is easy, to change a man's temperament is more difficult."
(From "The Zen of Programming")  ;-)

lanzo@wgate.UUCP (Mark Lanzo) (04/09/91)

In a prior article ben@epmooch.UUCP (Rev. Ben A. Mesander) wrote:
 >   I grabbed an excellent program called PickPacket from a fish disk. It's
 >   a great tool to play with dos.library packets. 
    
Another fine product brought to you by those folks at 
the Software Distillery   :-)

 >   I'm trying to set the date on a file with it. The first thing I do is
 >   send an ACTION_LOCATE_OBJECT packet to df1:. I'm trying to set the date
 >   on a file named "df1:ruru". The ACTION_LOCATE_OBJECT packet is filled out
 >   with Arg1: NULL, Arg2: (BSTR) ruru, Arg3: EXCLUSIVE_LOCK.
    
 >   It appears that I get a lock on the file "ruru". So now, I 
 >   send an ACTION_SET_DATE packet with Arg1 being the lock I obtained from
 >   the ACTION_LOCATE_OBJECT packet, and Arg2 being a pointer to a buffer
 >   containing nulls (I want to set the date to "the beginning of time"). 
    
 >   But I get an error back: "Invalid object lock". This happens whether I
 >   give a shared or exclusive lock to the ACTION_SET_DATE packet.


Unfortunately, I can't remember what the exact args for ACTION_SET_DATE
are; but I'll take a few stabs in the dark:

   1.  Pickpacket is incorrectly passing the pointer to the DateStamp
       structure (BPTR vs APTR).

   2.  Pickpacket is prompting for the wrong args, and you need:
       Arg1 = Lock on parent, Arg2 = name of file, Arg3 = Ptr to DateStamp.
       Note that Arg1 can NOT be null.  

Also, try this:

   3a.  Get a lock on DF1:
	  LOCATE_OBJECT:  Arg1=NULL, Arg2=NULL, Arg3=Shared
	  (assume pickpacket returns "FileLock 1").
   3b.  Get a lock on DF1:ruru
	  LOCATE_OBJECT:  Arg1="FileLock 1", Arg2="ruru", Arg3=Shared
	  (assume pickpacket returns "FileLock 2").
   3c.  Now do the SET_DATE, using "FileLock 2".

If this is due to a bug in pickpacket 1.0, then the solution is to wait
until I finish with pickpacket 2.0!

Yes, there really is a Pickpacket 2.0 in the works.  It incorporates
the DOS 2.0 packets, and the 2.0 "3D" look (It is still 1.3 
compatible though).

I'll double-check to see what the correct way to use SET_DATE is.
It definitely does work now in Pickpacket 2.0 -- I spent rather too
much time implementing that particular packet!  [With the new version you
allocate a DateStamp structure and give whatever date you want].

			More to come, ...

				Mark

mapjilg@gdr.bath.ac.uk (J I L Gold) (04/09/91)

In article <20441@cbmvax.commodore.com> jesup@cbmvax.commodore.com (Randell Jesup) writes:
>DOS isn't in the RKMs because of contract written by someone long-gone from
>commodore that gives Bantam exclusive rights to all Dos documentation.
>

Hmmm....and now the Bantam book is out of print, unavailable, ex-directory,
off-the-shelves and out to lunch. Isn't it time that someone at CBM addressed
this problem instead of making glib references to it? There are people out
here, there and everywhere who have spent hundred of dollars/pounds not only on 
their Amigas, but also nearly 100 pounds on the Hardware ref. man., Libs and
Devs and Includes/Autodocs, only to find that the information is far from
complete. Actually, now that I fell off my soap-box in all my excitement, 
does *anyone* out there know if Bantam intend to publish a shiny, moist, pink
and fluffy new edition of the AmigaDOS reference (updated for 2.0?)? Now 
*that* would be nice, maybe even (almost) worth the wait...

>-- 
>Randell Jesup, Keeper of AmigaDos, Commodore Engineering.
>{uunet|rutgers}!cbmvax!jesup, jesup@cbmvax.commodore.com  BIX: rjesup  
>Disclaimer: Nothing I say is anything other than my personal opinion.
>Thus spake the Master Ninjei: "To program a million-line operating system
>is easy, to change a man's temperament is more difficult."
>(From "The Zen of Programming")  ;-)


-- 
#  J.Gold                            |    mapjilg@uk.ac.bath.gdr               #
#  University of Bath , UK           |    jilg@uk.ac.bath.maths                #
#------------------------------------+-----------------------------------------#
# "Given that God is infinite, and that the universe is infinite, would you    #

jesup@cbmvax.commodore.com (Randell Jesup) (04/10/91)

In article <ben.5770@epmooch.UUCP> ben@epmooch.UUCP (Rev. Ben A. Mesander) writes:
>Arg1 = unused
>Arg2 = lock to parent dir (BPTR)
>Arg3 = name of file (BSTR)
>Arg4 = CPTR to date stamp
>
>Thanks to you and Randall Jesup, I patched my copy of PickPacket. It works
>fine for ACTION_SET_DATE (aside from the fact that I can only set the time
>of a file to the "beginning of time") That's no big deal though, I can
>always "touch" it later.

	Note that SetComment and SetProtect are similar to SetDate.

>Now that's strange - I thought that I had to put a lock on the parent
>directory in the SET_DATE packet, not a lock on the file itself.

	You have it right (though you can use a lock on the file and a null
name).

>Also, I can set the date of a file using shared locks? That seems odd to
>me also...

	Since the lock is on the parent, it's ok.

-- 
Randell Jesup, Keeper of AmigaDos, Commodore Engineering.
{uunet|rutgers}!cbmvax!jesup, jesup@cbmvax.commodore.com  BIX: rjesup  
Disclaimer: Nothing I say is anything other than my personal opinion.
Thus spake the Master Ninjei: "To program a million-line operating system
is easy, to change a man's temperament is more difficult."
(From "The Zen of Programming")  ;-)

ben@epmooch.UUCP (Rev. Ben A. Mesander) (04/10/91)

>In article <183@atesysv.UUCP> lanzo@wgate.UUCP (Mark Lanzo) writes:
[Re: PickPacket 1.0 and plans for PickPacket 2.0]

>      ( slinking off with proverbial tail between the legs :-) )

Hey! Cheer up! I fixed my copy of PickPacket, and now the 'make' I'm 
working on is happily 'touching' files. I really like PickPacket. It and
BlitLab are some of the best Amiga programmer's docs I've seen. I can
read about it in the AmigaDOS manual, and the RKM's, and then go try it
with minimal effort in an intuition based environment. It's fun, and
very informative.

Drop a line in the newsgroup when you finish version 2.0.

--
| ben@epmooch.UUCP   (Ben Mesander)       | "Cash is more important than |
| ben%servalan.UUCP@uokmax.ecn.uoknor.edu |  your mother." - Al Shugart, |
| !chinet!uokmax!servalan!epmooch!ben     |  CEO, Seagate Technologies   |

lanzo@wgate.UUCP (Mark Lanzo) (04/10/91)

As Randall Jesup has already pointed out, the args for SET_DATE are:

    Arg1 = unused
    Arg2 = lock to parent dir (BPTR)
    Arg3 = name of file (BSTR)
    Arg4 = CPTR to date stamp
    
Also,  ben@epmooch.UUCP (Rev. Ben A. Mesander) writes:

    >>Also, try this:
    >>
    >>   3a.  Get a lock on DF1:
    >>	  LOCATE_OBJECT:  Arg1=NULL, Arg2=NULL, Arg3=Shared
    >>	  (assume pickpacket returns "FileLock 1").
    >>   3b.  Get a lock on DF1:ruru
    >>	  LOCATE_OBJECT:  Arg1="FileLock 1", Arg2="ruru", Arg3=Shared
    >>	  (assume pickpacket returns "FileLock 2").
    >>   3c.  Now do the SET_DATE, using "FileLock 2".
    
    >Now that's strange - I thought that I had to put a lock on the parent
    >directory in the SET_DATE packet, not a lock on the file itself.

Whooops.  Brain fault.  Cortex dumped.  
What I was *trying* to say here was that it was important to get a lock 
on DF1: as the parent of the file "ruru", and then use that lock + the 
filename for subsequent calls to routines which take both a lock and 
a name.

The comment was triggered by a misconception I held for a while which 
really kept me confused for a long time while working on Pickpacket_2 -- 
namely, that a NULL for the parent lock meant "Root directory".  
The point I was originally trying to make was simply that you had to make
sure you had a real lock on the root of the volume, rather than using NULL.

          NULL_Lock + "ruru"   !=   Lock_on_DF1: + "ruru"

The LOCATE_OBJECT packet seems to have the special-case that a NULL
filelock represents the root directory for the volume, but other packets
don't also have this behavior (unfortunately, IMHO).

Also, the 3 steps shown above were based on the premise that the original
article was correct in its description of the args -- that Arg1 was a 
filelock, and Arg2 was the DateStamp. 

    >>If this is due to a bug in pickpacket 1.0, then the solution is to wait
    >>until I finish with pickpacket 2.0!
    
    >Yeah, except I'd like to get it done ASAP! :-)

Sigh.  Me too.  1/2 :-)      [ or is that 1/2 :-( ? ]

              
                  Back to work I guess,

			--Mark--
                        

      ( slinking off with proverbial tail between the legs :-) )